# CVE-2023-35931: Shescape potential environment variable exposure on Windows with CMD


- **Severity:** Low 3.1 (`CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Fix available:** Yes
- **Published:** 23 Jun 2023
- **Updated:** 5 Dec 2024
- **Also known as:** GHSA-3g7p-8qhx-mc8r

## What is CVE-2023-35931?

CVE-2023-35931 is a low-severity vulnerability in ericcornelissen shescape, published on 23 Jun 2023. 

### Official description

Shescape is a simple shell escape library for JavaScript. An attacker may be able to get read-only access to environment variables. This bug has been patched in version 1.7.1.

Weakness: CWE-526 (Cleartext Storage of Sensitive Information in an Environment Variable)

## Which versions are affected by CVE-2023-35931?

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


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

Products: Shescape Project Shescape.

## How do I fix CVE-2023-35931?

Upgrade shescape to 1.7.1 or later.

## Is CVE-2023-35931 being exploited?

There is no known exploitation of CVE-2023-35931 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-2021-21384](https://insights.sbomify.com/CVE-2021-21384/): Null characters not escaped in shescape (medium 6.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-35931 and fix it if it is affected.

What it is: CVE-2023-35931 is a low-severity vulnerability in ericcornelissen shescape, published on 23 Jun 2023. 
Exploitation: There is no known exploitation of CVE-2023-35931 in the wild and no public exploit code.

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

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-2023-35931/ (Markdown: https://insights.sbomify.com/CVE-2023-35931/index.md)
```

## Sources

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

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