# CVE-2021-42740: Improper Neutralization of Special Elements used in a Command in Shell-quote

- Severity: Critical 9.8 (CVSS:3.1, scored by NVD) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 4.11%, higher than 91% of CVEs (2026-12-01)
- Published: 2021-10-21T14:46:08.000Z
- Modified: 2026-09-10T03:49:38.560Z
- Also known as: GHSA-g4rg-993r-mgx7
- Weaknesses: CWE-77
- Assigned by: mitre

## Description

The shell-quote package before 1.7.3 for Node.js allows command injection. An attacker can inject unescaped shell metacharacters through a regex designed to support Windows drive letters. If the output of this package is passed to a real shell as a quoted argument to a command with exec(), an attacker can inject arbitrary commands. This is because the Windows drive letter regex character class is {A-z] instead of the correct {A-Za-z]. Several shell metacharacters exist in the space between capital letter Z and lower case letter a, such as the backtick character.

(As written by CVE List.)

## Affected

- Unspecified product: n/a
- shell-quote (npm): from 1.6.3 before 1.7.3
- shell-quote_project shell-quote: before 1.7.3

## Every score

- GitHub: CVSS:3.1 9.8 Critical `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`
- NVD: CVSS:3.1 9.8 Critical `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`
- NVD: CVSS:2.0 7.5 High `AV:N/AC:L/Au:N/C:P/I:P/A:P`

## References

- <https://www.npmjs.com/package/shell-quote> (vendor-advisory, web)
- <https://github.com/substack/node-shell-quote/blob/master/CHANGELOG.md#173> (third-party-advisory)
- <https://github.com/substack/node-shell-quote/commit/5799416ed454aa4ec9afafc895b4e31760ea1abe> (patch, third-party-advisory)
- <https://nvd.nist.gov/vuln/detail/CVE-2021-42740> (advisory)
- <https://github.com/ljharb/shell-quote/commit/5799416ed454aa4ec9afafc895b4e31760ea1abe> (web)
- <https://github.com/ljharb/shell-quote> (package)
- <https://github.com/ljharb/shell-quote/blob/master/CHANGELOG.md#173> (web)

## Sources

- CVE List: [CVE-2021-42740](https://www.cve.org/CVERecord?id=CVE-2021-42740), CVE Terms of Use, modified 2024-08-04
- GitHub Advisory Database: [GHSA-g4rg-993r-mgx7](https://github.com/advisories/GHSA-g4rg-993r-mgx7), CC-BY-4.0, modified 2026-09-10
- NVD: [CVE-2021-42740](https://nvd.nist.gov/vuln/detail/CVE-2021-42740), Public domain, modified 2026-06-17

---

Page: https://cve.day/CVE-2021-42740 · Whole record: https://cve.day/CVE-2021-42740.json · Rebuilt by cve.day 2026-11-25T22:58:04.714Z
