CVE-2021-42740 is a critical-severity (CVSS 9.8) CWE-77 vulnerability in shell-quote. A fix is available for shell-quote — see the affected versions and patch details below.
Improper Neutralization of Special Elements used in a Command in Shell-quote
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.
shell-quotenpmDescription
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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | shell-quote | ≥ 1.6.3&&< 1.7.3 | 1.7.3npm install shell-quote@1.7.3 |
Affected Products
shell-quoteshell-quote_projectDetection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for shell-quote, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update shell-quote to 1.7.3 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2021-42740 is resolved across your whole dependency graph.
Workarounds
Stop passing untrusted input into the interpreter or shell: call the affected binary with an argument array rather than a composed command string, reject anything outside a strict allowlist of expected values, and run the component under an account that cannot reach beyond the work it legitimately does.
Frequently Asked Questions
Is CVE-2021-42740 in your dependencies?
Find it across npm, including transitive dependencies.