/

CVE-2026-17524

Severity:

HIGH RISK

(7.5)

Directory Traversal (CWE-22) in zip-lib Extraction Logic

CVE-2026-17524

Deferred

Vulnerability type

Category:

Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write Outside Intended Directory

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 directory traversal flaw in zip-lib allows crafted archive entries to escape the intended extraction directory by abusing a cached path validation mechanism.

When attackers control ZIP contents and symlink layout, they may bypass isOutsideTargetFolder checks and cause files to be written outside the target folder, potentially overwriting sensitive paths.

A directory traversal flaw in zip-lib allows crafted archive entries to escape the intended extraction directory by abusing a cached path validation mechanism.

When attackers control ZIP contents and symlink layout, they may bypass isOutsideTargetFolder checks and cause files to be written outside the target folder, potentially overwriting sensitive paths.

Affected context

This vulnerability appears in applications that use vulnerable versions of zip-lib (before 1.1.0) to extract untrusted or user-supplied ZIP archives.

It is most relevant when:

  • The application relies on zip-lib's isOutsideTargetFolder to prevent directory traversal
  • ZIP contents can be influenced by an attacker (file uploads, plugin packages, backups, or import/export features)
  • Extraction is performed into directories that are on the same filesystem as sensitive application or system files

The issue is triggered during extraction when symlinks and nested paths are present, interacting with the caching-based path validation.

This vulnerability appears in applications that use vulnerable versions of zip-lib (before 1.1.0) to extract untrusted or user-supplied ZIP archives.

It is most relevant when:

  • The application relies on zip-lib's isOutsideTargetFolder to prevent directory traversal
  • ZIP contents can be influenced by an attacker (file uploads, plugin packages, backups, or import/export features)
  • Extraction is performed into directories that are on the same filesystem as sensitive application or system files

The issue is triggered during extraction when symlinks and nested paths are present, interacting with the caching-based path validation.

Exploit preconditions

  • Attack surface: ZIP archive extraction endpoints, file upload handlers, automated import jobs, or any service that unpacks attacker-controlled archives using zip-lib.
  • Required access: Ability to provide or influence the ZIP file being extracted (e.g., authenticated user upload, external integration, or supply-chain package).
  • Trigger point: The extraction process, especially when an archive includes symbolic links or crafted paths that are resolved after the initial path validation.
  • Why exploitation is possible: isOutsideTargetFolder performs path checks once and caches the result at the time the initial directory symlink is created, not re-validating subsequent path resolutions. This allows an attacker to design archive structures where a previously "safe" cached path later resolves outside the target directory via symlink manipulation or traversal sequences.
  • Attack surface: ZIP archive extraction endpoints, file upload handlers, automated import jobs, or any service that unpacks attacker-controlled archives using zip-lib.
  • Required access: Ability to provide or influence the ZIP file being extracted (e.g., authenticated user upload, external integration, or supply-chain package).
  • Trigger point: The extraction process, especially when an archive includes symbolic links or crafted paths that are resolved after the initial path validation.
  • Why exploitation is possible: isOutsideTargetFolder performs path checks once and caches the result at the time the initial directory symlink is created, not re-validating subsequent path resolutions. This allows an attacker to design archive structures where a previously "safe" cached path later resolves outside the target directory via symlink manipulation or traversal sequences.

Why this happens

The underlying bug is an incomplete path canonicalization and validation strategy that relies on cached decisions.

Instead of validating each file's fully resolved, final extraction path against the intended target directory, zip-lib:

  • Performs an isOutsideTargetFolder check when the initial directory (often involving a symlink) is processed
  • Caches that decision and reuses it for later extractions under the assumption that the path's safety does not change

This pattern falls under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where attacker-controlled paths (including use of symlinks and ../ components) are not consistently normalized and checked at the time files are actually written to the filesystem.

The underlying bug is an incomplete path canonicalization and validation strategy that relies on cached decisions.

Instead of validating each file's fully resolved, final extraction path against the intended target directory, zip-lib:

  • Performs an isOutsideTargetFolder check when the initial directory (often involving a symlink) is processed
  • Caches that decision and reuses it for later extractions under the assumption that the path's safety does not change

This pattern falls under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where attacker-controlled paths (including use of symlinks and ../ components) are not consistently normalized and checked at the time files are actually written to the filesystem.

Potential impact

  • Overwriting files outside the extraction directory that the application user or service account can access
  • Planting or modifying configuration files that may alter application behavior
  • Dropping web-accessible files (e.g., web shells) in server document roots, potentially leading to remote code execution in some environments
  • Corrupting application data, logs, or other files relied on for integrity and auditing
  • Escalating impact when combined with other misconfigurations (e.g., writable service scripts, cron jobs, or startup files)
  • Overwriting files outside the extraction directory that the application user or service account can access
  • Planting or modifying configuration files that may alter application behavior
  • Dropping web-accessible files (e.g., web shells) in server document roots, potentially leading to remote code execution in some environments
  • Corrupting application data, logs, or other files relied on for integrity and auditing
  • Escalating impact when combined with other misconfigurations (e.g., writable service scripts, cron jobs, or startup files)

General mitigation guidance

Effective mitigation focuses on robust path validation and reducing trust in archive contents:

  • Ensure that every extracted entry's final, canonical path is computed (resolving symlinks and .. segments) and checked against the intended base directory just before writing the file.
  • Avoid relying on cached "safe" directory checks; re-validate per entry to account for symlinks and later path changes.
  • Limit the extraction target to dedicated, isolated directories that do not contain executable code or critical configuration where possible.
  • Run archive extraction under a minimally privileged account with write access only to the intended extraction area.
  • Consider ignoring or explicitly handling symlinks in archives (e.g., refusing them, or converting them to plain files if appropriate for the application model).

Effective mitigation focuses on robust path validation and reducing trust in archive contents:

  • Ensure that every extracted entry's final, canonical path is computed (resolving symlinks and .. segments) and checked against the intended base directory just before writing the file.
  • Avoid relying on cached "safe" directory checks; re-validate per entry to account for symlinks and later path changes.
  • Limit the extraction target to dedicated, isolated directories that do not contain executable code or critical configuration where possible.
  • Run archive extraction under a minimally privileged account with write access only to the intended extraction area.
  • Consider ignoring or explicitly handling symlinks in archives (e.g., refusing them, or converting them to plain files if appropriate for the application model).

How teams detect issues like this

Detection can leverage both code-centric and behavior-centric approaches:

  • Static analysis and code review:
  • Look for uses of zip-lib's extraction APIs that rely solely on built-in directory traversal checks without additional canonical path validation.
  • Flag patterns that compute safety decisions once and then reuse cached results for multiple extracted entries.
  • Review logic that permits symlinks or complex relative paths in archives without post-resolution checks.
  • Runtime and operational monitoring:
  • Monitor extraction processes for file writes outside expected directories, especially during ZIP imports from untrusted sources.
  • Use filesystem auditing to detect unexpected modifications to configuration, executable, or web-root files during archive extraction operations.
  • Policy enforcement and tooling:
  • Include secure archive-handling policies in internal coding standards.
  • Use automated code scanning tools or custom linters to detect path traversal anti-patterns and missing canonicalization steps.

Detection can leverage both code-centric and behavior-centric approaches:

  • Static analysis and code review:
  • Look for uses of zip-lib's extraction APIs that rely solely on built-in directory traversal checks without additional canonical path validation.
  • Flag patterns that compute safety decisions once and then reuse cached results for multiple extracted entries.
  • Review logic that permits symlinks or complex relative paths in archives without post-resolution checks.
  • Runtime and operational monitoring:
  • Monitor extraction processes for file writes outside expected directories, especially during ZIP imports from untrusted sources.
  • Use filesystem auditing to detect unexpected modifications to configuration, executable, or web-root files during archive extraction operations.
  • Policy enforcement and tooling:
  • Include secure archive-handling policies in internal coding standards.
  • Use automated code scanning tools or custom linters to detect path traversal anti-patterns and missing canonicalization steps.

Sources

SourceLink
github.comgithub.com/fpsqdb/zip-lib/commit/0c29b1e17050f2611f4f37e6aaa92a60b3cb89d5
github.comgithub.com/fpsqdb/zip-lib/issues/14
security.snyk.iosecurity.snyk.io/vuln/SNYK-JS-ZIPLIB-13834403

Frequently asked

questions

It can be, depending on how the application exposes archive extraction. If a remote user can upload or otherwise supply a ZIP file that is automatically extracted by the server using zip-lib, the vulnerability is remotely exploitable.

The attacker needs the ability to influence or provide the ZIP archive being processed. This might be through an authenticated upload feature, a public file submission endpoint, or a supply-chain vector such as packaged plugins or themes.

The safest pattern is to re-validate each archive entry's final, canonical extraction path against a known safe base directory immediately before writing, without relying on cached path checks. Additionally, treat symlinks as unsafe or handle them with explicit, strict rules.

Use a defense-in-depth approach: adopt secure archive extraction libraries or patterns, enforce canonical path validation for every file operation, restrict extraction targets to non-sensitive directories under least-privilege accounts, and include file/path handling checks in code reviews and automated security testing.

It can be, depending on how the application exposes archive extraction. If a remote user can upload or otherwise supply a ZIP file that is automatically extracted by the server using zip-lib, the vulnerability is remotely exploitable.

The attacker needs the ability to influence or provide the ZIP archive being processed. This might be through an authenticated upload feature, a public file submission endpoint, or a supply-chain vector such as packaged plugins or themes.

The safest pattern is to re-validate each archive entry's final, canonical extraction path against a known safe base directory immediately before writing, without relying on cached path checks. Additionally, treat symlinks as unsafe or handle them with explicit, strict rules.

Use a defense-in-depth approach: adopt secure archive extraction libraries or patterns, enforce canonical path validation for every file operation, restrict extraction targets to non-sensitive directories under least-privilege accounts, and include file/path handling checks in code reviews and automated security testing.

Find out what's already
exploitable in your codebase.