CVE-2022-24303: Pillow Path Traversal Vulnerability

HIGH
Advisory Identifier: GHSA-9j59-75qj-795w
CVSS 9.1
CWE-22
Published
Advisory Summary

CVE-2022-24303 is a HIGH (CVSS 9.1) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Pillow libraries in the PyPI ecosystem. The issue involves path traversal in pillow. Remediation is available by upgrading affected packages to version 9.0.1.

CVE-2022-24303 at a Glance

CVE Identifier CVE-2022-24303
GHSA Identifier GHSA-9j59-75qj-795w
Severity HIGH
CVSS v3.1 Base Score 9.1
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Pillow
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 9.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2022-24303

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

Pillow fixed: 9.0.1
pip install Pillow>=9.0.1
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 Pillow

How to Check if You Are Affected

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

pip show Pillow

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

Note: The pip show Pillow 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 Pillow, 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

Pillow before 9.0.1 allows attackers to delete files because spaces in temporary pathnames are mishandled.

CVE-2022-24303 Affected Pillow Versions

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

References

Pillow Source Repository REPOSITORY
https://github.com/python-pillow/Pillow
Pillow Source Repository REPOSITORY
https://github.com/python-pillow/Pillow/blob/e8ab5640774716c5486d3cb05167f74f742ad6ef/CHANGES.rst?plain=1#L1172
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XR6UP2XONXOVXI4446VY72R63YRO2YTP
Pillow Release RELEASE
https://pillow.readthedocs.io/en/stable/releasenotes/9.0.1.html#security
NVD — CVE-2022-24303 NVD
https://nvd.nist.gov/vuln/detail/CVE-2022-24303
Pillow Source Repository REPOSITORY
https://github.com/python-pillow/Pillow/pull/3450
Pillow Source Repository REPOSITORY
https://github.com/python-pillow/Pillow/pull/6010
Security Fix Commit FIX COMMIT
https://github.com/python-pillow/Pillow/commit/10c4f75aaa383bd9671e923e3b91d391ea12d781
Security Fix Commit FIX COMMIT
https://github.com/python-pillow/Pillow/commit/143032103c9f2d55a0a7960bd3e630cb72549e8a
Security Fix Commit FIX COMMIT
https://github.com/python-pillow/Pillow/commit/427221ef5f19157001bf8b1ad7cfe0b905ca8c26
GitHub Advisory / Wiki ADVISORY
https://github.com/advisories/GHSA-9j59-75qj-795w
Pillow Source Repository REPOSITORY
https://github.com/pypa/advisory-database/tree/main/vulns/pillow/PYSEC-2022-168.yaml
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/W4ZUXPKEX72O3E5IHBPVY5ZCPMJ4GHHV
Pillow Security Information SECURITY
https://security.gentoo.org/glsa/202211-10

Frequently Asked Questions

What is CVE-2022-24303?
CVE-2022-24303 is a security vulnerability in Pillow involving Path traversal in Pillow under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Pillow versions are affected?
Affected versions include releases prior to 9.0.1 across affected packages: Pillow.
What version fixes CVE-2022-24303?
Upgrading to 9.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Pillow affected?
Yes, Pillow is affected in releases prior to 9.0.1. Upgrade your dependency to 9.0.1 or later.
What is the CVSS score of CVE-2022-24303?
CVE-2022-24303 has a CVSS v3.1 base score of 9.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H.
What CWE is associated with CVE-2022-24303?
CVE-2022-24303 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-2022-24303?
Run the dependency tree command: 'pip show Pillow'. 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-9j59-75qj-795w",
  "modified" : "2024-10-11T21:01:40Z",
  "published" : "2022-03-11T23:10:32Z",
  "aliases" : [ "CVE-2022-24303" ],
  "summary" : "Path traversal in Pillow",
  "details" : "Pillow before 9.0.1 allows attackers to delete files because spaces in temporary pathnames are mishandled.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Pillow"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "9.0.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-24303"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/python-pillow/Pillow/pull/3450"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/python-pillow/Pillow/pull/6010"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/python-pillow/Pillow/commit/10c4f75aaa383bd9671e923e3b91d391ea12d781"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/python-pillow/Pillow/commit/143032103c9f2d55a0a7960bd3e630cb72549e8a"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/python-pillow/Pillow/commit/427221ef5f19157001bf8b1ad7cfe0b905ca8c26"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-9j59-75qj-795w"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pillow/PYSEC-2022-168.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/python-pillow/Pillow"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/python-pillow/Pillow/blob/e8ab5640774716c5486d3cb05167f74f742ad6ef/CHANGES.rst?plain=1#L1172"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/W4ZUXPKEX72O3E5IHBPVY5ZCPMJ4GHHV"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XR6UP2XONXOVXI4446VY72R63YRO2YTP"
  }, {
    "type" : "WEB",
    "url" : "https://pillow.readthedocs.io/en/stable/releasenotes/9.0.1.html#security"
  }, {
    "type" : "WEB",
    "url" : "https://security.gentoo.org/glsa/202211-10"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-03-11T23:10:32Z",
    "nvd_published_at" : "2022-03-28T02:15:00Z"
  }
}