Back to Blog
critical SEVERITY5 min read

Unpacking the Danger: Fixing node-tar's Path Traversal Vulnerability

A medium-severity path traversal vulnerability (CVE-2026-24842) has been patched in the popular `node-tar` library. This fix prevents attackers from creating arbitrary files outside the intended extraction directory by exploiting a bypass in the hardlink security check, safeguarding countless Node.js projects that rely on it.

O
By Orbis AppSec
•Technically reviewed by Anupam Mediratta•Published February 13, 2026•Reviewed June 3, 2026

Answer Summary

CVE-2026-24842 is a path traversal vulnerability in the node-tar library for Node.js, classified under CWE-22 (Improper Limitation of a Pathname to a Restricted Directory). Attackers could craft malicious tar archives with specially formatted hardlinks that bypassed the existing security checks, allowing file creation outside the intended extraction directory. The fix strengthens the hardlink validation logic to properly detect and block path traversal attempts, ensuring all extracted files remain within the designated target directory.

Vulnerability at a Glance

cweCWE-22 (Improper Limitation of a Pathname to a Restricted Directory)
fixEnhanced hardlink path validation to prevent directory escape
riskArbitrary file creation outside extraction directory
languageNode.js
root causeInsufficient validation of hardlink targets in tar archive extraction
vulnerabilityPath traversal via hardlink security bypass

A Deep Dive into node-tar's Path Traversal Vulnerability (CVE-2026-24842)

If you're a Node.js developer, you've almost certainly used the node-tar library, even if you didn't know it. As the backbone for npm and countless other tools, it's one of the most fundamental packages in the ecosystem, responsible for packing and unpacking tar archives. Recently, a medium-severity vulnerability, CVE-2026-24842, was discovered and patched in this critical library.

This vulnerability allowed for arbitrary file creation through a path traversal bypass, a classic but dangerous bug. For developers, this is a must-fix issue. Because node-tar is so deeply embedded in the Node.js toolchain, your projects are likely affected. Understanding this vulnerability is key to appreciating the fix and building more secure applications.

The Vulnerability Explained

What is Path Traversal?

Path traversal, also known as directory traversal, is a web security vulnerability that allows an attacker to read or write files outside of the directory they are supposed to have access to. Attackers exploit this by manipulating file paths with ../ sequences to "travel up" the directory tree.

In the context of node-tar, this means a specially crafted tar archive could trick the library into writing a file anywhere on the file system that the user running the extraction process has permissions for.

The Weak Link: Hardlink Security Checks

The vulnerability in node-tar was specific to how it handled hardlinks within an archive. A hardlink is a file system entry that associates a name with a file. Unlike a symbolic link, it points directly to the file's data on the disk, not to another path.

The exploitation process looked something like this:

  1. Craft a Malicious Archive: An attacker creates a .tar file.
  2. Add a Benign File: Inside the archive, they place a file, let's call it payload.txt.
  3. Create a Malicious Hardlink: They then create a hardlink within the archive. The hardlink's target is the safe, internal payload.txt, but its name is a malicious path, like ../../../../../../etc/malicious_file.
  4. Bypass the Check: The vulnerable version of node-tar would check the hardlink's target to ensure it was safe and within the extraction directory. However, it failed to properly validate the hardlink's name.

Because the check was bypassed, the library would proceed to create a hardlink at the malicious path, effectively creating a copy of payload.txt far outside the intended extraction folder.

Real-World Impact

The impact of this is significant. An attacker could:
- Overwrite critical system files: By naming the hardlink ../../etc/passwd, they could attempt to corrupt user account information.
- Achieve Remote Code Execution (RCE): By writing to a file like ~/.bashrc or a web server's configuration file, an attacker could inject malicious commands that would be executed later.
- Denial of Service: Overwriting crucial application or system files could render the system inoperable.

Imagine a web application that allows users to upload .tar files for processing. If this application uses a vulnerable version of node-tar on the backend, a malicious upload could compromise the entire server.

The Fix: Strengthening Path Validation

The fix for CVE-2026-24842 addresses the core of the problem: insufficient validation of the hardlink's path. While we don't have the exact code diff from the automated pull request, we can illustrate the logical change.

The corrected code ensures that both the hardlink's target and its own path are resolved and validated to be strictly within the confines of the destination directory.

Conceptual Code Example

Here is a simplified, conceptual example to demonstrate the flawed logic versus the patched logic.

Before (Conceptual Flawed Logic):
The code might have only checked if the file the link points to is safe.

// WARNING: Simplified, illustrative code
function createHardlink(extractionDir, linkName, linkTarget) {
  const targetPath = path.resolve(extractionDir, linkTarget);

  // The check is only on the target, not the link's name itself.
  if (!targetPath.startsWith(extractionDir)) {
    throw new Error('Invalid hardlink target!');
  }

  // This next line is dangerous! `linkName` could be malicious, e.g., "../../etc/pwned"
  const maliciousLinkPath = path.resolve(extractionDir, linkName);
  fs.linkSync(targetPath, maliciousLinkPath);
}

After (Conceptual Secure Logic):
The corrected logic validates the resolved path of the link name itself.

// WARNING: Simplified, illustrative code
function createHardlink(extractionDir, linkName, linkTarget) {
  const targetPath = path.resolve(extractionDir, linkTarget);
  const linkPath = path.resolve(extractionDir, linkName); // Resolve the link path

  // **THE FIX**: Check both the target and the link's final path
  if (!targetPath.startsWith(extractionDir) || !linkPath.startsWith(extractionDir)) {
    throw new Error('Path traversal attempt detected!');
  }

  // This is now safe, as `linkPath` has been validated
  fs.linkSync(targetPath, linkPath);
}

By adding the check for linkPath, the fix ensures that no matter what ../ sequences are in the hardlink's name, the final absolute path never leaves the intended extraction directory.

Conclusion

CVE-2026-24842 is a powerful reminder that vulnerabilities can exist in the most foundational parts of our software stack. The node-tar team acted swiftly to patch the issue, but the responsibility is on us as developers to apply these fixes.

By understanding the mechanics of path traversal, appreciating the security improvements in the patch, and adopting a proactive security posture, we can build more resilient and trustworthy applications. So, take a moment today: check your package-lock.json, run an audit, and ensure your projects are secure.

Prevention and further reading

Related Articles

medium

path-to-regexp 0.1.12 DoS: Catastrophic Backtracking on Malformed URL

path-to-regexp version 0.1.12 contains a regular expression engine vulnerability where maliciously crafted URL parameters trigger exponential backtracking, causing CPU exhaustion and service unavailability. Upgrading to version 0.1.13 eliminates the vulnerable pattern from the parsing logic.

critical

CVE-2026-59873: node-tar 7.5.11 DoS via Crafted Gzip Bomb

node-tar versions 7.5.11 through 7.5.18 are vulnerable to a denial-of-service attack through maliciously crafted gzip archives that decompress to disproportionately large sizes. An attacker can exploit this to exhaust memory and CPU resources by submitting a small, highly compressed archive that expands beyond configured limits during extraction.

high

MapManager.get() Race Condition Duplicates API Requests

The MapManager's `get(mapUid, cache)` method used a check-then-act pattern that permitted multiple concurrent requests to pass the cache miss check simultaneously, triggering redundant API calls and risking cache corruption. The fix introduces a `_pending` promise map to deduplicate in-flight fetches for identical map UIDs.

critical

Lampa Desktop Auto-Update Heuristic Bypass: Execution of Unverified

Lampa Desktop's auto-update mechanism downloaded JavaScript and CSS from `raw.githubusercontent.com` using only heuristic validation—file size thresholds and string pattern matching—that attackers could trivially satisfy. The fix introduces cryptographic integrity verification by cross-referencing Git blob hashes from the GitHub Contents API, ensuring downloaded code matches the repository's authoritative state before execution.

high

adm-zip 0.6.0 Preserves SUID Bits From ZIPs: CVE-2026-102282

The `adm-zip` dependency resolved to 0.6.0 in this project's dependency tree, a version affected by CVE-2026-102282: during extraction it applies the Unix permission bits stored in each ZIP entry's external file attributes verbatim, including the setuid (`04000`), setgid (`02000`), and sticky bits. An attacker who controls an archive passed to `extractAllTo()` or `extractEntryTo()` can therefore have the extractor create a setuid binary owned by whatever user the extraction process runs as. The

high

requestInput() Type Confusion: NaN and Object Bypass in JavaScript

The `requestInput()` utility function lacked validation on its `type` parameter and failed to handle `NaN` results from float conversions, creating a type confusion weakness. An attacker could supply malformed inputs that propagate unhandled `NaN` values or unexpected object types through the type system. The fix adds explicit guards against `NaN` type parameters and rejects non-primitive type values.