Home/Research/Post

GHSA-xm6h-2993-3ch9: node-tar PathReservations.getDirs() quadratic memory amplification via unbounded symlink linkpath depth — uncatchable OOM process kill

  • Severity: HIGH
  • CVE: CVE-2026-140230
  • Ecosystems: npm
  • Packages: tar

### Summary

node-tar’s PathReservations.getDirs() materializes every parent-directory prefix of a given path as individual strings — an O(N²) operation. The existing maxDepth guard applies only to entry.path, not to entry.linkpath. A crafted archive with a shallow entry.path and a deeply-nested linkpath bypasses the guard entirely, forcing a catastrophic heap allocation. The resulting V8 OOM is uncatchable — try/catch, Promise .catch(), and process.on(‘uncaughtException’) all fail to intercept it. A 181-byte gzip archive is sufficient to instantly kill any Node.js process attempting extraction.

### Details

ROOT CAUSE

node-tar enforces a maxDepth=1024 segment cap on entry.path via its CHECKPATH routine. This guard is entirely absent for entry.linkpath — the target path of a symlink entry. PathReservations.reserve() unconditionally pushes entry.linkpath into its path list without any depth validation.

getDirs() then materializes every parent-directory prefix of that path as individual JavaScript strings. For a linkpath with N segments this produces N strings of average length N/2, totaling O(N²) memory. A linkpath with 10000 segments causes instant catastrophic heap exhaustion.

The GNU K (LongLink) extended-header mechanism allows a linkpath up to 1 MiB, roughly 524000 segments, which theoretically yields a ~275 GB memory allocation target.

AFFECTED CODE

src/path-reservations.ts — getDirs() function
src/path-reservations.ts — reserve() function (no depth check before pu…

Source: GitHub Security Advisories · 2026-12-02