CVE-2025-29787: Zip Zip Incorrectly Canonicalizes Paths During Vulnerability

HIGH
Advisory Identifier: GHSA-94vh-gphv-8pm8
CWE-61 CWE-180 CWE-22
Published
Advisory Summary

CVE-2025-29787 is a HIGH zip incorrectly canonicalizes paths during vulnerability (CWE-61: UNIX Symbolic Link (Symlink) Following) affecting Zip libraries in the crates.io ecosystem. The issue involves zip incorrectly canonicalizes paths during archive extraction leading to arbitrary file write. Remediation is available by upgrading affected packages to version 2.3.0.

CVE-2025-29787 at a Glance

CVE Identifier CVE-2025-29787
GHSA Identifier GHSA-94vh-gphv-8pm8
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-61: UNIX Symbolic Link (Symlink) Following
Affected Product Zip
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix CVE-2025-29787

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

zip fixed: 2.3.0
Upgrade zip to 2.3.0
Verify Direct and Transitive Dependencies

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

inspect dependencies for zip

How to Check if You Are Affected

To determine whether your application is affected by CVE-2025-29787, inspect your project dependencies for Zip:

inspect dependencies for zip

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

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-61: UNIX Symbolic Link (Symlink) Following, where the product, when opening a file or directory, does not sufficiently account for when the file is a symbolic link that resolves to a target outside of the intended control sphere. this could allow an attacker to cause the product to operate on unauthorized files. In Zip, 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

### Summary In the archive extraction routine of affected versions of the `zip` crate, symbolic links earlier in the archive are allowed to be used for later files in the archive without validation of the final canonicalized path, allowing maliciously crafted archives to overwrite arbitrary files in the file system when extracted. ### Details This is a variant of the [zip-slip](https://github.com/snyk/zip-slip-vulnerability) vulnerability, we can make the extraction logic step outside of the target directory by creating a symlink to the parent directory and then extracting further files through that symlink. The documentation of the [`::zip::read::ZipArchive::extract`] method is in my opinion implying this should not happen: > "Paths are sanitized with ZipFile::enclosed_name." ... > [`::zip::read::FileOptions::enclosed_name`] ... is resistant to path-based exploits ... can’t resolve to a path outside the current directory. Most archive software either decline to extract symlinks that traverse out of the directory or defer creation of symlinks after all files have been created to prevent unexpected behavior when later entries depend on earlier symbolic link entries. ### PoC https://gist.github.com/eternal-flame-AD/bf71ef4f6828e741eb12ce7fd47b7b85 ### Impact Users who extract untrusted archive files using the following high-level API method may be affected and critical files on the system may be overwritten with arbitrary file permissions, which can potentially lead to code execution. - zip::unstable::stream::ZipStreamReader::extract - zip::read::ZipArchive::extract

CVE-2025-29787 Affected Zip Versions

1 component(s)
Fixed Versions:
2.3.0
Product / Package Ecosystem Affected Versions Fixed Version
zip
crates.io
≥ 1.3.0
< 2.3.0
2.3.0

References

Frequently Asked Questions

What is CVE-2025-29787?
CVE-2025-29787 is a security vulnerability in Zip involving zip Incorrectly Canonicalizes Paths during Archive Extraction Leading to Arbitrary File Write under CWE-61: UNIX Symbolic Link (Symlink) Following.
Which Zip versions are affected?
Affected versions include releases prior to 2.3.0 across affected packages: zip.
What version fixes CVE-2025-29787?
Upgrading to 2.3.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is zip affected?
Yes, zip is affected in releases prior to 2.3.0. Upgrade your dependency to 2.3.0 or later.
What CWE is associated with CVE-2025-29787?
CVE-2025-29787 is classified under CWE-61: UNIX Symbolic Link (Symlink) Following (The product, when opening a file or directory, does not sufficiently account for when the file is a symbolic link that resolves to a target outside of the intended control sphere. This could allow an attacker to cause the product to operate on unauthorized files.).
How can I check crates.io dependencies for CVE-2025-29787?
Run the dependency tree command: 'inspect dependencies for zip'. 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-94vh-gphv-8pm8",
  "modified" : "2025-03-19T15:51:04Z",
  "published" : "2025-03-17T21:26:32Z",
  "aliases" : [ "CVE-2025-29787" ],
  "summary" : "zip Incorrectly Canonicalizes Paths during Archive Extraction Leading to Arbitrary File Write",
  "details" : "### Summary\n\n\nIn the archive extraction routine of affected versions of the `zip` crate, symbolic links earlier in the archive are allowed to be used for later files in the archive without validation of the final canonicalized path, allowing maliciously crafted archives to overwrite arbitrary files in the file system when extracted.\n\n### Details\n\nThis is a variant of the [zip-slip](https://github.com/snyk/zip-slip-vulnerability) vulnerability, we can make the extraction logic step outside of the target directory by creating a symlink to the parent directory and then extracting further files through that symlink.\n\nThe documentation of the [`::zip::read::ZipArchive::extract`] method is in my opinion implying this should not happen:\n\n> \"Paths are sanitized with ZipFile::enclosed_name.\" ...\n> [`::zip::read::FileOptions::enclosed_name`] ... is resistant to path-based exploits ... can’t resolve to a path outside the current directory.\n\n\nMost archive software either decline to extract symlinks that traverse out of the directory or defer creation of symlinks after all files have been created to prevent unexpected behavior when later entries depend on earlier symbolic link entries.\n\n### PoC\n\nhttps://gist.github.com/eternal-flame-AD/bf71ef4f6828e741eb12ce7fd47b7b85\n\n### Impact\n\nUsers who extract untrusted archive files using the following high-level API method may be affected and critical files on the system may be overwritten with arbitrary file permissions, which can potentially lead to code execution.\n\n- zip::unstable::stream::ZipStreamReader::extract\n- zip::read::ZipArchive::extract",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:H/AT:N/PR:L/UI:N/VC:L/VI:H/VA:N/SC:H/SI:H/SA:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "zip"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.3.0"
      }, {
        "fixed" : "2.3.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/zip-rs/zip2/security/advisories/GHSA-94vh-gphv-8pm8"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-29787"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zip-rs/zip2/commit/a2e062f37066c3b12860a32eb1cb44856cfb7afe"
  }, {
    "type" : "WEB",
    "url" : "https://gist.github.com/eternal-flame-AD/bf71ef4f6828e741eb12ce7fd47b7b85"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/zip-rs/zip2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zip-rs/zip2/releases/tag/v2.3.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-180", "CWE-22", "CWE-61" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-03-17T21:26:32Z",
    "nvd_published_at" : "2025-03-17T14:15:22Z"
  }
}