feat: add IFRAME_CSP env var for srcdoc iframe content security policy

Adds an IFRAME_CSP environment variable that injects a Content-Security-Policy
<meta> tag into all srcdoc iframes rendering untrusted content:
- Artifacts (LLM-generated HTML previews)
- FullHeightIframe (tool/embed output)
- FilePreview (user-uploaded HTML files)
- CitationModal (RAG document HTML)

Shared utility in src/lib/utils/csp.ts handles injection with HTML-safe
attribute escaping. URL-based iframes (src=) are correctly excluded.

Env-var only — no PersistentConfig, no admin UI, no DB. Set once at deploy
time, requires restart. Empty string (default) means no CSP restriction.
This commit is contained in:
Timothy Jaeryang Baek committed 2026-05-11 01:56:02 +09:00
1 parent 1388f4568b
commit 3bba1c2270
8 files changed
+30 -6

No files matched your search

+1
View File
@@ -1376,6 +1376,7 @@ RESPONSE_WATERMARK = PersistentConfig(
os.environ.get('RESPONSE_WATERMARK', ''),
)
IFRAME_CSP = os.environ.get('IFRAME_CSP', '')
USER_PERMISSIONS_WORKSPACE_MODELS_ACCESS = (
os.environ.get('USER_PERMISSIONS_WORKSPACE_MODELS_ACCESS', 'False').lower() == 'true'