Packages / serve-static / Security

LowVulnerabilityGHSA-cm22-4g7w-348pCVE-2024-43800Published 10 Sep 2024

serve-static vulnerable to template injection that can lead to XSS

Your version

Affected releases · serve-static

  • 2.x2.0.0Fixed in 2.1.0
  • 1.x1.0.0 – 1.15.0Fixed in 1.16.0

On 2.x, the newest line:

npm install serve-static@2.1.0
Every release on a timeline
2.x
  1. Affected

    2.0.0

    1 release

  2. Fixed

    2.1.0 – 2.2.1

    3 releases, latest

1.x
  1. Affected

    1.0.0 – 1.15.0

    59 releases

  2. Fixed

    1.16.0 – 1.16.3

    4 releases

67 stable releases of serve-static, oldest to newest, one row per major.

What happens

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()

  2. express MUST NOT redirect before the template appears

  3. the browser MUST NOT complete redirection before:

  4. the user MUST click on the link in the template