# CVE-2025-29787: zip Vulnerable to Incorrect Path Canonicalization During Archive Extraction, Leading to Arbitrary File Write

> Attackers can overwrite arbitrary files via malicious ZIP archives due to improper path canonicalization, potentially leading to code execution.

- **Severity:** High 7.3 (`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`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 17 Mar 2025
- **Updated:** 19 Mar 2025
- **Also known as:** GHSA-94vh-gphv-8pm8, RUSTSEC-2025-0168, UBUNTU-CVE-2025-29787

## What is CVE-2025-29787?

CVE-2025-29787 is a high-severity path traversal vulnerability in zip-rs zip2, published on 17 Mar 2025. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

`zip` is a zip library for rust which supports reading and writing of simple ZIP files. In the archive extraction routine of affected versions of the `zip` crate starting with version 1.3.0 and prior to version 2.3.0, 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. 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. Version 2.3.0 fixes the issue.

Weakness: CWE-61 (UNIX Symbolic Link (Symlink) Following), CWE-22 (Improper Limitation of a Pathname to a Restricted Directory), CWE-180 (Incorrect Behavior Order: Validate Before Canonicalize)

## Which versions are affected by CVE-2025-29787?

3 open source packages ship an affected version, including zip.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `zip` | crates.io | From 1.3.0 | 2.3.0 |
| `zip` | crates.io | From 1.3.0 | 2.3.0 |
| `zip` | crates.io | From 1.3.0 | 2.3.0 |

## How do I fix CVE-2025-29787?

Upgrade zip to 2.3.0 or later.

## Is CVE-2025-29787 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-29787 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-29787 and fix it if it is affected.

What it is: CVE-2025-29787 is a high-severity path traversal vulnerability in zip-rs zip2, published on 17 Mar 2025. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-29787 exists.

Affected packages and fixed versions:
- zip (crates.io): affected from 1.3.0; fixed in 2.3.0
- zip (crates.io): affected from 1.3.0; fixed in 2.3.0
- zip (crates.io): affected from 1.3.0; fixed in 2.3.0

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

## Sources

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

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