GHSA-6q87-84jw-cjhp

Suggest an improvement
Source
https://github.com/advisories/GHSA-6q87-84jw-cjhp
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/04/GHSA-6q87-84jw-cjhp/GHSA-6q87-84jw-cjhp.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-6q87-84jw-cjhp
Aliases
Published
2025-04-14T19:10:42Z
Modified
2025-04-16T00:40:49Z
Severity
  • 5.4 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N CVSS Calculator
Summary
@sveltejs/kit vulnerable to Cross-site Scripting via tracked search_params
Details

Summary

Unsanitized search param names cause XSS vulnerability. You are affected if you iterate over all entries of event.url.searchParams inside a server load function. Attackers can exploit it by crafting a malicious URL and getting a user to click a link with said URL.

Details

SvelteKit tracks which parameters in event.url.searchParams are read inside server load functions. If the application iterates over the these parameters, the uses.search_params array included in the boot script (embedded in the server-rendered HTML) will have any search param name included in unsanitized form.

packages/kit/src/runtime/server/utils.js:150 has the stringify_uses(node) function which prints these out.

Reproduction

In a +page.server.js or +layout.server.js:

/** @type {import('@sveltejs/kit').Load} */
export function load(event) {
  const values = {};

  for (const key of event.url.searchParams.keys()) {
    values[key] = event.url.searchParams.get(key);
  }
}

If a user visits the page in question via a link containing ?</script/><script>window.pwned%3D1</script/>, the </script> will be included verbatim in the payload, causing the embedded script to be executed.

It is not necessary to return the parameter value from load or render it in the page, only to read it (which causes it to be tracked as a dependency) while load is running.

Impact

Any application that iterates over all values in event.url.searchParams in a load function in +page.server.js or +layout.server.js (directly or indirectly) is vulnerable to XSS.

Database specific
{
    "nvd_published_at": "2025-04-15T23:15:42Z",
    "cwe_ids": [
        "CWE-79"
    ],
    "severity": "MODERATE",
    "github_reviewed": true,
    "github_reviewed_at": "2025-04-14T19:10:42Z"
}
References

Affected packages

npm / @sveltejs/kit

Package

Name
@sveltejs/kit
View open source insights on deps.dev
Purl
pkg:npm/%40sveltejs/kit

Affected ranges

Type
SEMVER
Events
Introduced
2.0.0
Fixed
2.20.6