CVE-2024-49766: Werkzeug Werkzeug Safe_join Not Safe On Vulnerability

MODERATE
Advisory Identifier: GHSA-f9vj-2wh5-fj8j
CWE-22
Published
Advisory Summary

CVE-2024-49766 is a MODERATE werkzeug safe_join not safe on vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Werkzeug libraries in the PyPI ecosystem. The issue involves werkzeug safe_join not safe on windows. Remediation is available by upgrading affected packages to version 3.0.6.

CVE-2024-49766 at a Glance

CVE Identifier CVE-2024-49766
GHSA Identifier GHSA-f9vj-2wh5-fj8j
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Werkzeug
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2024-49766

To remediate this vulnerability, upgrade all affected Werkzeug dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

Werkzeug fixed: 3.0.6
pip install Werkzeug>=3.0.6
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show Werkzeug

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-49766, inspect your installed packages using pip:

pip show Werkzeug

Analyze the terminal output to locate any version of Werkzeug in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.6), your application is affected.

Note: The pip show Werkzeug command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Werkzeug, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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.

CVE-2024-49766 Affected Werkzeug Versions

1 component(s)
Fixed Versions:
3.0.6
Product / Package Ecosystem Affected Versions Fixed Version
Werkzeug
PyPI
< 3.0.6
3.0.6

References

Frequently Asked Questions

What is CVE-2024-49766?
CVE-2024-49766 is a security vulnerability in Werkzeug involving Werkzeug safe_join not safe on Windows under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Werkzeug versions are affected?
Affected versions include releases prior to 3.0.6 across affected packages: Werkzeug.
What version fixes CVE-2024-49766?
Upgrading to 3.0.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Werkzeug affected?
Yes, Werkzeug is affected in releases prior to 3.0.6. Upgrade your dependency to 3.0.6 or later.
What CWE is associated with CVE-2024-49766?
CVE-2024-49766 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check PyPI dependencies for CVE-2024-49766?
Run the dependency tree command: 'pip show Werkzeug'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-f9vj-2wh5-fj8j",
  "modified" : "2025-01-31T15:30:42Z",
  "published" : "2024-10-25T19:43:41Z",
  "aliases" : [ "CVE-2024-49766" ],
  "summary" : "Werkzeug safe_join not safe on Windows",
  "details" : "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.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Werkzeug"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.0.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.0.5"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pallets/werkzeug/security/advisories/GHSA-f9vj-2wh5-fj8j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-49766"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pallets/werkzeug/commit/2767bcb10a7dd1c297d812cc5e6d11a474c1f092"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pallets/werkzeug"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pallets/werkzeug/releases/tag/3.0.6"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20250131-0005"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-10-25T19:43:41Z",
    "nvd_published_at" : "2024-10-25T20:15:04Z"
  }
}