Command Injection Vulnerability in node-shell-quote Package

node-shell-quote Updated 02 Oct 2025

Summary

21/10/2021
N/A
Yes i
Critical
9.8

CVE-2021-42740: The shell-quote package before 1.7.3 for Node.js allows command injection. Affects node-shell-quote versions < 1.7.3+~1.7.1-1. Fixed in 1.7.3+~1.7.1-1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The node-shell-quote package is a utility for quoting shell commands in Node.js applications. It is designed to ensure that command-line arguments are properly formatted to prevent issues when executing commands. However, a flaw in its regex handling for Windows drive letters exposes it to command injection vulnerabilities, allowing attackers to exploit this weakness.

Vulnerability Detail

The vulnerability, identified as CVE-2021-42740, arises from the incorrect regex character class used in the node-shell-quote package. The regex {A-z] instead of the correct {A-Za-z] allows for the inclusion of shell metacharacters that can be exploited. If the output from this package is passed to a shell command via exec(), an attacker can inject arbitrary commands, potentially leading to severe security breaches. The CVSS score for this vulnerability is 9.8, indicating a critical level of risk.

How To Fix

Minimum fixed version

1.7.3+~1.7.1-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-shell-quote

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, avoid using the node-shell-quote package for quoting shell commands until you can update to the fixed version. If you must use it, ensure that any user input is properly sanitized to prevent command injection.

Conclusion

The CVE-2021-42740 vulnerability in the node-shell-quote package poses a significant risk due to its potential for command injection. It is crucial for developers to update to the latest version to mitigate this risk and ensure the security of their applications.

See every vulnerability recorded for node-shell-quote →

Share this vulnerability

FAQ

CVE-2021-42740 is a command injection vulnerability found in the node-shell-quote package that allows attackers to inject arbitrary commands through improperly handled shell metacharacters.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

If exploited, this vulnerability can allow attackers to execute arbitrary commands on the server, potentially leading to data breaches, unauthorized access, or complete system compromise.

If an immediate update is not possible, implement input sanitization to mitigate the risk of command injection and avoid using the package until it is updated.

The CVSS score for CVE-2021-42740 is 9.8, indicating a critical level of severity.

Related vulnerabilities

Recent vulnerabilities recorded for node-shell-quote.

How To Fix

Minimum fixed version

1.7.3+~1.7.1-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-shell-quote

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback