CVE-2026-40176: Composer is vulnerable to Command Injection via Malicious Perforce Repository
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).
Security readout for executives and security teams
Plain-English summary
Composer can be tricked into running operating-system commands when someone runs Composer on an untrusted PHP project with a malicious root composer.json. The attacker must influence that project file or Composer config. This is serious for developer workstations and CI systems because code could execute with the privileges of the Composer process.
Executive priority
Treat as high priority for engineering and CI environments that process external code. Patch Composer in build images and developer baselines promptly, then tighten review of untrusted project manifests before dependency installation.
Technical view
The flaw is command injection in Composer's Perforce::generateP4Command(), where Perforce connection parameters are interpolated into shell commands without proper escaping. A malicious Perforce VCS repository entry in root composer.json or Composer config can trigger command execution, even without Perforce installed. Dependency package composer.json files are not an exploitation path.
Likely exposure
Exposure is most likely in developer machines, build runners, and CI pipelines that run vulnerable Composer versions against untrusted or newly submitted projects. Composer versions 1.0 through before 2.2.27 and 2.3 through before 2.9.6 are affected.
Exploitation context
Sources do not show CISA KEV listing or confirmed active exploitation. Exploitation requires user interaction: running Composer commands on attacker-supplied project content or compromised Composer configuration. The root composer.json and Composer config directory are the relevant trust boundaries.
Researcher notes
The important boundary is root project configuration, not transitive dependency manifests. Validation should focus on vulnerable Composer versions and whether untrusted composer.json or Composer config content can reach automated build systems. No source in the bundle establishes public exploitation in the wild.
Mitigation direction
Upgrade Composer 2.2 LTS to 2.2.27 or later.
Upgrade Composer mainline to 2.9.6 or later.
Avoid running Composer on untrusted projects before review.
Inspect root composer.json and Composer config for Perforce VCS repositories.
Update distribution packages using vendor guidance, including Red Hat advisories where applicable.
Validation and detection
Inventory Composer versions on developer workstations and CI images.
Confirm versions are 2.2.27, 2.9.6, or later as appropriate.
Review project root composer.json files for Perforce VCS repository entries.
Review Composer config directories used by build environments.
Check vendor package status if Composer is supplied by an operating-system distribution.
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.