Summary
Open WebUI's HTML rendering view allows injected scripts to execute within an iframe that is configured with permissive sandbox attributes, effectively bypassing intended isolation.
When untrusted chat content is rendered as HTML with script execution and same-origin access enabled, an attacker-controlled script can run in the user's browser and interact with parent context data such as local storage.
Affected context
This vulnerability arises in Open WebUI installations that:
- Use the HTML rendering view to visualize chat content in the browser
- Embed that content inside an iframe using a
sandboxattribute that still permitsallow-scripts,allow-forms, andallow-same-origin - Render user- or model-generated content without fully neutralizing active scripting capabilities
The issue primarily affects browser clients viewing chats in environments where content may include untrusted or semi-trusted HTML fragments.
Exploit preconditions
- Attack surface: Web UI in the browser, via the HTML chat visualization feature.
- Required access: Ability to inject or influence chat content that is later rendered in the HTML view (e.g., via user input, shared prompts, or data imported into the chat).
- Trigger point: A victim user opens or previews the affected chat using the HTML rendering view, causing the browser to load the iframe containing the malicious HTML.
- Why exploitation is possible: The iframe's
sandboxconfiguration includesallow-scriptsandallow-same-origin, which undermines isolation and permits the injected script to execute and interact with the parent origin context.
Why this happens
The root cause is a classic Cross-Site Scripting (XSS) pattern where untrusted content is rendered as active HTML/JavaScript without sufficient neutralization or isolation.
Although the content is placed in a sandboxed iframe, the inclusion of allow-scripts and allow-same-origin reintroduces most of the privileges that the sandbox was meant to restrict.
This maps to CWE-79: Improper Neutralization of Input During Web Page Generation, as the application assumes that the iframe sandbox alone provides adequate protection while still allowing script execution from untrusted content.
Potential impact
- Script execution in the context of the Open WebUI origin.
- Access to browser storage associated with the application (e.g., local storage, if exposed via same-origin).
- Impersonation of user actions within the UI, including sending prompts or modifying settings visible in the web interface.
- Exfiltration of sensitive information accessible from the client-side context, such as stored tokens or configuration data.
- Persistent or semi-persistent XSS if the malicious HTML remains associated with saved chats or shared content.
General mitigation guidance
Mitigation generally involves reducing the trust placed in rendered HTML content and tightening client-side isolation:
- Prefer rendering chat content as plain text or using robust HTML sanitization that removes or neutralizes scripts, event handlers, and dangerous attributes before display.
- Avoid enabling
allow-scriptsandallow-same-originon iframes that contain untrusted or user-controlled content; use a stricter sandbox policy that prevents script execution and blocks access to the parent origin. - Apply a default-deny approach for active content in the UI, only whitelisting minimal, well-audited functionality when absolutely necessary.
- Segment sensitive client-side data (such as tokens or configuration) so that it is not accessible to potentially compromised UI components, and ensure least-privilege access even within the browser.
- Encourage architectural patterns where potentially unsafe visualizations are hosted on separate origins or subdomains with no access to core application state.
How teams detect issues like this
Detection can focus on both code-level and behavior-level indicators:
- Static analysis and code review:
- Flag uses of
innerHTML,dangerouslySetInnerHTML, or similar APIs that insert raw HTML derived from user or model content. - Identify iframe
sandboxattributes that includeallow-scriptsandallow-same-originfor content that is not strictly trusted. - Review components responsible for rendering chat history, exports, or previews to ensure they either sanitize content or enforce strong isolation.
- Policy enforcement:
- Apply security linting rules in CI to prevent introduction of script-enabled iframes or unsanitized HTML rendering paths.
- Use Content Security Policy (CSP) to limit inline script execution and restrict script sources where feasible.
- Runtime monitoring:
- Monitor the application for unexpected script execution paths or DOM modifications originating from content areas intended to be passive.
Automated code scanning tools, browser-based security tests, and targeted penetration tests focusing on the HTML visualization feature can help discover similar issues.

