Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: don't sanitize when auto-instantiate is on (#7077)

Myles Scolnick24ca13764360
diff --git a/docs/security.md b/docs/security.md
index acc09523d4..b98c00d215 100644
--- a/docs/security.md
+++ b/docs/security.md
@@ -31,11 +31,13 @@ Code only runs when you explicitly execute cells.
marimo behaves differently depending on how you run it:
**Edit mode** (`marimo edit`):
-- Content is sanitized until you run your first cell
+
+- Content is sanitized until you run your first cell or `auto_instantiate` is enabled (by default it is `disabled`)
- After you run code, subsequent outputs are trusted (you created them)
- Token authentication enabled by default for remote access
**Run mode** (`marimo run`):
+
- Notebooks run as web applications
- Content is treated as a trusted website (no sanitization)
- Token authentication can be configured via CLI flags or custom middleware
@@ -129,7 +131,7 @@ For general questions about marimo, see our [FAQ](faq.md) or join us on [Discord
<ul>
<li><strong><a href="https://github.com/marimo-team/marimo/security/advisories/GHSA-xjv7-6w92-42r7">[GHSA-xjv7-6w92-42r7]</a></strong>: Unauthenticated proxy vulnerability in matplotlib endpoint. The <code>/mpl/[port]/[route]</code> endpoint allowed external attackers to reach internal services. Affected versions 0.9.20 through 0.16.3. Fixed in 0.16.4. </li>
-
+
<li><strong>[molab-0]</strong>: iframe sandbox escape via markdown render. In molab, an attacker could exploit a vulnerability in the iframe sandboxing to escape the iframe and execute code in the parent context. Fixed in molab deployment on 2025-10-19.</li>
</ul>
diff --git a/frontend/src/plugins/core/sanitize.ts b/frontend/src/plugins/core/sanitize.ts
index 074959e3cd..5b7b1fcd18 100644
--- a/frontend/src/plugins/core/sanitize.ts
+++ b/frontend/src/plugins/core/sanitize.ts
@@ -2,6 +2,7 @@
import DOMPurify, { type Config } from "dompurify";
import { atom, useAtomValue } from "jotai";
import { hasRunAnyCellAtom } from "@/components/editor/cell/useRunCells";
+import { autoInstantiateAtom } from "@/core/config/config";
import { getInitialAppMode } from "@/core/mode";
/**
@@ -11,10 +12,11 @@ import { getInitialAppMode } from "@/core/mode";
*/
const sanitizeHtmlAtom = atom<boolean>((get) => {
const hasRunAnyCell = get(hasRunAnyCellAtom);
+ const autoInstantiate = get(autoInstantiateAtom);
- // If a user has specifically run at least one cell, we don't need to sanitize.
+ // If a user has specifically run at least one cell or auto_instantiate is enabled, we don't need to sanitize.
// HTML needs to be rich to allow for interactive widgets and other dynamic content.
- if (hasRunAnyCell) {
+ if (hasRunAnyCell || autoInstantiate) {
return false;
}