# CVE-2024-49766: Werkzeug safe_join not safe on Windows


- **Severity:** Medium 6.3 (`CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N`)
- **Exploited in the wild:** Not known
- **Fix available:** Yes
- **Published:** 25 Oct 2024
- **Updated:** 31 Jan 2025
- **Also known as:** CLEANSTART-2026-KC63022, CLEANSTART-2026-LS94875, ECHO-9c5b-9fe7-f077, GHSA-f9vj-2wh5-fj8j, MINI-c474-jj9x-pjjm, MINI-h843-xcjh-979v, PYSEC-2026-2045, ROOT-APP-PYPI-CVE-2024-49766

## What is CVE-2024-49766?

CVE-2024-49766 is a medium-severity vulnerability in pallets werkzeug, published on 25 Oct 2024. 

### Official description

Werkzeug is a Web Server Gateway Interface web application library. On Python < 3.11 on Windows, os.path.isabs() does not catch UNC paths like //server/share. Werkzeug's safe_join() relies on this check, and so can produce a path that is not safe, potentially allowing unintended access to data. Applications using Python >= 3.11, or not using Windows, are not vulnerable. Werkzeug version 3.0.6 contains a patch.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

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

3 open source packages ship an affected version, including werkzeug and Werkzeug. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `werkzeug` | PyPI | All versions | 3.0.6 |
| `werkzeug` | PyPI | All versions | 3.0.6 |
| `Werkzeug` | PyPI | All versions | 3.0.6 |

Products: Palletsprojects Werkzeug.

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

Upgrade werkzeug to 3.0.6 or later.

## Is CVE-2024-49766 being exploited?

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

## Other vulnerabilities in pallets werkzeug

- [CVE-2022-29361](https://insights.sbomify.com/CVE-2022-29361/): Other in n/a (critical 9.8)
- [CVE-2023-46136](https://insights.sbomify.com/CVE-2023-46136/): Werkzeug DoS: High resource usage when parsing multipart/form-data containing a large part with CR/LF character at the beginning (high 8.0)
- [CVE-2023-25577](https://insights.sbomify.com/CVE-2023-25577/): Werkzeug may allow high resource usage when parsing multipart form data with many fields (high 7.5)
- [CVE-2019-14322](https://insights.sbomify.com/CVE-2019-14322/): Pallets Werkzeug vulnerable to Path Traversal (high 7.5)
- [CVE-2026-27199](https://insights.sbomify.com/CVE-2026-27199/): Werkzeug safe_join() allows Windows special device names (medium 6.3)

## Fix prompt for AI coding agents

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

What it is: CVE-2024-49766 is a medium-severity vulnerability in pallets werkzeug, published on 25 Oct 2024. 
Exploitation: There is no known exploitation of CVE-2024-49766 in the wild and no public exploit code.

Affected packages and fixed versions:
- werkzeug (PyPI): affected all versions; fixed in 3.0.6
- werkzeug (PyPI): affected all versions; fixed in 3.0.6
- Werkzeug (PyPI): affected all versions; fixed in 3.0.6

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-49766/ (Markdown: https://insights.sbomify.com/CVE-2024-49766/index.md)
```

## Sources

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

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