Critical

Shescape vulnerable to insufficient escaping of whitespace

  • Disclosed: 15.07.2022
  • Updated: 11.10.2026 10:22

Impact

This only impacts users that use the escape or escapeAll functions with the interpolation option set to true. Example:

js
import cp from "node:child_process";
import * as shescape from "shescape";

// 1. Prerequisites
const options = {
  shell: "bash",
  // Or
  shell: "dash",
  // Or
  shell: "powershell.exe",
  // Or
  shell: "zsh",
  // Or
  shell: undefined, // Only if the default shell is one of the affected shells.
};

// 2. Attack (one of multiple)
const payload = "foo #bar";

// 3. Usage
let escapedPayload;
shescape.escape(payload, { interpolation: true });
// Or
shescape.escapeAll(payload, { interpolation: true });

cp.execSync(`echo Hello ${escapedPayload}!`, options);
// _Output depends on the shell being used_

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.
    • Affected shells: Bash, Dash, Zsh, PowerShell
  2. Invoke shell-specific behaviour through shell-specific special characters inserted or appearing after line terminating characters.
    • Affected shells: Bash
  3. Invoke arbitrary commands by inserting a line feed character.
    • Affected Shells: Bash, Dash, Zsh, PowerShell
  4. Invoke arbitrary commands by inserting a carriage return character.
    • Affected Shells: PowerShell

Patches

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.

Workarounds

The best workaround is to avoid having to use the interpolation: true option - in most cases using an alternative is possible, see the recipes for recommendations.

Alternatively, you can 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.

References

For more information

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
npm package shescape >= 1.4.0, < 1.5.8 1.5.8

References

CVSS score 9.8/10
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Weakness (CWE)
CWE-74
Platform
npm
Package
shescape
Disclosed
15.07.2022
Updated
11.10.2026 10:22

Sources and licenses

OSV / GitHub Advisory Database - GHSA-44vr-rwwj-p88h - CC BY 4.0

Vulnerability history: shescape

All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (13) in the archive
Total entries
13
First → latest
03.2021 07.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • Critical 2
  • High 5
  • Medium 4
  • Low 2

Disclosures per year

  1. 2021: 1
  2. 2022: 4
  3. 2023: 2
  4. 2024: 0
  5. 2025: 1
  6. 2026: 5
Severity:
  1. High CVE-2026-73413 >= 2.1.11, < 2.1.14, >= 3.0.0, < 3.0.1 2.1.14, 3.0.1
  2. Critical CVE-2026-73414 < 2.1.14, >= 3.0.0, < 3.0.1 2.1.14, 3.0.1
  3. High · 8.6 CVE-2023-40185 < 1.7.4 1.7.4
  4. High · 7.5 CVE-2022-25918 >= 1.5.10, < 1.6.1 1.6.1
  5. Shescape vulnerable to insufficient escaping of whitespace this entry
    Critical · 9.8 CVE-2022-31180 >= 1.4.0, < 1.5.8 1.5.8
  6. High · 6.3 CVE-2021-21384 < 1.1.3 1.1.3

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.