# CVE-2021-21384: Null characters not escaped in shescape

> Attackers can execute arbitrary shell commands by injecting null characters into payloads processed by the shescape library.

- **Severity:** Medium 6.3 (`CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 18 Mar 2021
- **Updated:** 3 Aug 2024
- **Also known as:** GHSA-f2rp-38vg-j3gh

## What is CVE-2021-21384?

CVE-2021-21384 is a medium-severity command injection vulnerability in ericcornelissen shescape, published on 18 Mar 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

shescape is a simple shell escape package for JavaScript. In shescape before version 1.1.3, anyone using _Shescape_ to defend against shell injection may still be vulnerable against shell injection if the attacker manages to insert a into the payload. For an example see the referenced GitHub Security Advisory. The problem has been patched in version 1.1.3. No further changes are required.

Weakness: CWE-88 (Improper Neutralization of Argument Delimiters in a Command)

## Which versions are affected by CVE-2021-21384?

2 open source packages ship an affected version, including shescape. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `shescape` | npm | All versions | 1.1.3 |
| `shescape` | npm | All versions | 1.1.3 |

Products: Shescape Project Shescape.

## How do I fix CVE-2021-21384?

Upgrade shescape to 1.1.3 or later.

## Is CVE-2021-21384 being exploited?

There is no known exploitation of CVE-2021-21384 in the wild and no public exploit code.

## Other vulnerabilities in ericcornelissen shescape

- [CVE-2022-31180](https://insights.sbomify.com/CVE-2022-31180/): Insufficient escaping of whitespace in shescape (critical 9.8)
- [CVE-2022-31179](https://insights.sbomify.com/CVE-2022-31179/): Insufficient escaping of line feeds for CMD in shescape (high 8.1)
- [CVE-2026-32094](https://insights.sbomify.com/CVE-2026-32094/): Shescape escape() leaves bracket glob expansion active on Bash, BusyBox, and Dash (medium 6.9)
- [CVE-2023-40185](https://insights.sbomify.com/CVE-2023-40185/): Shescape on Windows escaping may be bypassed in threaded context (medium 6.5)
- [CVE-2022-24725](https://insights.sbomify.com/CVE-2022-24725/): Exposure of home directory through shescape on Unix with Bash (medium 6.2)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-21384 and fix it if it is affected.

What it is: CVE-2021-21384 is a medium-severity command injection vulnerability in ericcornelissen shescape, published on 18 Mar 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2021-21384 in the wild and no public exploit code.

Affected packages and fixed versions:
- shescape (npm): affected all versions; fixed in 1.1.3
- shescape (npm): affected all versions; fixed in 1.1.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-21384/ (Markdown: https://insights.sbomify.com/CVE-2021-21384/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-21384
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-21384
- OSV: https://osv.dev/vulnerability/CVE-2021-21384

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-21384/
Summaries are generated and may contain mistakes; the official description above is the record.
