serve-static vulnerable to template injection that can lead to XSS
Published 10 Sept 2024 · Updated 10 Sept 2026
Affected packages
- Affected
- <1.16.0
- Fixed in
- 1.16.0
npm install serve-static@1.16.0- Affected
- >=2.0.0 <2.1.0
- Fixed in
- 2.1.0
npm install serve-static@2.1.0Details
Impact
passing untrusted user input - even after sanitizing it - to redirect() may execute untrusted code
Patches
this issue is patched in serve-static 1.16.0
Workarounds
users are encouraged to upgrade to the patched version of express, but otherwise can workaround this issue by making sure any untrusted inputs are safe, ideally by validating them against an explicit allowlist
Details
successful exploitation of this vector requires the following:
1. The attacker MUST control the input to response.redirect() 1. express MUST NOT redirect before the template appears 1. the browser MUST NOT complete redirection before: 1. the user MUST click on the link in the template
Is GHSA-cm22-4g7w-348p in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected serve-static, and gives you the command that fixes it.
References
- Linkgithub.com/expressjs/serve-static/security/advisories/GHSA-cm22-4g7w-348p
- Advisorynvd.nist.gov/vuln/detail/CVE-2024-43800
- Linkgithub.com/expressjs/serve-static/commit/0c11fad159898cdc69fd9ab63269b72468ecaf6b
- Linkgithub.com/expressjs/serve-static/commit/ce730896fddce1588111d9ef6fdf20896de5c6fa
- Packagegithub.com/expressjs/serve-static
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.