# CVE-2021-41116: Command injection in composer on Windows

> Windows users installing untrusted dependencies via Composer are vulnerable to command injection, allowing attackers to execute arbitrary code.

- **Severity:** High 8.2 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 5 Oct 2021
- **Updated:** 4 Aug 2024
- **Also known as:** BIT-composer-2021-41116, CLEANSTART-2024-SA12234, GHSA-frqg-7g38-6gcf, UBUNTU-CVE-2021-41116, openSUSE-SU-2024:11617-1, openSUSE-SU-2024:11874-1

## What is CVE-2021-41116?

CVE-2021-41116 is a high-severity command injection vulnerability in composer, published on 5 Oct 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

Composer is an open source dependency manager for the PHP language. In affected versions windows users running Composer to install untrusted dependencies are subject to command injection and should upgrade their composer version. Other OSs and WSL are not affected. The issue has been resolved in composer versions 1.10.23 and 2.1.9. There are no workarounds for this issue.

Weakness: CWE-77 (Improper Neutralization of Special Elements used in a Command)

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

5 open source packages ship an affected version, including composer/composer and composer. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `composer/composer` | Packagist | All versions | 1.10.23 |
| `composer/composer` | Packagist | All versions | 1.10.23 |
| `composer/composer` | Packagist | From 2.0.0-alpha1 | 2.1.9 |
| `composer/composer` | Packagist | From 2.0.0-alpha1 | 2.1.9 |
| `composer` | Bitnami | All versions | 1.10.23, 2.1.9 |
| `php-composer` | openSUSE:Tumbleweed | All versions | 1.10.25-1.1 |
| `php-composer2` | openSUSE:Tumbleweed | All versions | 2.1.12-1.1 |

Products: Getcomposer Composer, Tenable Tenable.sc.

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

Upgrade composer/composer to a fixed version for your release line: 1.10.23 or 2.1.9.

## Is CVE-2021-41116 being exploited?

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

## Other vulnerabilities in composer

- [CVE-2026-40261](https://insights.sbomify.com/CVE-2026-40261/): Composer has Command Injection via Malicious Perforce Reference (high 8.8)
- [CVE-2024-24821](https://insights.sbomify.com/CVE-2024-24821/): Code execution and possible privilege escalation via compromised InstalledVersions.php or installed.php in Composer (high 8.8)
- [CVE-2015-8371](https://insights.sbomify.com/CVE-2015-8371/): Composer allows cache poisoning from other projects built on the same host (high 8.8)
- [CVE-2026-40176](https://insights.sbomify.com/CVE-2026-40176/): Composer is vulnerable to Command Injection via Malicious Perforce Repository (high 7.8)
- [CVE-2025-67746](https://insights.sbomify.com/CVE-2025-67746/): Composer vulnerable to ANSI sequence injection (low 1.3)

## Fix prompt for AI coding agents

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

What it is: CVE-2021-41116 is a high-severity command injection vulnerability in composer, published on 5 Oct 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2021-41116 in the wild and no public exploit code.

Affected packages and fixed versions:
- composer/composer (Packagist): affected all versions; fixed in 1.10.23
- composer/composer (Packagist): affected all versions; fixed in 1.10.23
- composer/composer (Packagist): affected from 2.0.0-alpha1; fixed in 2.1.9
- composer/composer (Packagist): affected from 2.0.0-alpha1; fixed in 2.1.9
- composer (Bitnami): affected all versions; fixed in 1.10.23, 2.1.9

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

## Sources

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

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