mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-18 05:05:09 +02:00
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:
@@ -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'
|
||||
|
||||
@@ -460,6 +460,7 @@ from open_webui.config import (
|
||||
OAUTH_PROVIDERS,
|
||||
WEBUI_URL,
|
||||
RESPONSE_WATERMARK,
|
||||
IFRAME_CSP,
|
||||
# Admin
|
||||
ENABLE_ADMIN_CHAT_ACCESS,
|
||||
ENABLE_ADMIN_ANALYTICS,
|
||||
@@ -2444,6 +2445,7 @@ async def get_app_config(request: Request):
|
||||
'pending_user_overlay_title': app.state.config.PENDING_USER_OVERLAY_TITLE,
|
||||
'pending_user_overlay_content': app.state.config.PENDING_USER_OVERLAY_CONTENT,
|
||||
'response_watermark': app.state.config.RESPONSE_WATERMARK,
|
||||
'iframe_csp': IFRAME_CSP,
|
||||
},
|
||||
'license_metadata': app.state.LICENSE_METADATA,
|
||||
**(
|
||||
|
||||
Reference in New Issue
Block a user