/

CVE-2026-26960

Severity:

HIGH RISK

(7.1)

Path Traversal in node-tar Extraction Defaults

CVE-2026-26960

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read and Write

Severity:

HIGH RISK

(7.1)

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

node-tar versions 7.5.7 and below allow attacker-controlled tar archives to create hardlinks that point to files outside the intended extraction directory.

When extracted with default options, this can bypass path protections and give an attacker arbitrary file read and write capabilities as the extracting user.

Affected context

This vulnerability affects applications and tools that:

  • Use node-tar (≤ 7.5.7) to extract untrusted or semi-trusted tar archives
  • Rely on node-tar's default extraction options for safety
  • Run the extraction as a user account with access to sensitive files on the same filesystem

The problem manifests when an archive contains hardlink entries that, once materialized in the extraction directory, reference files located outside the extraction root. Environments that process archives from external users, CI/CD pipelines, package managers, or automated importers are particularly exposed.

Exploit preconditions

  • Attack surface: Any service, CLI, or background job that extracts attacker-supplied tar archives using node-tar with default options.
  • Required access: Ability to provide or influence the tar file being extracted (e.g., file upload, package submission, repository contribution).
  • Trigger point: Invoking node-tar extraction on the crafted archive without additional path or link sanitization.
  • Why exploitation is possible: node-tar's default handling of hardlink entries allows creation of links inside the extraction directory that resolve to files outside the extraction root, effectively bypassing path normalization and traversal defenses.

Why this happens

The core issue is insufficient validation of file targets when processing hardlink entries during tar extraction.

While typical path traversal protections focus on relative paths (e.g., ../ segments), hardlinks can reference files elsewhere on the filesystem via inodes, not just string paths. In vulnerable versions, node-tar allows a hardlink to be created in the extraction tree that points to a target outside the intended root, thereby violating directory confinement assumptions.

This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') because the library fails to effectively constrain filesystem operations to the extraction root when interpreting archive metadata.

Potential impact

  • An attacker may read sensitive files accessible to the extracting user (configuration files, API keys, SSH keys, environment files).
  • An attacker may overwrite or corrupt files outside the extraction directory, potentially altering application behavior or configurations.
  • An attacker could plant or modify scripts and binaries that the system later executes, enabling privilege escalation or code execution in follow-up steps.
  • An attacker can use archive extraction as a generalized filesystem access primitive within the permissions of the extracting process.

General mitigation guidance

Mitigation focuses on strictly constraining where archive contents can land and how link entries are handled:

  • Treat all archives from external sources as untrusted and avoid relying solely on default extraction behaviors for safety.
  • Enforce a strict extraction root policy that rejects or neutralizes files and links resolving outside the designated directory, including hardlinks and symlinks.
  • Consider disabling the creation of hardlinks and symbolic links during extraction, or mapping them to regular files where appropriate.
  • Run extraction under a least-privilege account with minimal access to sensitive parts of the filesystem, isolating temporary extraction locations from critical data.
  • Introduce additional validation layers around archive processing (e.g., pre-scan entries, apply allowlists for paths and file types) rather than trusting library defaults.

How teams detect issues like this

Effective detection combines code-level inspection with operational monitoring:

  • Static analysis / code review:
  • Identify uses of node-tar that extract archives originating from user input or external sources.
  • Look for extraction calls that rely on defaults without explicit options for link handling, path normalization, or root confinement.
  • Flag patterns where extraction paths are assumed to be safe solely because a library is "tar-aware," without additional checks.
  • Security testing:
  • Incorporate crafted archives with hardlink and symlink entries into test suites and CI pipelines to validate extraction behavior.
  • Perform fuzzing or property-based testing around archive extraction to reveal unexpected file placement.
  • Runtime and policy enforcement:
  • Use filesystem monitoring (e.g., audit logs, container security tools) to detect archive extraction processes writing or linking files outside their designated directories.
  • Apply sandboxing or containerization policies that restrict filesystem access for archive-handling components, and alert on violations.

Sources

SourceLink
github.comgithub.com/isaacs/node-tar/commit/2cb1120bcefe28d7ecc719b41441ade59c52e384
github.comgithub.com/isaacs/node-tar/commit/d18e4e1f846f4ddddc153b0f536a19c050e7499f
github.comgithub.com/isaacs/node-tar/security/advisories/GHSA-83g3-92jg-28cx

Frequently asked

questions

Yes, if a system exposes a network-accessible feature (such as an upload endpoint, package ingestion service, or API) that accepts tar archives and extracts them using node-tar with default options. In such setups, an attacker can provide a crafted archive remotely.

The attacker needs the ability to supply or influence the tar archive being extracted. They do not need local shell access; control over the archive contents is sufficient, as long as the extraction is performed under a user with access to the target files.

The safest pattern is to enforce strict confinement of extraction to a dedicated directory, combined with rejecting or neutralizing any archive entries (including hardlinks and symlinks) that resolve outside that directory. Complement this with least-privilege execution for the extraction process.

Apply a defense-in-depth approach to archive handling: assume library defaults may not cover all edge cases, explicitly validate and normalize paths, disable or strictly control link handling, isolate extraction into constrained environments, and include malicious archive cases in automated testing and security reviews.

Find out what's already
exploitable in your codebase.