ComposerApplication · Getcomposer

CVE-2026-40261

HIGH · 8.8 CVSS v3.1 Published 2026-04-15
Fix available
A fix is available. Upgrade to after 2.9.5 or later.
See remediation →
95/100
Remediation priority · Urgent
Remotely reachable No privileges

Official description Straight from the sourceThe vendor's or NVD's own wording, published unedited. Authoritative, but often terse — it says what broke, rarely what to do.

NVD · unedited
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.

Technical summary Written by usOur analysis, written from the advisory, the CVSS vector and the affected-version data. It adds context the advisory leaves out, and never invents facts that are not in the source.

dbcve analysis · high confidence

Composer versions 1.0-2.2.26 and 2.3-2.9.5 contain a command injection vulnerability in the Perforce integration. The Perforce::syncCodeBase() method unsafely appends the $sourceReference parameter to a shell command, while Perforce::generateP4Command() interpolates user-supplied connection parameters (port, user, client) from package metadata without escaping. Since these values come from repository-served package metadata, any compromised or malicious Composer repository can trigger arbitrary command execution during source installs.

MitigationUpdate to Composer 2.2.27 or 2.9.6 immediately. Until then, use --prefer-dist or set preferred-install: dist to avoid source-based installs from untrusted repositories.

Verify against the referenced sources before acting — the references below are authoritative for this CVE, this summary is not.

Affected products & versions What the vendor confirmedThe version ranges the vendor confirmed as vulnerable. If your version sits inside a range here, treat yourself as exposed until you have upgraded.

NVD · CPE data
ComposerApplication
Affected:>= 1.0.0, <= 2.2.26>= 2.3.0, <= 2.9.5

CVSS breakdown How the score is builtThe industry scoring standard. It rates how the flaw is reached, what it takes to exploit, and what an attacker gains — the score is derived from those, not the other way round.

From the vector
Attack vector
Network
Complexity
Low
Privileges
None
User interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

Am I affected? How to checkSteps we derive from the advisory and the affected-version data, so you can decide whether this CVE reaches your setup. They are a guide, not a scan — your own configuration is the authority.

dbcve checks

Work through these to decide whether this CVE applies to you.

  1. Check installed Composer version
    Run `composer --version` or `composer self-version` to get the exact version number
    Affected if Version is >= 1.0.0 and <= 2.2.26, OR >= 2.3.0 and <= 2.9.5
  2. Verify Perforce client availability
    Check if the `p4` command is available on the system by running `which p4` or `p4 -V`
    Affected if Perforce client (p4) is installed and accessible from the system PATH
  3. Inspect composer.json for Perforce repository usage
    Look for Perforce-based package sources in the project's composer.json and any composer repositories configuration. Search for URLs starting with `p4:` or Perforce depot paths
    Affected if The project or its dependencies reference Perforce-based repositories or source URLs
  4. Check installation method being used
    Review composer.json for `preferred-install` setting, or inspect `composer.lock` to see if packages are installed from source. Run `composer install --prefer-source` or check if source installations are occurring
    Affected if Packages are being installed from source (using Perforce or other VCS sources) rather than dist archives
  5. Examine installed package source types
    Check the `vendor/` directory structure. Source-installed packages typically have `.git`, `.svn`, or other VCS directories rather than packed archive files. Run `ls -la vendor/<package>/` to inspect
    Affected if Packages from Perforce/VCS sources are present in vendor/ with source control directories

You are affected if your Composer version is in the vulnerable range AND you are installing packages from Perforce or other source-based repositories, especially from untrusted sources.

Generated from the published advisory. Verify against your own configuration.

Check your environment

Paste your version and any relevant configuration and it will be compared against the affected criteria above. Do not include secrets or credentials.

AI-assisted, checked against the advisory. Informational, not a guarantee.

Remediation Closing itWhat it takes to close this. Where a vendor fix exists we point at it; where none exists we say so plainly, and can build one. Effort estimates are scoped from the advisory, not from your codebase.

dbcve · scoped
Upgrade available Upgrade to a release after 2.9.5
Interim mitigation

Update to Composer 2.2.27 or 2.9.6 immediately. Until then, use --prefer-dist or set preferred-install: dist to avoid source-based installs from untrusted repositories.

Recommended fix High confidence

Composer 2.2.27 (LTS) or Composer 2.9.6 (mainline)

  1. 1. Identify the current Composer version by running: composer --version
  2. 2. For Composer 2.x users: Upgrade to version 2.9.6 or later by running: composer self-update 2.9.6
  3. 3. For Composer 2.2 LTS users: Upgrade to version 2.2.27 or later by running: composer self-update 2.2.27
  4. 4. Verify the upgrade was successful by running: composer --version
  5. 5. As an alternative to upgrading, if you cannot upgrade immediately, add "preferred-install": "dist" to your composer.json's config section to avoid installing from source
  6. 6. Only use trusted Composer repositories and verify repository integrity

Generated from the published advisory — verify against the referenced sources before acting.

Fix this in Composer Scoped from the published advisory
  • Consultation2.0 h
  • Implementation4.0 h
  • Testing2.0 h
  • Review / QA1.0 h
9.0 hours of engineering $1,600
Get the upgrade done

An estimate, not a bill — we confirm scope with you before any work starts. Need it this week? Rush from $2,560.

Scan for this in your stack

Free · runs locally
dbcve dependency scanner

Check whether your project pulls in CVE-2026-40261 — or any other known-vulnerable package — straight from your lock files. Free and open source; it runs locally and uploads nothing.

References Go to the primary sourcePrimary sources — vendor advisories, patches and trackers. Where our summary and a reference disagree, the reference wins.

Primary sources

Practitioner notes

Contributed

Peer-ranked notes from engineers who’ve handled CVE-2026-40261 in production — separate from our analysis above.

No notes yet

Be the first to add a field note for this CVE — a mitigation you’ve verified, a version caveat, or a link to a working fix. Sign in above to contribute.

What this is

A place for practitioners to share what actually worked: a mitigation you’ve tested, a configuration change, a version- or environment-specific caveat, or a link to a verified patch. The most useful notes rise to the top as peers upvote them, so the signal stays high.

What belongs here
  • Verified mitigations, workarounds, and config changes
  • Version or environment caveats, and links to real fixes
  • No weaponised exploit code, or anything meant to cause harm
  • No spam, self-promotion, credentials, or personal data