CVE-2021-42740: Command Injection

Published Oct 21, 2021
·
Updated

Node.js shell-quote module could allow a remote attacker to execute arbitrary commands on the system, caused by a flaw with windows drive letter regex. By sending a specially-crafted shell metacharacters, an attacker could exploit this vulnerability to execute arbitrary commands on the system.

Other sources

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.

— GitHub

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 Software

4 affected componentsFixes available
npm/shell-quote<=1.7.2
1.7.3
Shell-quote Project Shell-quote Node.js<1.7.3
IBM Planning Analytics<=2.0
ubuntu/node-shell-quote*

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/shell-quote to a version that resolves this vulnerability.

    Fixed in 1.7.3

Event History

Oct 21, 2021
CVE Published
via MITRE·02:46 PM
Data Sourced
via MITRE·02:46 PM
Description
Data Sourced
via OSV·03:15 PM
DescriptionSeverityAffected Software
Data Sourced
03:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Oct 28, 2021
Data Sourced
via NVD·01:54 PM
RemedyDescriptionSeverityWeaknessAffected Software
Updated
via NVD·01:54 PM
Affected Software
May 24, 2022
Advisory Published
07:18 PM
Nov 29, 2023
Advisory Published
10:20 PM
Dec 21, 2023
Data Sourced
via IBM·12:00 AM
DescriptionSeverityAffected Software
Updated
via IBM·12:00 AM
Affected Software
Feb 2, 2024
Data Sourced
via GitHub·08:50 PM
DescriptionSeverityWeaknessAffected Software
Updated
via GitHub·08:50 PM
Description

Parent advisories

This vulnerability appears in the following advisories.

Frequently Asked Questions

1

What is the severity of CVE-2021-42740?

CVE-2021-42740 is classified as a high severity vulnerability due to its potential for remote code execution.

2

How do I fix CVE-2021-42740?

To fix CVE-2021-42740, update the shell-quote module to version 1.7.3 or later.

3

What systems are affected by CVE-2021-42740?

CVE-2021-42740 affects the shell-quote module for Node.js and versions up to 1.7.2.

4

Can CVE-2021-42740 be exploited remotely?

Yes, CVE-2021-42740 can be exploited by a remote attacker to execute arbitrary commands on the system.

5

What is the impact of CVE-2021-42740?

The impact of CVE-2021-42740 includes the potential for arbitrary command execution on affected systems.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203