/

CVE-2026-85396

Severity:

HIGH RISK

(7.5)

Path Traversal (CWE-22) in rubyzip ZIP Extraction Bug

CVE-2026-85396

Awaiting Analysis

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal vulnerability in rubyzip allows crafted archive entries to escape the intended extraction directory and write files into nearby filesystem locations.

The issue becomes risky when an application extracts attacker-controlled ZIP archives and relies on an incomplete destination-prefix check.

Affected context

The vulnerability occurs in rubyzip extraction workflows that use Zip::Entry#extract and process archive entry names without fully validating their canonical destination paths. It may affect applications that extract archives supplied by untrusted users or external services, particularly when the extraction directory has writable sibling paths sharing the same textual prefix.

Exploit preconditions

  • Attack surface: ZIP archive extraction through Zip::Entry#extract
  • Required access: Ability to provide or influence an archive processed by the application
  • Trigger point: Extraction of an archive entry containing traversal-oriented path components
  • Why exploitation is possible: Destination validation relies on prefix comparison without requiring a trailing path separator, allowing paths outside the intended directory to appear valid when they share its textual prefix

Why this happens

The underlying bug is insufficient canonical path validation, mapping to CWE-22: Improper Limitation of a Pathname to a Restricted Directory.

A simple string-prefix comparison does not establish that a resolved target remains within the intended extraction directory. Without canonicalization and boundary-aware comparison, an entry can reference a sibling location whose name begins with the destination directory's prefix.

Potential impact

  • An attacker may write or overwrite files outside the intended extraction directory
  • Application configuration or executable files could be modified
  • Extracted content could be placed in sibling upload or backup directories
  • The application or other users may consume attacker-controlled files
  • Local privilege escalation or broader compromise could occur if sensitive writable paths are affected

General mitigation guidance

Mitigation generally focuses on enforcing a real filesystem containment boundary during archive extraction.

Common defensive patterns include:

  • Canonicalizing the extraction root and candidate destination before comparison
  • Requiring a path-separator boundary rather than accepting a textual prefix match
  • Rejecting absolute paths, traversal components, and entries that resolve outside the extraction root
  • Using extraction APIs or libraries that provide safe path handling by default
  • Extracting into isolated, least-privileged directories with minimal write permissions
  • Applying resource limits and treating archive contents as untrusted input
  • Avoiding execution or automatic processing of newly extracted files

How teams detect issues like this

Organizations can detect this class of issue through:

  • Static analysis rules identifying prefix-only path containment checks
  • Code review searches for archive extraction without canonicalization or separator-aware validation
  • Tests using traversal components, absolute paths, encoded separators, and sibling directories with shared prefixes
  • Runtime monitoring for file creation outside approved extraction roots
  • Policy enforcement requiring approved safe-extraction helpers for archive handling

Automated security review tools may help identify unsafe path construction and archive-processing patterns, but focused behavioral tests remain important.

Sources

SourceLink
github.comgithub.com/geo-chen/oss/blob/main/rubyzip.md
github.comgithub.com/rubyzip/rubyzip
github.comgithub.com/rubyzip/rubyzip/blob/v3.3.1/lib/zip/entry.rb
github.comgithub.com/rubyzip/rubyzip/commit/17edfbf4423b83211b075acc23a7d8640da63449
github.comgithub.com/rubyzip/rubyzip/releases/tag/v3.4.0
vulncheck.comvulncheck.com/advisories/rubyzip-before-3.4.0-path-traversal-in-zip-entry-extract-via-sibling-directory-prefix

Frequently asked

questions

It can be remotely exploitable when a network-facing application accepts attacker-controlled ZIP archives and extracts them without additional trust checks.

The attacker generally needs the ability to supply or modify an archive that reaches the vulnerable extraction workflow. The required access depends on the application's upload and processing controls.

Resolve candidate extraction paths canonically and verify that they remain within the intended root using a boundary-aware containment check before writing any file.

Treat archive entries as untrusted, use safe extraction primitives, test hostile path forms, and run extraction with least-privilege filesystem permissions.

Find out what's already
exploitable in your codebase.