# CVE-2026-40261: Composer command injection in Perforce repository handling

Source: https://junglewise.ai/threats/cve-2026-40261-composer-command-injection-in-perforce-repository-handling  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-04-15. Updated: 2026-07-20  
License: CC BY 4.0 with a link back

CVE-2026-40261 · Severity: high · CVSS 8.8 · Published 2026-04-15

Composer, a popular dependency manager for PHP, is vulnerable to a flaw that allows malicious package repositories to execute unauthorized commands on a user's computer. By providing specially crafted package metadata, an attacker can gain control over systems that are installing or updating software dependencies. This risk exists even if the user does not have the Perforce version control system installed.

Technologies: [Composer (Packagist)](https://junglewise.ai/threats/technologies/composer), [composer/composer (Packagist)](https://junglewise.ai/threats/technologies/composer-composer). Vendors: [Packagist](https://junglewise.ai/threats/vendors/packagist).

## Quick answers

**Is CVE-2026-40261 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-40261 being exploited in the wild.

**How severe is CVE-2026-40261?** High severity, with a CVSS score of 8.8, published 15 April 2026.

**Which products and versions are affected?** Composer (Packagist) >= 1.0.0, < 2.2.27; >= 2.3.0, < 2.9.6, 1.0.0 - 2.2.26, 2.3.0 - 2.9.5; composer/composer (Packagist) ECOSYSTEM:introduced=2.3.0,fixed=2.9.6.

**Is there a fix for CVE-2026-40261?** Yes. composer/composer (Packagist): upgrade to 2.9.6 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-40261 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-40261?** Check whether you run Composer (Packagist) or composer/composer (Packagist) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- composer/composer (Packagist): upgrade to 2.9.6 or later

  ```sh
  composer require composer/composer:^2.9.6
  ```


## Technical details

Composer's Perforce implementation contains two command injection vectors. The `Perforce::syncCodeBase()` method fails to properly escape the `$sourceReference` parameter before appending it to a shell command. Additionally, the `Perforce::generateP4Command()` method interpolates user-supplied connection parameters (port, user, client) from the source URL field without neutralization. An attacker controlling a Composer repository can serve malicious metadata that triggers these injections during a `composer install` or `update` when `--prefer-source` is used. The vulnerability is exploitable regardless of whether the Perforce binary is actually present on the host system. Fixes are available in versions 2.2.27 and 2.9.6.

## Affected products

- Composer composer/composer >= 1.0.0, < 2.2.27; >= 2.3.0, < 2.9.6

## Identifiers

- CVE-2026-40261
- GHSA-gqw4-4w2p-838q

## Timeline

- 2026-04-14: advisory: GitHub Advisory GHSA-gqw4-4w2p-838q published
- 2026-04-14: patched: Fixed in versions 2.2.27 and 2.9.6

## References

- [https://api.github.com/users/kodareef5](https://api.github.com/users/kodareef5)
- [https://github.com/kodareef5](https://github.com/kodareef5)
- [https://api.github.com/users/kodareef5/gists%7B/gist_id%7D](https://api.github.com/users/kodareef5/gists%7B/gist_id%7D)
- [https://api.github.com/users/kodareef5/repos](https://api.github.com/users/kodareef5/repos)
- [https://avatars.githubusercontent.com/u/261977334?v=4](https://avatars.githubusercontent.com/u/261977334?v=4)
- [https://api.github.com/users/kodareef5/events%7B/privacy%7D](https://api.github.com/users/kodareef5/events%7B/privacy%7D)

## Related threats

- [Composer bin path validation bypass via symlinks](https://junglewise.ai/threats/cve-2026-59944-composer-bin-path-validation-bypass-via-symlinks)
- [Composer arbitrary command execution via malicious Perforce source URL](https://junglewise.ai/threats/cve-2026-84361-composer-arbitrary-command-execution-via-malicious-perforce)
- [Composer sensitive information disclosure in GitHub token validation](https://junglewise.ai/threats/cve-2026-45793-composer-sensitive-information-disclosure-in-github-token)
- [Composer path traversal via malicious package name](https://junglewise.ai/threats/cve-2026-59948-composer-path-traversal-via-malicious-package-name)
- [Composer sensitive information disclosure in verbose debug output](https://junglewise.ai/threats/cve-2026-59947-composer-sensitive-information-disclosure-in-verbose-debug-output)
