Skip to main content

CVE-2026-40261 — Vulnerability in composer/composer — CVE Details

HIGH

Composer has a command injection via malicious perforce reference

Published April 14, 2026Updated September 10, 2026Source: OSV

What Should I Do?

Address in Next Maintenance Window

Low exploitation probability (1.98%). Schedule for your next planned update.

Does your project use an affected composer/composer version?

Paste your composer.lock to check it for CVE-2026-40261 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.

Check my composer.lock

Summary

Impact

The Perforce::syncCodeBase() method appended the $sourceReference parameter to a shell command without proper escaping, allowing an attacker to inject arbitrary commands through a crafted source reference containing shell metacharacters. Further as in GHSA-wg36-wvj6-r67p / CVE-2026-40176 the Perforce::generateP4Command() method constructed shell commands by interpolating user-supplied Perforce connection parameters (port, user, client) without proper escaping from the source url field. Composer would execute these injected commands even if Perforce is not installed.

The source reference and url are provided as part of package metadata. Any Composer package repository can serve package metadata declaring perforce as a source type with a malicious source reference or source url. This means the vulnerability can be exploited through any package served by a compromised or malicious Composer repository. An attack does not require Perforce to be installed on the client, as Composer will attempt to execute the constructed command regardless.

This vulnerability is exploitable when installing or updating dependencies from source (--prefer-source, default when installing dev prefixed versions), even if you do not use Perforce.

Patches

Fixed in Composer 2.2.27 (2.2 LTS) and 2.9.6 (mainline)

Note, the fix for the source url in the Perforce::generateP4Command() was addressed as part of the patches for GHSA-wg36-wvj6-r67p / CVE-2026-40176 in the same versions.

Workarounds

  • Avoid installing dependencies from source by using --prefer-dist or the preferred-install: dist config setting.
  • Only use trusted Composer repositories.

Advisory Timeline

  • First published April 14, 2026 (226 days ago).
  • Last revised September 10, 2026 — 148 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

Composer
Update composer/composer to 2.9.6 or later
composer require "composer/composer:^2.9.6"
Composer
Update composer/composer to 2.2.27 or later
composer require "composer/composer:^2.2.27"

After upgrading, scan your dependencies again to confirm the vulnerability is resolved.

Affected Packages (2)

Affects 1 ecosystem: Packagist (1).

PackageFixed In
composer/composer Packagist · Affected: 2.3.0, 2.3.1, 2.3.10, 2.3.2 (+59 more)2.9.6
composer/composer Packagist · Affected: 1.0.0, 1.0.1, 1.0.2, 1.0.3 (+143 more)2.2.27

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

  • CWE-20
    Improper Input ValidationMITRE
  • CWE-78
    OS Command InjectionMITRE

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 8.8 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
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

Frequently Asked Questions

What is CVE-2026-40261?
Composer has a command injection via malicious perforce reference. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 8.8/10).
How do I check if my project is affected by CVE-2026-40261?
CVE-2026-40261 affects composer/composer. It has a 2.0% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-40261 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
8.8

Significant impact if exploited, or exploitable with modest effort.

EPSS Score (30-day exploit probability)
1.98%
EPSS percentile: 81.2

This places it in the top quartile of EPSS-scored vulnerabilities — 81.2% of tracked vulnerabilities score at or below it, so it is more likely to be exploited than most of the tracked corpus.

Also Known As

GHSA-gqw4-4w2p-838q
BIT-composer-2026-40261

Related CVEs

  • CVE-2024-35241
    HIGH

    Composer has a command injection via malicious git branch name

  • CVE-2026-103035
    HIGH

    TeamPass folder re-parenting authorization bypass

  • CVE-2026-110782
    HIGH

    SAML2: Incomplete fix of CVE-2026-49283: unsigned embedded Response bypasses HTTP-Artifact signature verification (no embedded-Issuer binding)

  • CVE-2026-84361
    HIGH

    Composer arbitrary command execution via a malicious package's Perforce source URL

  • CVE-2024-35242
    HIGH

    Composer has multiple command injections via malicious git/hg branch names

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my composer.lock