Summary
Traccar versions starting with 6.11.1 allow authenticated users to upload SVG files as device images that are later rendered in other users' browsers without sanitization.
Because these SVGs are served with the image/svg+xml Content-Type, embedded JavaScript can execute in the context of viewers' sessions, enabling stored cross-site scripting (XSS) attacks against other authenticated users.
Affected context
This vulnerability arises in the Traccar web application where users can upload device images, including SVG files, that are later displayed to other users.
The risk is present when:
- Authenticated users are permitted to upload SVGs as images,
- The server stores and serves these SVGs without sanitization or transformation, and
- Browsers are instructed to interpret them as
image/svg+xmlrather than a purely static image format.
In such deployments, any user with upload permissions can introduce active content that runs in the browsers of other users viewing affected pages.
Exploit preconditions
- Attack surface: Web interface for uploading device images and viewing device details or lists.
- Required access: Authenticated user with permission to upload device images; no elevated privileges are strictly required beyond upload capability.
- Victim interaction: Another user (e.g., administrator, dispatcher, or operator) must browse to a page where the malicious device image is rendered by the application.
- Trigger point: Browser loads and renders the attacker-supplied SVG served with
image/svg+xml, allowing any embedded script to execute in the victim's session. - Why exploitation is possible: The application does not sanitize SVG content, does not restrict it to a safe subset, and serves it with a content type that permits script execution, thereby treating untrusted user-controlled data as active content in other users' browsers.
Why this happens
The underlying issue is the combination of accepting untrusted SVG uploads and rendering them as active SVG documents without sanitization or neutralization.
SVG is not just an image format; it is an XML-based document type that can contain script blocks, event handlers, and external resource references.
By storing these SVGs verbatim and serving them with image/svg+xml, the application allows attacker-controlled markup and JavaScript to execute in the security context of any user who views the image.
This maps primarily to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), where untrusted content is rendered in a web page without removing or neutralizing scriptable constructs.
It is also related to CWE-434: Unrestricted Upload of File with Dangerous Type, because the application permits upload and subsequent execution of a file type that can contain active script content.
Potential impact
- Theft of session tokens or other sensitive data accessible via the victim's browser context.
- Unauthorized actions performed on behalf of the victim, such as modifying devices, changing tracking settings, or altering system configuration.
- Creation of new privileged accounts or escalation of privileges if an administrator views the malicious image.
- Persistent compromise of user accounts through in-browser backdoors or malicious JavaScript that re-injects itself into other pages.
- Use of the platform as a pivot for broader attacks, including targeting integrated services or APIs accessed through the victim's session.
General mitigation guidance
Effective mitigation focuses on treating user-uploaded files as untrusted content and ensuring they cannot execute active code in other users' browsers.
Common defensive patterns include:
- Restricting allowed file types for user-uploaded images to inherently passive formats such as JPEG and PNG, and rejecting SVG uploads altogether where they are not strictly necessary.
- If SVG support is required, enforcing strict sanitization of uploaded SVG markup, removing scripts, event handlers, external references, and any elements or attributes that can trigger script execution.
- Serving uploaded files from a separate origin or domain with tightly controlled Content Security Policy (CSP), minimizing the ability of uploaded content to access application cookies or DOM.
- Forcing SVGs to be treated as downloads or static images (e.g., serving them as
image/*only in controlled ways, or rasterizing on the server) rather than active XML documents that can execute script. - Applying least-privilege access controls to upload features, limiting which roles can upload or modify shared resources, and auditing changes to shared images.
- Encoding and contextual output escaping for any user-supplied metadata rendered alongside images (names, descriptions) to avoid additional XSS vectors.
How teams detect issues like this
Detection often combines code-level review with runtime monitoring:
- Static analysis and code review:
- Identify file upload endpoints that accept SVG or other active content types.
- Look for direct storage and serving of uploaded files without sanitization or content-type enforcement.
- Flag any logic that returns user-controlled SVGs with
image/svg+xmlor other script-capable content types. - Security testing:
- Perform manual and automated penetration tests that upload SVG files containing benign script markers to verify whether scripts execute when viewing the image.
- Use dynamic application security testing (DAST) tools configured to probe for file upload XSS via SVG and other document types.
- Operational monitoring:
- Monitor logs for unusual patterns in file uploads, such as SVG files where image formats are expected.
- Inspect CSP violation reports and browser security logs (where available) for script execution originating from uploaded file paths.
- Automated code scanning and review tools can be configured with rules targeting CWE-79 and CWE-434 patterns around file uploads and content serving paths.

