Summary
Snipe-IT contains a stored cross-site scripting vulnerability where uploaded files can be served inline without sufficient sanitization or content-type restrictions.
A low-privilege user can upload active XML-based content that is later rendered in a victim's browser under the same origin, allowing arbitrary JavaScript execution when the attachment is viewed.
Affected context
This vulnerability arises in Snipe-IT deployments that allow authenticated users to upload attachments which are later served inline from the same Snipe-IT origin.
It specifically affects scenarios where UploadFileRequest does not fully sanitize non-SVG XML/XHTML files, and UploadedFilesController returns these files inline without enforcing a strict safe-inline policy.
The risk is most pronounced when users routinely open attachments directly in their browser from within the Snipe-IT interface.
Exploit preconditions
- Attack surface: Web interface for file uploads and inline viewing of attachments.
- Required access: Authenticated low-privilege user with permission to upload attachments.
- Trigger point: A victim user opens or previews the malicious attachment delivered inline from the Snipe-IT instance.
- Why exploitation is possible: SVG sanitization is only applied based on a specific MIME type check, and other active XML/XHTML content is served inline without passing through a safety gate such as
StorageHelper::allowSafeInline(), enabling script execution under the application's origin.
Why this happens
The core issue is a stored cross-site scripting flaw where user-supplied file content is treated as passive data but can be interpreted as active web content by the browser.
UploadFileRequest ties SVG sanitization to the MIME type reported by PHP finfo, leaving other XML/XHTML payloads unsanitized.
UploadedFilesController then serves attachments inline, without a centralized safety check to distinguish safe, purely static content from active, script-capable markup.
This pattern maps to CWE-79: Improper Neutralization of Input During Web Page Generation, in this case via uploaded files that are later rendered in a browser context.
Potential impact
- Execution of arbitrary JavaScript in the context of the Snipe-IT origin.
- Theft of active user session tokens or other sensitive in-page data.
- Unauthorized actions performed on behalf of the victim (e.g., changing settings or manipulating assets) via CSRF-like behavior within the same origin.
- Deployment of persistent browser-based malware or malicious redirects for users who view the attachment.
General mitigation guidance
Effective mitigation focuses on treating all user-uploaded files as untrusted, especially when they may be rendered inline.
Recommended defensive patterns include:
- Strictly limiting which content types may be served inline and defaulting other types to forced download.
- Centralizing inline-delivery checks through a helper or policy function that enforces a whitelist of safe MIME types and disallows script-capable formats.
- Normalizing and validating MIME types using multiple signals (server-side detection, file extension, and, where applicable, magic bytes) rather than trusting a single source.
- Applying robust sanitization to any content that might be interpreted as HTML, SVG, XML, or XHTML before it is ever rendered in a browser.
- Reducing privileges of uploaded content by disabling inline rendering in contexts where it is not strictly necessary.
How teams detect issues like this
Organizations can detect similar vulnerabilities by:
- Reviewing controller and storage-layer code paths that serve user-uploaded files, checking for inline rendering and lack of centralized safety checks.
- Using static analysis to flag instances where user-controlled files or data are returned with
Content-Typeheaders that trigger HTML/XML/SVG rendering. - Adding automated tests that attempt to upload benign XSS test payloads in various file types (e.g., SVG, XHTML, XML) and verifying they are not executed when viewed.
- Incorporating security-focused code review checklists that explicitly ask whether uploaded files can be rendered inline and under what constraints.

