CVE-2024-29041: Express.js open redirect in malformed URLs

CVE-2024-29041 · Severity: low · CVSS 3.1 · Published 2024-03-25

Express.js is a widely-used web application framework for Node.js. Applications using Express redirect functions with user-provided URLs can be tricked into redirecting users to attacker-controlled websites, bypassing security controls. An attacker can exploit this by crafting a malformed URL that passes validation checks, potentially leading to credential theft, malware distribution, or phishing attacks.

Technologies: Express.

Quick answers

Is CVE-2024-29041 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2024-29041 being exploited in the wild.
How severe is CVE-2024-29041?
Low severity, with a CVSS score of 3.1, published 25 March 2024.
Which products and versions are affected?
Express SEMVER:introduced=0,fixed=4.19.2.
Is there a fix for CVE-2024-29041?
Yes. Express: upgrade to 4.19.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2024-29041 attacked?
It is attacked over the network.
Am I affected by CVE-2024-29041?
Check whether you run Express at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • Express: upgrade to 4.19.2 or later

Technical details

This is an open redirect vulnerability (CWE-601, CWE-1286) affecting the res.location() and res.redirect() methods in Express.js versions prior to 4.19.2 and 5.0.0-beta.3. The vulnerability exists because Express encodes user-provided URLs using encodeurl before adding them to the location header, but this encoding can cause malformed URLs to be evaluated unexpectedly by redirect allowlist implementations. An attacker can craft a specially-formatted URL that bypasses the application's allow-list checks, causing legitimate users (who must click a link) to be redirected to an attacker-controlled site. The fix involves pre-parsing URLs using Node.js built-in URL parsing (require('node:url').parse or new URL) before passing them to the redirect functions. Patches are available in Express 4.19.2 and 5.0.0-beta.3.

Affected products

  • Express.js Express <4.19.2, >=5.0.0-alpha.1 <5.0.0-beta.3

Identifiers

  • CVE-2024-29041
  • GHSA-rv95-896h-c2vc

Timeline

  • 2024-03-25: disclosed: Vulnerability published in GHSA-rv95-896h-c2vc
  • 2024-03-25: patched: Express 4.19.2 and 5.0.0-beta.3 released with fixes

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.