# CVE-2025-24959: Environment Variable Injection for dotenv API in zx

> Attackers can inject environment variables via dotenv.stringify in zx, leading to arbitrary command execution in dependent applications.

- **Severity:** Low 1.0 (`CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:A/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 3 Feb 2025
- **Updated:** 12 Feb 2025
- **Also known as:** GHSA-qwp8-x4ff-5h87, UBUNTU-CVE-2025-24959

## What is CVE-2025-24959?

CVE-2025-24959 is a low-severity code injection vulnerability in google zx, published on 3 Feb 2025. 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

zx is a tool for writing better scripts. An attacker with control over environment variable values can inject unintended environment variables into `process.env`. This can lead to arbitrary command execution or unexpected behavior in applications that rely on environment variables for security-sensitive operations. Applications that process untrusted input and pass it through `dotenv.stringify` are particularly vulnerable. This issue has been patched in version 8.3.2. Users should immediately upgrade to this version to mitigate the vulnerability. If upgrading is not feasible, users can mitigate the vulnerability by sanitizing user-controlled environment variable values before passing them to `dotenv.stringify`. Specifically, avoid using `"`, `'`, and backticks in values, or enforce strict validation of environment variables before usage.

Weakness: CWE-94 (Improper Control of Generation of Code)

## Which versions are affected by CVE-2025-24959?

2 open source packages ship an affected version, including zx.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `zx` | npm | From 8.3.1 | 8.3.2 |
| `zx` | npm | From 8.3.1 | 8.3.2 |

## How do I fix CVE-2025-24959?

Upgrade zx to 8.3.2 or later.

## Is CVE-2025-24959 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-24959 and fix it if it is affected.

What it is: CVE-2025-24959 is a low-severity code injection vulnerability in google zx, published on 3 Feb 2025. 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-2025-24959 in the wild and no public exploit code.

Affected packages and fixed versions:
- zx (npm): affected from 8.3.1; fixed in 8.3.2
- zx (npm): affected from 8.3.1; fixed in 8.3.2

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

## Sources

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

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