Safeguard
Security Guides•

Is it safe to render someone else's notebook with nbconvert?

Converting a notebook to HTML does not run its cells, but rendered output can carry script. The Jupyter CSP sandbox setting confines it. What to check.

Safeguard Security Team
3 min read

Converting without executing does not run the notebook's code cells, but saved outputs can contain HTML and JavaScript. Jupyter Server adds a sandbox to the Content-Security-Policy header for nbconvert pages by default, which confines that script. Executing during conversion is a different matter.

Two operations that sound alike

The nbconvert documentation describes converting and executing as separate things. Converting changes the format of a notebook file, for example to HTML. Executing runs the input cells and saves the results. The command that executes is the same tool with an execute flag added.

OperationRuns cell codeRisk to think about
Convert to HTML, no executeNoScript inside saved outputs when a person views the page
Convert with executeYesEverything the notebook code can do, as your account

For the second row see the companion post on running notebooks in CI.

The sandbox default

The Jupyter security documentation explains the problem. Unlike other documents, a notebook includes output, and that output exists in a context that can execute code through JavaScript. When notebooks are rendered through the server's nbconvert endpoints, the server adds a sandbox allow-scripts directive to the Content-Security-Policy header by default. That confines any JavaScript in the rendered output to a unique origin, preventing it from interacting with the Jupyter server.

The setting is called nbconvert_csp_sandbox, and the documentation shows it as True by default:

c.ServerApp.nbconvert_csp_sandbox = True

The word allow-scripts means scripts may still run. They are isolated, not forbidden. They can still draw things on the page.

What to check on your setup

  1. Leave the sandbox setting at its default unless you have a reason and a compensating control.
  2. If you publish converted HTML on a website, serve it from a separate domain from anything with logins, so script in an output cannot reach your sessions.
  3. Never publish notebooks from untrusted authors without clearing outputs first.
  4. Remember the Jupyter trust model: HTML and JavaScript from outputs you did not generate are untrusted.
  5. Keep your Jupyter packages current. Security fixes for notebook rendering ship in releases, as with the 2026 advisory covered in /resources/blog/jupyterlab-cve-2026-102832-trust-prompt-wrong-document.

A safer publishing flow

For a public report from your own notebook:

  1. Run it in a clean environment you control.
  2. Review the saved outputs, especially any HTML or widget output.
  3. Convert to a static format.
  4. Serve the result from a static host on its own domain.

For a notebook from outside your team, read it as text first, and clear outputs before you convert it.

Where Safeguard fits

Safeguard's SBOM and dependency scanning covers the packages behind your notebook tooling, and the pull request gates can flag a vulnerable version before it merges. Try the free scan at gold.safeguard.sh/scan.

Try it yourself

Click through it at your own pace, or open it full screen. See how a gate decides before anything merges.

Quick check

Does the sandbox block all JavaScript in rendered notebooks?

No. The directive is allow-scripts, so scripts can run, but they are confined to a unique origin.

Does converting a notebook to HTML execute its code cells?

Not unless you also ask nbconvert to execute it.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.