CVE-2023-35931
3.1low
Shescape potential environment variable exposure on Windows with CMD
- Severity
- 3.1low CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.74% (higher than 51% of CVEs)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-3g7p-8qhx-mc8r
Description
Shescape is a simple shell escape library for JavaScript. An attacker may be able to get read-only access to environment variables. This bug has been patched in version 1.7.1.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| ericcornelissen shescape | < 1.7.1 | CVE List |
| shescape (npm) | before 1.7.1 | GitHub Advisory Database |
| shescape_project shescape | before 1.7.1 | NVD |
All scores
| GitHub_M | 3.1low CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:N |
| GitHub | 3.1low CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:N |
| NVD | 4.3medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
Shescape is a simple shell escape library for JavaScript. An attacker may be able to get read-only access to environment variables. This bug has been patched in version 1.7.1.
GitHub Advisory Database
Impact
This impact users of Shescape:
- On Windows using the Windows Command Prompt (i.e.
cmd.exe), and - Using
quote/quoteAllorescape/escapeAllwith theinterpolationoption set totrue.
An attacker may be able to get read-only access to environment variables. Example:
import * as cp from "node:child_process";
import * as shescape from "shescape";
// 1. Prerequisites
const options = {
shell: "cmd.exe",
// Or
shell: undefined, // Only if the default shell is CMD
// And
interpolation: true, // Only applies to `escape` and `escapeAll` usage
}
// 2. Attack (one of many)
const payload = "%PATH%";
// 3. Usage
let escapedPayload;
escapedPayload = shescape.quote(payload, options);
// Or
escapedPayload = shescape.quoteAll([payload], options);
// Or
escapedPayload = shescape.escape(payload, options);
// Or
escapedPayload = shescape.escapeAll([payload], options);
// And (example)
const result = cp.execSync(`echo Hello ${escapedPayload}`, options);
// 4. Impact
console.log(result.toString());
// Outputs "Hello" followed by the contents of the PATH environment variable
Patches
This bug has been patched in v1.7.1 which you can upgrade to now. No further changes are required.
Workarounds
Alternatively, users can remove all instances of % from user input, either before or after using Shescape.
References
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2023-35931 changed 2024-12-05 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-3g7p-8qhx-mc8r changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2023-35931 changed 2026-06-17 | Public domain |