express vulnerable to XSS via response.redirect()
Affected releases · express
- 4.x4.0.0 – 4.19.2Fixed in 4.20.0
- 3.x and older0.14.0 – 3.21.2No fix, no longer updated
On 4.x, the newest line:
npm install express@4.20.0Not affected
5.0.0 – 5.3.0
6 releases, latest
Affected
4.0.0 – 4.19.2
87 releases
Fixed
4.20.0 – 4.22.3
8 releases
Affected
3.0.0 – 3.21.2
96 releases
Affected
2.0.0 – 2.5.11
39 releases
Affected
1.0.0 – 1.0.8
9 releases
Affected
0.14.0 – 0.14.1
2 releases
Is your project affected?
Paste your package.json, or type the range you declare for express. It is read in your browser and sent nowhere.
What happens
Impact
In express <4.20.0, passing untrusted user input - even after sanitizing it - to response.redirect() may execute untrusted code
Patches
this issue is patched in express 4.20.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:
The attacker MUST control the input to response.redirect()
express MUST NOT redirect before the template appears
the browser MUST NOT complete redirection before:
the user MUST click on the link in the template