DEV Community

OnaEiuspkz
OnaEiuspkz

Posted on

sevenz-rust2 Extracted 7z Entries Without Containing Paths

sevenz-rust2 Extracted 7z Entries Without Containing Paths

A Rust library can still inherit classic archive bugs. CVE-2026-61725 affects sevenz-rust2 before 0.21.1. The advisory says the decompression path built each output as dest.join(entry.name()) without a traversal guard, allowing a crafted 7z entry to write outside the selected destination.

That pattern is familiar from Zip Slip, but the file extension changes the attack surface. Applications that accept .7z uploads, backups, artifact bundles or support archives may treat the library as a file parser and overlook the fact that extraction performs a write.

How the escape works

The advertised destination is a directory chosen by the application. An archive entry carries its own name. If the application passes a name containing parent-directory components or an absolute path into a path join and later creates the file, the resulting path can leave the destination.

The advisory says multiple built-in decompression helpers were affected, including the file and password variants. Fixing one caller does not help if another convenience function retains the vulnerable path construction. A safe API should reject an unsafe name before opening the output file and should check the final resolved path.

Archive extraction can lead to code execution through several routes. An attacker may overwrite a startup script, a library loaded by the application, a configuration file used by a privileged process or a scheduled task. The more privileges held by the extracting service, the more valuable a single file write becomes.

Remediation

Upgrade sevenz-rust2 to 0.21.1 or later. Rebuild every binary that links the library, including command-line tools and background workers. A patched dependency in one service does not protect another service that still vendors the old crate.

Add a pre-extraction validation step that rejects absolute paths, parent-directory components, empty names and platform-specific path prefixes. Resolve the final path and confirm it remains below the extraction root. Do not follow symbolic links from inside the archive. Set file and directory permissions after extraction instead of trusting archive metadata.

Run extraction in a disposable worker with a private temporary directory, no cloud credentials and a read-only base image. Keep a resource limit for the archive and the output tree. A path containment bug becomes less damaging when the worker cannot reach production secrets.

Investigation

Search artifact and upload histories for .7z files processed by affected builds. Review write activity around startup directories, shared libraries, cron entries and service configuration during the retention window. File hashes can identify known payloads, but a crafted archive may only leave an unexpected file in a trusted path.

If the extractor ran as root or as a service account with broad write access, collect process creation, file integrity and package manager logs before cleaning the host. Replacing the library closes the vulnerability. It does not prove that a previous archive was harmless.

Verification

Test the new version with entries containing .., an absolute path and a symlink that points outside the root. Confirm the operation fails before any file is created. Also test the application's own path policy, because a safe library call can still be wrapped by unsafe code.

References

Top comments (0)