# CVE-2024-29041: Express.js Open Redirect in malformed URLs

> Attackers can bypass redirect allow lists in Express.js applications using malformed URLs, leading to open redirects.

- **Severity:** Medium 6.1 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 25 Mar 2024
- **Updated:** 2 Aug 2024
- **Also known as:** AZL-37137, AZL-43690, AZL-44361, CLSA-2026-1792597402, DEBIAN-CVE-2024-29041, GHSA-rv95-896h-c2vc, MINI-pj65-wr82-8q53, ROOT-APP-NPM-CVE-2024-29041, UBUNTU-CVE-2024-29041

## What is CVE-2024-29041?

CVE-2024-29041 is a medium-severity vulnerability in expressjs express, published on 25 Mar 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

Express.js minimalist web framework for node. Versions of Express.js prior to 4.19.0 and all pre-release alpha and beta versions of 5.0 are affected by an open redirect vulnerability using malformed URLs. When a user of Express performs a redirect using a user-provided URL Express performs an encode [using `encodeurl`](https://github.com/pillarjs/encodeurl) on the contents before passing it to the `location` header. This can cause malformed URLs to be evaluated in unexpected ways by common redirect allow list implementations in Express applications, leading to an Open Redirect via bypass of a properly implemented allow list. The main method impacted is `res.location()` but this is also called from within `res.redirect()`. The vulnerability is fixed in 4.19.2 and 5.0.0-beta.3.

Weakness: CWE-601 (URL Redirection to Untrusted Site), CWE-1286 (Improper Validation of Syntactic Correctness of Input)

## Which versions are affected by CVE-2024-29041?

4 open source packages ship an affected version, including express. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `express` | npm | All versions | 4.19.2 |
| `express` | npm | All versions | 4.19.2 |
| `express` | npm | From 5.0.0-alpha.1 | 5.0.0-beta.3 |
| `express` | npm | From 5.0.0-alpha.1 | 5.0.0-beta.3 |

Products: Openjsf Express.

## How do I fix CVE-2024-29041?

Upgrade express to a fixed version for your release line: 4.19.2 or 5.0.0-beta.3.

## Is CVE-2024-29041 being exploited?

There is no known exploitation of CVE-2024-29041 in the wild and no public exploit code.

## Other vulnerabilities in expressjs express

- [CVE-2014-6393](https://insights.sbomify.com/CVE-2014-6393/): No Charset in Content-Type Header in express (medium 6.1)
- [CVE-2024-43796](https://insights.sbomify.com/CVE-2024-43796/): express vulnerable to XSS via response.redirect() (medium 5.0)
- [CVE-2024-10491](https://insights.sbomify.com/CVE-2024-10491/): Preload arbitrary resources by injecting additional `Link` headers (medium 4.0)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-29041 and fix it if it is affected.

What it is: CVE-2024-29041 is a medium-severity vulnerability in expressjs express, published on 25 Mar 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2024-29041 in the wild and no public exploit code.

Affected packages and fixed versions:
- express (npm): affected all versions; fixed in 4.19.2
- express (npm): affected all versions; fixed in 4.19.2
- express (npm): affected from 5.0.0-alpha.1; fixed in 5.0.0-beta.3
- express (npm): affected from 5.0.0-alpha.1; fixed in 5.0.0-beta.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-29041/ (Markdown: https://insights.sbomify.com/CVE-2024-29041/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-29041
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-29041
- OSV: https://osv.dev/vulnerability/CVE-2024-29041

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-29041/
Summaries are generated and may contain mistakes; the official description above is the record.
