Dev.to Security 🔐 Cybersecurity 👁 0 📖 3 min read

CVE-2026-61725: CVE-2026-61725: Path Traversal and Arbitrary File Overwrite in sevenz-rust2

CVE-2026-61725: Path Traversal and Arbitrary File Overwrite in sevenz-rust2 Vulnerability ID: CVE-2026-61725 CVSS Score: 6.1 Published: 2026-11-20 CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sev

CVE-2026-61725: Path Traversal and Arbitrary File Overwrite in sevenz-rust2

Vulnerability ID: CVE-2026-61725
CVSS Score: 6.1
Published: 2026-11-20

CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sevenz-rust2 Cargo package prior to version 0.21.1. The vulnerability occurs because the decompression utility fails to validate or sanitize archive entry filenames before joining them with the destination directory path via std::path::Path::join. An attacker who supplies a crafted 7z archive containing parent directory traversal sequences or absolute paths can write or overwrite arbitrary files on the host filesystem with the privileges of the extracting process.

TL;DR

Versions of sevenz-rust2 prior to 0.21.1 do not sanitize archive entry filenames during extraction, allowing attackers to achieve arbitrary file write and overwrite via specially crafted 7z archives containing path traversal sequences or absolute file paths.

⚠️ Exploit Status: POC

Technical Details

  • CVE ID: CVE-2026-61725 (GHSA-qh76-45cr-8xrc)
  • Weakness Class: CWE-22 / CWE-23 (Path Traversal / Zip-Slip)
  • Affected Component: sevenz-rust2 (< 0.21.1) in src/util/decompress.rs
  • CVSS v3.1 Score: 6.1 Medium (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:L)
  • EPSS Score: 0.14% (3.24th Percentile)
  • Impact: Arbitrary File Write and Overwrite outside destination root
  • Exploit Status: Proof-of-Concept Publicly Available
  • Patched Version: sevenz-rust2 v0.21.1

Affected Systems

  • sevenz-rust2 Cargo package (< 0.21.1)
  • sevenz-rust2: < 0.21.1 (Fixed in: 0.21.1)

Code Analysis

Commit: ef760b6

7z files could write files outside the destination directory

@@ -137,13 +137,40 @@ fn decompress_impl<R: Read + Seek>(
         std::fs::create_dir_all(&dest)?;
     }
     seven.for_each_entries(|entry, reader| {
-        let dest_path = dest.join(entry.name());
+        let dest_path = safe_join(&dest, entry.name())?;
         extract_fn(entry, reader, &dest_path)
     })?;

     Ok(())
 }

+/// Joins an untrusted archive entry name onto `dest`, rejecting any path that would
+/// escape the destination directory (Zip-Slip / CWE-22).
+///
+/// Both `/` and `\` are treated as separators so Windows-style names are validated on
+/// every platform, and any `..`, root, or drive-prefix component causes rejection.
+#[cfg(not(target_arch = "wasm32"))]
+fn safe_join(dest: &Path, entry_name: &str) -> Result<PathBuf, Error> {
+    use std::path::Component;
+
+    // Treat backslashes as separators too, so `..\..\x` from a Windows-authored
+    // archive is caught when extracting on Unix.
+    let normalized = entry_name.replace('\\', "/");
+    let mut result = dest.to_path_buf();
+    for component in Path::new(&normalized).components() {
+        match component {
+            Component::Normal(part) => result.push(part),
+            Component::CurDir => {}
+            Component::ParentDir | Component::RootDir | Component::Prefix(_) => {
+                return Err(Error::other(format!(
+                    "unsafe entry path escapes destination: {entry_name}"
+                )));
+            }
+        }
+    }
+    Ok(result)
+}

Exploit Details

  • GitHub: Independent reproduction and proof-of-concept analysis repository for CVE-2026-61725.
  • GitHub: Upstream regression tests in tests/decompression_tests.rs demonstrating relative and absolute path traversal archive payloads.

Mitigation Strategies

  • Upgrade the sevenz-rust2 crate dependency to version 0.21.1 or later across all Cargo projects.
  • Replace calls to high-level convenience functions (decompress, decompress_file) with custom SevenZReader::for_each_entries callbacks that strictly reject Component::ParentDir, Component::RootDir, and Component::Prefix.
  • Normalize backslash characters ('\') to forward slashes ('/') prior to parsing archive entry paths to prevent cross-platform path separator bypasses.
  • Execute archive extraction tasks within least-privilege sandboxes, containers, or chroot environments with restricted filesystem write permissions.

Remediation Steps:

  1. Update Cargo.toml to specify sevenz-rust2 = ">= 0.21.1".
  2. Run 'cargo update -p sevenz-rust2' to refresh Cargo.lock with the patched version.
  3. Verify the resolved crate version using 'cargo tree -i sevenz-rust2' and run 'cargo audit'.
  4. Rebuild and redeploy all binaries and services that depend on sevenz-rust2.

References

Read the full report for CVE-2026-61725 on our website for more details including interactive diagrams and full exploit analysis.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.