CVE-2026-40261: Composer has Command Injection via Malicious Perforce Reference
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::syncCodeBase() method, which appends the $sourceReference parameter to a shell command without proper escaping, and additionally in the Perforce::generateP4Command() method as in GHSA-wg36-wvj6-r67p / CVE-2026-40176, which interpolates user-supplied Perforce connection parameters (port, user, client) from the source url field without proper escaping. An attacker can inject arbitrary commands through crafted source reference or source url values containing shell metacharacters, even if Perforce is not installed. Unlike CVE-2026-40176, the source reference and url are provided as part of package metadata, meaning any compromised or malicious Composer repository can serve package metadata declaring perforce as a source type with malicious values. This vulnerability is exploitable when installing or updating dependencies from source, including the default behavior when installing dev-prefixed versions. This issue has been fixed in Composer 2.2.27 (2.2 LTS) and 2.9.6 (mainline). If developers are unable to immediately update, they can avoid installing dependencies from source by using --prefer-dist or the preferred-install: dist config setting, and only use trusted Composer repositories as a workaround.
Security readout for executives and security teams
Plain-English summary
Composer can be tricked into running operating-system commands during dependency install or update if a malicious or compromised repository supplies crafted Perforce package metadata. This is a build-chain risk for developer machines, CI, and release systems when Composer installs packages from source, including dev-prefixed versions.
Executive priority
Prioritize remediation for build and release environments first. Compromise there can affect source code integrity, secrets, and deployed artifacts. Treat this as a high-priority supply-chain issue, not only a developer workstation bug.
Technical view
Affected Composer versions append sourceReference in Perforce::syncCodeBase() and interpolate Perforce URL connection parameters in generateP4Command() without proper shell escaping. Malicious package metadata can inject commands through source reference or source URL values, even when Perforce is not installed.
Likely exposure
Exposure is most likely in PHP environments using Composer 1.0.0 to before 2.2.27, or 2.3.0 to before 2.9.6, especially CI and developer workflows using source installs, dev-prefixed dependencies, or non-trusted Composer repositories.
Exploitation context
The bundle does not report active exploitation, and KEV is false. Exploitation requires user interaction through installing or updating dependencies from source, with malicious metadata served by a compromised or malicious Composer repository.
Researcher notes
This issue extends the Perforce command-injection pattern associated with CVE-2026-40176 by allowing malicious package metadata to supply the source reference and URL. Evidence supports affected ranges and fixed Composer versions, but the bundle does not provide proof of public exploitation.
Mitigation direction
Upgrade Composer 2.2 LTS to 2.2.27 or later.
Upgrade Composer mainline to 2.9.6 or later.
Use preferred-install: dist where immediate upgrade is not possible.
Use --prefer-dist for dependency installation as a temporary workaround.
Restrict Composer repositories to trusted sources.
Validation and detection
Inventory Composer versions on developer machines, CI runners, and build images.
Check whether builds install dependencies from source or use dev-prefixed versions.
Review Composer repository configuration for untrusted or unnecessary repositories.
Confirm preferred-install is set to dist where upgrades are delayed.
Monitor vendor advisories for downstream package status and guidance.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-20: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
Command injection weaknesses can lead defenders to review execution techniques and command interpreter telemetry. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
The CVE wording references code or command execution, so execution technique review may help defensive triage. This is a Glexia inferred lookup path, not an official MITRE, ATT&CK, or CVE Program mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
2CVSS vectors
5Timeline events
2ADP providers
7Source links
SSVC decision data
CISA-ADPCISA Coordinator
Timestamp
Version
2.0.3
Exploitation: noneAutomatable: noTechnical Impact: total
CVSS vector scores
2 official scores
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.