CVE-2026-40261
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 · uneditedComposer 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 confidenceComposer 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.
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>= 1.0.0, <= 2.2.26>= 2.3.0, <= 2.9.5CVSS 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 checksWork through these to decide whether this CVE applies to you.
-
Check installed Composer versionRun `composer --version` or `composer self-version` to get the exact version numberAffected if Version is >= 1.0.0 and <= 2.2.26, OR >= 2.3.0 and <= 2.9.5
-
Verify Perforce client availabilityCheck 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
-
Inspect composer.json for Perforce repository usageLook 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 pathsAffected if The project or its dependencies reference Perforce-based repositories or source URLs
-
Check installation method being usedReview 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 occurringAffected if Packages are being installed from source (using Perforce or other VCS sources) rather than dist archives
-
Examine installed package source typesCheck 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 inspectAffected 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.
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 · scopedUpdate 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.
Composer 2.2.27 (LTS) or Composer 2.9.6 (mainline)
- 1. Identify the current Composer version by running: composer --version
- 2. For Composer 2.x users: Upgrade to version 2.9.6 or later by running: composer self-update 2.9.6
- 3. For Composer 2.2 LTS users: Upgrade to version 2.2.27 or later by running: composer self-update 2.2.27
- 4. Verify the upgrade was successful by running: composer --version
- 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. Only use trusted Composer repositories and verify repository integrity
Generated from the published advisory — verify against the referenced sources before acting.
- Consultation2.0 h
- Implementation4.0 h
- Testing2.0 h
- Review / QA1.0 h
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 locallyCheck 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 sourcesPractitioner notes
ContributedPeer-ranked notes from engineers who’ve handled CVE-2026-40261 in production — separate from our analysis above.
The advisory tells you what broke. It rarely tells you what actually worked. If you’ve dealt with this one, that detail is what the next engineer is searching for.
- The version that genuinely resolved it — not the one the vendor claimed
- A config change or rule that shut the vector down
- A gotcha in the upgrade path that cost you an afternoon
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.
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.
- 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