Summary
Open WebUI before 0.9.5 contains a stored cross-site scripting flaw in its OAuth profile image handling, where the MIME type of the picture claim URL is inferred from the file extension instead of the HTTP Content-Type header.
Malicious SVG files can bypass validation, be persisted as data URIs, and later be rendered for other authenticated users, enabling attacker-controlled script execution in the same origin that can steal tokens and lead to account takeover.
Affected context
This vulnerability arises in Open WebUI deployments that:
- Integrate OAuth providers and consume the
pictureclaim from user profile responses - Infer image MIME types from URL file extensions rather than the Content-Type header
- Persist profile images as data URIs and serve them back to authenticated users
- Render SVG content without strict sanitization, content security policies, or restrictive response headers
In such contexts, a crafted SVG profile image from an attacker-controlled OAuth account can be stored and later displayed to other users within the same origin.
Exploit preconditions
- Attack surface: Web UI profile image rendering within the authenticated application origin.
- Required access: Ability to authenticate via OAuth and control the
pictureclaim URL (e.g., by hosting a custom image endpoint). - Trigger point: A victim user or administrator visits any page or endpoint that loads the attacker's stored profile image as a data URI.
- Why exploitation is possible: The application trusts the URL file extension to infer image type, allowing SVG content to bypass validation. The SVG is stored and served without robust sanitization or protective security headers, permitting inline script execution in the browser.
Why this happens
The underlying issue is improper input validation and trust decisions around external profile image data, aligning with CWE-20 (Improper Input Validation).
Instead of using authoritative metadata such as the Content-Type header and enforcing a strict set of allowed image formats, the implementation infers MIME type from the URL's file extension and accepts SVG content without sanitization.
This insecure pattern allows attacker-controlled script-capable content to be persisted and rendered in a trusted origin, turning a seemingly benign profile image feature into a stored XSS vector.
Potential impact
- Attackers can execute arbitrary JavaScript in the context of the Open WebUI origin.
- Malicious scripts can access authentication tokens or session data, enabling account takeover.
- User profiles, application settings, and conversation history may be viewed or modified by attackers.
- Elevated or administrative accounts can be compromised if they view attacker-controlled profile images.
- Further lateral movement is possible through impersonation or API abuse using stolen credentials.
General mitigation guidance
Effective mitigation focuses on tightening validation of profile image inputs and reducing the trust placed in external content.
Common defensive patterns include:
- Validating image responses using the Content-Type header and accepting only a small, fixed list of safe raster formats (e.g., JPEG, PNG, WEBP).
- Rejecting, stripping, or strictly sanitizing SVG content before storage, especially when used in user profile images.
- Avoiding the storage and rendering of untrusted content as data URIs; prefer serving images as static resources through a controlled media pipeline.
- Applying least-privilege principles to client-side exposure, coupled with robust Content Security Policy (CSP) to restrict script execution and inline content.
- Implementing secure defaults for any profile-related features so that ambiguous or unsupported content types are blocked rather than allowed.
How teams detect issues like this
To detect similar issues, organizations can:
- Use static analysis rules and secure coding checks that flag reliance on file extensions for MIME type determination and any unsanitized handling of SVG or data URIs.
- Incorporate code review practices focusing on user profile features, OAuth claim consumption, and image processing paths, looking for improper validation and missing sanitization.
- Employ dynamic application security testing (DAST) to probe profile image endpoints with crafted SVG payloads and observe script execution behavior.
- Enforce internal policies and automated CI checks requiring Content-Type-based validation and disallowing script-capable formats in user-uploaded or external profile images.

