Home/Research/Post

GHSA-ph3c-p786-j4rp: node-tar: Non-finite PAX size (Infinity) bypasses validation, causing extraction entry loss and an uncaught exception when re-packing

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

## Summary

`tar` (node-tar) does not validate that a numeric `size` value supplied through a PAX extended header (typeflag `x`) is finite before it is applied to the following archive entry. A PAX record such as `17 size=Infinity\n` is coerced to the JavaScript number `Infinity` and accepted, because the only guard on the value is a `>= 0` check and `Infinity >= 0` is true. The non-finite size then propagates into the entry-body state machine and, when the entry is re-packed, into numeric header encoding. Any process that parses, extracts, lists, or re-packs an attacker-supplied archive is affected; no authentication or non-default configuration is required.

## Root Cause

The PAX key/value parser assigns the `size` field after a check that was designed only to reject negative values. It never checks that the coerced number is finite or a safe integer, so `Infinity` (and other non-finite positive values) pass.

“`typescript
// src/pax.ts (parseKVLine)
case ‘size’:
const s = +v // +”Infinity” === Infinity
if (s >= 0) set[k] = s // Infinity >= 0 is true, so size is set to Infinity
break
“`

The `>= 0` guard was added to reject negative sizes. It does not enforce finiteness. The secondary guard `notNegative()` in `src/header.ts` has the same gap: `Infinity < 0` is false, so it returns `Infinity` unchanged. As a result the entry’s `size` becomes `Infinity` and reaches two distinct sinks: the parser body-length state machine and the numeric header encoder used during re-pac…

Source: GitHub Security Advisories · 2026-12-02