Summary
A stored cross-site scripting (XSS) vulnerability in Open WebUI allows attacker-controlled document content to be rendered as HTML when citation previews are displayed.
By manipulating the html metadata property in chat history, an attacker can cause arbitrary script execution in users' browsers when they view affected chats or shared citations.
Affected context
The issue arises in Open WebUI's handling of chat history documents and their metadata.
When a document referenced in a chat contains metadata with html set, the frontend may treat its contents as trusted HTML and render them in an iframe during citation preview.
This becomes risky when chat history or document metadata can be modified by users or imported content without strict sanitization or validation, especially in multi-user or shared-chat scenarios.
Exploit preconditions
- Attack surface: Web UI (browser-based chat interface and shared chat views)
- Required access: Ability to create or modify chat history entries or associated document metadata, including setting the
htmlproperty - Trigger point: Viewing a chat that includes a citation referencing a weaponized document, or opening a shared chat containing such a citation
- Why exploitation is possible: The frontend follows a code path that interprets document contents as HTML based on the
htmlmetadata flag, and renders them without robust sanitization or isolation from the application's origin, allowing embedded JavaScript to execute in the context of the Open WebUI domain.
Why this happens
The underlying bug is a classic stored XSS condition where untrusted content is treated as trusted HTML.
The frontend uses a metadata flag (html) on documents to decide whether to render their contents as HTML in an iframe during citation preview.
Because this flag can be influenced through manual modification of chat history, and the resulting HTML content is not strictly sanitized or served from a strongly isolated origin, attacker-controlled script can execute in the user's browser.
This corresponds to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), where data from a lower trust source is incorporated into a web page as active HTML/JavaScript without appropriate neutralization.
Potential impact
- Execution of arbitrary JavaScript in the context of the Open WebUI origin
- Theft or exfiltration of chat content, prompts, and AI responses
- Impersonation of the victim within the web application (e.g., sending or modifying chats)
- Manipulation of AI interactions, including prompt injection at the UI layer
- Potential pivot to browser-based attacks (e.g., redirecting users, phishing overlays, keylogging within the application view)
General mitigation guidance
Effective mitigation focuses on treating document content and metadata as untrusted and minimizing any rendering as active HTML:
- Avoid using simple boolean flags (like
html) that cause untrusted content to be interpreted as raw HTML; prefer data-only formats (e.g., plain text or Markdown with a strict renderer). - Apply robust HTML sanitization on any content that might be rendered as HTML, stripping scripts, event handlers, and dangerous elements/attributes.
- Serve rich content from a strongly isolated context (e.g., sandboxed iframes with restrictive attributes and, where viable, different origins) to limit what injected script can access.
- Enforce strict validation on chat history and document metadata so that only expected, safe fields and values are permitted.
- Follow a least-privilege model for client-side components, ensuring that UI script has minimal access to sensitive in-page objects and tokens, reducing the blast radius if XSS occurs.
How teams detect issues like this
High-level detection approaches can help identify and prevent similar XSS issues:
- Static analysis: Search for code paths that render dynamic content as HTML (e.g.,
innerHTML, dangerouslySetInnerHTML, iframesrcdoc, or template injection) based on user-controlled metadata flags. - Code review: Flag any logic that switches from text rendering to HTML rendering using client-side flags or metadata fields that originate from stored data; verify sanitization, encoding, and sandboxing at these boundaries.
- Security testing: Use automated and manual XSS probes in chat content, document uploads, and history import/export flows to validate that user-supplied content cannot become executable HTML.
- Policy and tooling: Integrate secure coding guidelines into review checklists and optionally use SAST/DAST tools configured with rules for XSS patterns, particularly around iframe usage and HTML rendering shortcuts.

