Insufficient escaping of whitespace in shescape
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- None
- Attack complexity
- Low
- Impact type
- —
- Confidentiality · integrity · availability
- High · High · High
- Fix status
- Fixed
Attack profile from CVSS 3.1 · CNA. Fix status from CNA and GitHub.
Summary
Shescape is a simple shell escape package for JavaScript. Affected versions were found to have insufficient escaping of white space when interpolating output. This issue only impacts users that use the `escape` or `escapeAll` functions with the `interpolation` option set to `true`. The result is that if an attacker is able to include whitespace in their input they can: 1. Invoke shell-specific behaviour through shell-specific special characters inserted directly after whitespace. 2. Invoke shell-specific behaviour through shell-specific special characters inserted or appearing after line terminating characters. 3. Invoke arbitrary commands by inserting a line feed character. 4. Invoke arbitrary commands by inserting a carriage return character. Behaviour number 1 has been patched in [v1.5.7] which you can upgrade to now. No further changes are required. Behaviour number 2, 3, and 4 have been patched in [v1.5.8] which you can upgrade to now. No further changes are required. The best workaround is to avoid having to use the `interpolation: true` option - in most cases using an alternative is possible, see [the recipes](https://github.com/ericcornelissen/shescape#recipes) for recommendations. Alternatively, users may strip all whitespace from user input. Note that this is error prone, for example: for PowerShell this requires stripping `'\u0085'` which is not included in JavaScript's definition of `\s` for Regular Expressions.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- Poc
- Automatable
- Yes
- Technical impact
- Total
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| ericcornelissen | shescape | >=1.4.0 < 1.5.8 | — | No fix listed | CNA |
| — | shescape (npm) | 1.4.0 to before 1.5.8 | 1.5.8 | Patch available | GHSA-44vr-rwwj-p88h |
- shescape Vendorericcornelissen Affected >=1.4.0 < 1.5.8 Fixed in — No fix listed CNA
- shescape (npm) Vendor— Affected 1.4.0 to before 1.5.8 Fixed in 1.5.8 Patch available GHSA-44vr-rwwj-p88h
CPE configurations NVD · 1
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:shescape_project:shescape:*:*:*:*:*:*:*:* | 1.4.0 to before 1.5.8 | Vulnerable | ericcornelissen |
- cpe:2.3:a:shescape_project:shescape:*:*:*:*:*:*:*:* Versions 1.4.0 to before 1.5.8 Vulnerable ·ericcornelissen
Remediation
- Fix · GHSA-44vr-rwwj-p88h shescape (npm) Fixed in 1.5.8 Advisory →
Timeline
- 2026-10-02 Threatist record created from CVE-2022-31180
- 2026-10-03 Alias added: GHSA-44vr-rwwj-p88h
References
Patch 2
Advisory 3
More ericcornelissen Shescape vulnerabilities
- TI-2022-13219 Insufficient escaping of line feeds for CMD in shescape CVSS 3.1CRITICAL 9.8
- TI-2022-09469 Regular expression denial of service (ReDoS) in shescape CVSS 3.1HIGH 7.5
- TI-2026-24632 Shescape escape() leaves bracket glob expansion active on Bash, BusyBox, and Dash CVSS 4.0MEDIUM 6.9
- TI-2022-16487 Shescape Inefficient Regular Expression Complexity vulnerability CVSS 3.1HIGH 7.5
- TI-2022-08540 Exposure of home directory through shescape on Unix with Bash CVSS 3.1MEDIUM 6.2
- TI-2023-21058 Shescape on Windows escaping may be bypassed in threaded context CVSS 3.1HIGH 8.6
Sources
- CVE-2022-31180 · CVE Program
- CVE-2022-31180 · NVD
- FIRST EPSS
- GHSA-44vr-rwwj-p88h · GitHub Advisory Database · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences