Skip to content
Heist/ feed
Back to feed
Critical

Security advisory

Type: advisorySources: OSVCVE: CVE-2021-42740

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2021-42740
Confirmed fixed CVEs
Not specified
Updated in this feed
1 Nov 2026, 06:40 UTC · Revision 1

Source evidence

CVE-2021-42740

core-osv · Original source

Published 21 Oct 2021, 15:15 UTC

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.

osv:CVE-2021-42740
Complete source record
{
  "id": "54e6e1e825026f9492be4830b134e7e7061554e52054c5ef35e34e4eba8cdf7c",
  "url": "https://osv.dev/vulnerability/CVE-2021-42740",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "CVE-2021-42740",
    "summary": "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.",
    "evidence": "osv:CVE-2021-42740",
    "products": [],
    "severity": "critical",
    "structured": {
      "id": "CVE-2021-42740",
      "aliases": [
        "CVE-2021-42740",
        "GHSA-g4rg-993r-mgx7"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/ljharb/shell-quote",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "6a8a899c62a58a30fb128a7079f02826ed4faee0"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:shell-quote_project:shell-quote:*:*:*:*:*:node.js:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "1.7.3"
                      }
                    ],
                    "source": "CPE_RANGE"
                  }
                ]
              }
            }
          ],
          "versions": [
            "v1.7.2",
            "v1.7.1",
            "v1.7.0",
            "v1.6.3",
            "v1.6.2",
            "v1.6.1",
            "v1.6.0",
            "v1.5.0",
            "v1.4.3",
            "v1.4.2",
            "v1.4.1",
            "v1.4.0",
            "v1.3.3",
            "v1.3.2",
            "v1.3.1",
            "v1.3.0",
            "v1.2.0",
            "v1.1.0",
            "v1.0.0",
            "v0.1.1",
            "v0.1.0",
            "v0.0.1",
            "v0.0.0"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2021-42740.json"
          }
        }
      ],
      "modified": "2026-10-24T10:30:42.832450286Z",
      "provider": "osv",
      "references": [
        "https://github.com/substack/node-shell-quote/blob/master/CHANGELOG.md#173",
        "https://www.npmjs.com/package/shell-quote",
        "https://github.com/substack/node-shell-quote/commit/5799416ed454aa4ec9afafc895b4e31760ea1abe"
      ],
      "provider_metadata": {}
    },
    "related_cves": [
      {
        "value": "CVE-2021-42740",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 435483,
  "published_at": "2021-10-21T15:15:07.633+00:00"
}