IT lexicon › Security › iframe sandbox

iframe sandbox

Security På svenska → Updated: 2026-07-30

HTML5 attribute on <iframe> that drastically restricts what embedded content may do. <iframe sandbox> = max-restrictive (no JS, no forms, no popups, no top-navigation, unique origin).

Granular opt-ins via allow flag: sandbox="allow-scripts allow-forms allow-same-origin". Modern use: embedding user-generated HTML (rich-text editor preview, embedded snippets) safely. Cloud IDEs: CodeSandbox runs user code in a sandboxed iframe + service worker for isolation. Anti-pattern: allow-scripts allow-same-origin together → escape possibility, breaks sandbox. Combine with CSP frame-src for defense-in-depth. iframe srcdoc + sandbox = inline-secured embedding.

← Back to the lexicon