Find, fix and prevent vulnerabilities in your code.
high severity
new
- Vulnerable module: tar-fs
- Introduced through: puppeteer@13.7.0
Detailed paths
-
Introduced through: extract-css-core@bartveneman/extract-css-core#4a85a18a33b2e9e64550c15a92d3a5dfad6ff324 › puppeteer@13.7.0 › tar-fs@2.1.1Remediation: Upgrade to puppeteer@18.2.0.
Overview
tar-fs is a filesystem bindings for tar-stream.
Affected versions of this package are vulnerable to Improper Link Resolution Before File Access ('Link Following') through the exports.extract
function. An attacker can manipulate the path of extracted files to write outside the intended directory by crafting a malicious tarball.
Workaround
This vulnerability can be mitigated by using the ignore option to ignore paths like symlinks that are not files/directories.
ignore (_, header) {
// pass files & directories, ignore e.g. symlinks
return header.type !== 'file' && header.type !== 'directory'
}
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-fs
to version 1.16.5, 2.1.3, 3.0.9 or higher.
References
high severity
- Vulnerable module: tar-fs
- Introduced through: puppeteer@13.7.0
Detailed paths
-
Introduced through: extract-css-core@bartveneman/extract-css-core#4a85a18a33b2e9e64550c15a92d3a5dfad6ff324 › puppeteer@13.7.0 › tar-fs@2.1.1Remediation: Upgrade to puppeteer@18.2.0.
Overview
tar-fs is a filesystem bindings for tar-stream.
Affected versions of this package are vulnerable to Symlink Attack via the extraction process of a maliciously crafted tar file. An attacker can overwrite or write unauthorized files outside the intended directory by exploiting the path traversal and link following vulnerabilities.
Remediation
Upgrade tar-fs
to version 1.16.4, 2.1.2, 3.0.7 or higher.
References
high severity
- Vulnerable module: ws
- Introduced through: puppeteer@13.7.0
Detailed paths
-
Introduced through: extract-css-core@bartveneman/extract-css-core#4a85a18a33b2e9e64550c15a92d3a5dfad6ff324 › puppeteer@13.7.0 › ws@8.5.0Remediation: Upgrade to puppeteer@18.2.0.
Overview
ws is a simple to use websocket client, server and console for node.js.
Affected versions of this package are vulnerable to Denial of Service (DoS) when the number of received headers exceed the server.maxHeadersCount
or request.maxHeadersCount
threshold.
Workaround
This issue can be mitigating by following these steps:
Reduce the maximum allowed length of the request headers using the
--max-http-header-size=size
and/or themaxHeaderSize
options so that no more headers than theserver.maxHeadersCount
limit can be sent.Set
server.maxHeadersCount
to 0 so that no limit is applied.
PoC
const http = require('http');
const WebSocket = require('ws');
const server = http.createServer();
const wss = new WebSocket.Server({ server });
server.listen(function () {
const chars = "!#$%&'*+-.0123456789abcdefghijklmnopqrstuvwxyz^_`|~".split('');
const headers = {};
let count = 0;
for (let i = 0; i < chars.length; i++) {
if (count === 2000) break;
for (let j = 0; j < chars.length; j++) {
const key = chars[i] + chars[j];
headers[key] = 'x';
if (++count === 2000) break;
}
}
headers.Connection = 'Upgrade';
headers.Upgrade = 'websocket';
headers['Sec-WebSocket-Key'] = 'dGhlIHNhbXBsZSBub25jZQ==';
headers['Sec-WebSocket-Version'] = '13';
const request = http.request({
headers: headers,
host: '127.0.0.1',
port: server.address().port
});
request.end();
});
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 ws
to version 5.2.4, 6.2.3, 7.5.10, 8.17.1 or higher.
References
medium severity
- Vulnerable module: inflight
- Introduced through: puppeteer@13.7.0
Detailed paths
-
Introduced through: extract-css-core@bartveneman/extract-css-core#4a85a18a33b2e9e64550c15a92d3a5dfad6ff324 › puppeteer@13.7.0 › rimraf@3.0.2 › 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
.