CVE-2021-21384: Shescape null character escape bypass in shell quoting

CVE-2021-21384 · Severity: low · CVSS 3.1 · Published 2021-03-18

Shescape is a JavaScript library used to defend applications against shell injection attacks by safely escaping user input. A flaw in the library fails to escape null characters, allowing attackers to bypass its protection mechanism and execute arbitrary shell commands if they can inject null bytes into input.

Technologies: shescape (npm). Vendors: npm.

Quick answers

Is CVE-2021-21384 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2021-21384 being exploited in the wild.
How severe is CVE-2021-21384?
Low severity, with a CVSS score of 3.1, published 18 March 2021.
Which products and versions are affected?
shescape (npm) SEMVER:introduced=0,fixed=1.1.3.
Is there a fix for CVE-2021-21384?
Yes. shescape (npm): upgrade to 1.1.3 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2021-21384 attacked?
It is attacked with local access, in a software library.
Am I affected by CVE-2021-21384?
Check whether you run shescape (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • shescape (npm): upgrade to 1.1.3 or later
    npm install shescape@1.1.3

Technical details

The vulnerability is an incomplete input sanitization flaw in Shescape's quote() function (CWE-88). The library failed to escape null characters (\x00) in shell command arguments, allowing them to pass through to the shell unfiltered. An attacker who can control user input can inject a null byte followed by arbitrary shell commands. The vulnerability affects all versions prior to 1.1.3, is network-reachable if the application processes untrusted input, and allows command execution depending on application context and shell behavior. The patch in v1.1.3 properly escapes null characters.

Affected products

  • Eric Cornelissen Shescape < 1.1.3

Identifiers

  • CVE-2021-21384
  • GHSA-f2rp-38vg-j3gh

Timeline

  • 2021-03-13: disclosed
  • 2021-03-18: patched: v1.1.3 released

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.