CVE-2026-40261: Command Injection in Composer Perforce VCS Driver
- Vendor
- Getcomposer
CVE-2026-40261 is a command injection vulnerability in Composer's Perforce VCS driver. Affected versions are Composer 1.0 through 2.2.26 and 2.3 through 2.9.5. The flaw is centered on the Perforce::syncCodeBase() method, which appends the attacker-controlled $sourceReference value to a shell command without proper escaping. The issue is compounded by unsafe command construction in Perforce::generateP4Command(), similar to CVE-2026-40176, where Perforce connection parameters derived from the source URL may also be interpolated into shell commands without sufficient escaping. Unlike CVE-2026-40176, this vulnerability is delivered through package metadata from a malicious or compromised Composer repository: an attacker can publish or serve metadata declaring a Perforce source type and embed shell metacharacters in the source reference or source URL fields. When Composer installs or updates dependencies from source, the crafted metadata can cause arbitrary shell commands to be executed on the client system, even if Perforce itself is not installed.
Impact, mitigation & remediation
What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.
Impact
What an attacker gets, and what they’ve been doing with it.
Successful exploitation results in arbitrary command execution in the security context of the user running Composer. This can allow compromise of developer workstations, CI runners, or build environments; theft of credentials, tokens, SSH keys, or source code; modification of project files or dependency trees; installation of persistence mechanisms or secondary payloads; and broader supply-chain compromise if the affected environment has access to internal repositories, signing material, or deployment infrastructure. The issue is particularly severe because exploitation can be triggered by malicious dependency metadata from a repository rather than requiring a user to manually open an untrusted root project.
Mitigation
If you can’t patch tonight, do this now.
If immediate patching is not possible, avoid installing dependencies from source by using --prefer-dist or setting preferred-install to dist. Restrict Composer usage to trusted repositories only, and avoid consuming package metadata from untrusted or compromised repository sources. Where feasible, disable or block Perforce-backed source installs in internal workflows, and monitor developer and CI environments for unexpected shell execution during Composer operations. Additional defensive measures include isolating build environments, minimizing available credentials on systems running Composer, and reviewing repository metadata handling in internal package mirrors.
Remediation
Patch, then assume compromise.
Upgrade Composer to a fixed release: 2.2.27 for the 2.2 LTS branch or 2.9.6 for the mainline branch. Organizations should update all developer endpoints, CI/CD agents, build containers, and any automation invoking Composer. If repository mirrors or internal package infrastructure cache Composer metadata, ensure they are refreshed after upgrading. Review recent installs or updates performed from source against untrusted or third-party repositories for signs of command execution or tampering.
Exploits
2 exploits validated by Mallory's analysis.
Affected products & vendors
Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.
References
Frequently asked questions
- Is CVE-2026-40261 exploited in the wild?
- As of Sep 25, 2026, Mallory has no reports of CVE-2026-40261 being exploited in the wild. It is not listed in CISA KEV.
- Is there a public exploit for CVE-2026-40261?
- Yes. Mallory tracks 2 public exploits or proofs of concept for CVE-2026-40261, the earliest disclosed Apr 16, 2026.
- Is there a patch for CVE-2026-40261?
- Upgrade Composer to a fixed release: 2.2.27 for the 2.2 LTS branch or 2.9.6 for the mainline branch. Organizations should update all developer endpoints, CI/CD agents, build containers, and any automation invoking Composer.
- What products are affected by CVE-2026-40261?
- Getcomposer Composer.
- How severe is CVE-2026-40261?
- CVE-2026-40261 has a CVSS v3.1 score of 8.8 (High) and an EPSS score of 1.7% (78th percentile) as of Sep 25, 2026.
Recent activity
17 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.