diff --git a/docs/features/chat-conversations/chat-features/code-execution/artifacts.md b/docs/features/chat-conversations/chat-features/code-execution/artifacts.md index 5d2bcd2fb..8b70ee2cf 100644 --- a/docs/features/chat-conversations/chat-features/code-execution/artifacts.md +++ b/docs/features/chat-conversations/chat-features/code-execution/artifacts.md @@ -32,6 +32,28 @@ When Open WebUI creates an Artifact, you'll see the content displayed in a dedic - **Updates**: Open WebUI may update an existing Artifact based on your messages. The Artifact window will display the latest content. - **Actions**: Access additional actions for the Artifact, such as copying the content or opening the artifact in full screen, located in the lower right corner of the Artifact. +## Securing Artifact previews with CSP + +Artifact HTML previews are rendered inside an iframe. You can now apply a dedicated Content Security Policy (CSP) to those artifact iframes without changing the CSP used by the rest of Open WebUI. + +- **Admin setting**: **Admin Panel > Settings > General > Artifacts Content Security Policy** +- **Environment variable**: [`ARTIFACT_CONTENT_SECURITY_POLICY`](/reference/env-configuration#artifact_content_security_policy) +- **Default**: Empty, which leaves artifact previews on the browser default policy + +When this setting is populated, Open WebUI injects the configured policy into the artifact document before it is rendered. If the artifact already contains a `Content-Security-Policy` meta tag, Open WebUI replaces it with the configured value so the instance-wide artifact policy wins consistently. + +Use this when you want to limit what generated artifact HTML can load or execute, for example: + +- Block external scripts and network calls for untrusted generated content +- Allow only the specific image, font, or API origins your artifacts need +- Apply stricter restrictions to artifacts without tightening the main app's CSP + +:::tip + +Start permissive and tighten incrementally. Many generated artifacts rely on inline `