- Reported
-
- Issued
-
- Package
-
zip
(crates.io)
- Type
-
Vulnerability
- Categories
-
- Keywords
-
#symlink
#path-traversal
#extraction
- Aliases
-
- References
-
- CVSS Score
- 7.4
HIGH
- CVSS Details
-
- Attack Vector
- Network
- Attack Complexity
- High
- Privileges Required
- None
- User Interaction
- None
- Scope
- Unchanged
- Confidentiality Impact
- None
- Integrity Impact
- High
- Availability Impact
- High
- CVSS Vector
- CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:H
- Patched
-
- Unaffected
-
Description
Before writing an entry whose path goes through a symlink, ZipArchive::extract checks the symlink's target against the destination directory. That check compares the paths as text and does not follow symlinks, and from 7.2.0 it drops the root and prefix of an absolute target before comparing. Symlinks taken from the archive were created without any check of their targets.
A crafted archive can first create a symlink that points outside the destination, then a second symlink whose target looks like a path inside the destination but goes through the first one, and then a file entry under the second symlink. The file is written outside the destination directory, for example over an existing file in the user's home directory, and extract still returns Ok(()). On Windows, a target on another drive or share whose path otherwise matches the destination passes the check directly (creating symlinks there needs Developer Mode or administrator rights). The attacker has to know or guess the absolute path of the destination directory.
This affects ZipArchive::extract and ZipArchive::extract_unwrapped_root_dir.
The fix resolves symlink targets one component at a time from the canonicalized destination, following symlinks on the way, and refuses to create a symlink, or write through one, that leads outside the destination.
Advisory available under CC0-1.0
license.