Summary
Lobe Chat through v2.2.13 contains a stored cross-site scripting vulnerability in its user avatar upload feature. A low-privileged authenticated user may upload a crafted SVG file containing JavaScript, which can execute when the avatar is rendered in a vulnerable application context.
Affected context
The vulnerability occurs in Lobe Chat deployments that allow authenticated users to upload SVG files as avatars and later render those files without sufficiently restricting active content. Risk depends on how uploaded media is stored, served, embedded, and sanitized, as well as which users can view the affected avatar.
Exploit preconditions
- Attack surface: Authenticated avatar upload and rendering functionality
- Required access: A low-privileged authenticated account with permission to set or update an avatar
- Trigger point: A crafted SVG avatar is subsequently displayed in a browser context that permits script execution
- Why exploitation is possible: The application may treat user-controlled SVG content as trusted media without adequately removing scripts or isolating the uploaded file
Why this happens
The underlying issue is insufficient neutralization of user-controlled SVG content before it is stored and rendered.
SVG is an active document format that can contain script-capable elements or event handlers. When an application accepts uploaded SVG files as avatars and serves them in a browser-executable context without strict sanitization or isolation, attacker-controlled content may execute in another user's session. This maps to CWE-79: Improper Neutralization of Input During Web Page Generation, commonly known as cross-site scripting.
Potential impact
- A malicious script may execute in the context of a victim's session
- User-specific data may be exposed
- Authenticated actions may be performed without the victim's intent
- Session-related information or application tokens could be targeted
- Malicious content may persist and affect multiple users who view the avatar
General mitigation guidance
Mitigation generally focuses on treating uploaded SVG files as untrusted active content.
Common defensive patterns include:
- Prefer inert raster image formats for avatars where SVG is not required
- Apply robust allowlist-based SVG sanitization before storage or delivery
- Remove scripts, event handlers, external references, and unsafe elements from accepted SVG files
- Serve user-uploaded files from an isolated origin with restrictive content policies
- Use appropriate content types, download handling, and browser security headers
- Enforce authorization and least privilege for upload, replacement, and media access operations
- Avoid rendering untrusted uploads directly into privileged application pages
How teams detect issues like this
Organizations commonly detect this class of issue through:
- Static analysis checks for unsanitized user uploads rendered in HTML or image contexts
- Code review signals involving SVG parsing, direct file serving, innerHTML, or dynamic URL assignment
- Tests that upload active content and verify that scripts and event handlers cannot execute
- Content security policy monitoring for unexpected script execution or external resource loads
- Policy enforcement that restricts avatar uploads to approved inert formats
- Automated security testing and code review tools that identify stored XSS data flows

