p PatchFirst

CVE-2026-40261

CVE-2026-40261 · Composer has Command Injection via Malicious Perforce Reference

This page contains facts from public vulnerability sources. Check the original advisory before updating.

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.

CVSS 8.8 · High · EPSS 1.7% · Fix available

Published
Updated

Stack: system · php

Affected products and versions

  • composer

    Versions
    • >= 2.3.0, < 2.9.6: Affected
    • >= 1.0.0, < 2.2.27: Affected

    No fix published

  • composer Debian:12

    Versions
    • 2.5.5-1
    • 2.5.5-1+deb12u1
    • 2.5.5-1+deb12u2
    • 2.5.5-1+deb12u3
    Affected ranges
    • ECOSYSTEM: < 2.5.5-1+deb12u4

    Update to 2.5.5-1+deb12u4

  • composer Debian:13

    Versions
    • 2.8.8-1
    • 2.8.8-1+deb13u1
    Affected ranges
    • ECOSYSTEM: < 2.8.8-1+deb13u2

    Update to 2.8.8-1+deb13u2

  • composer Debian:14

    Versions
    • 2.8.10-1
    • 2.8.11-1
    • 2.8.11-2
    • 2.8.12-1
    • 2.8.8-1
    • 2.8.9-1
    • 2.9.0~rc1-1
    • 2.9.1-1
    • 2.9.2-1
    • 2.9.3-1
    • 2.9.4-1
    • 2.9.5-1
    Affected ranges
    • ECOSYSTEM: < 2.9.7-1

    Update to 2.9.7-1

  • composer/composer Packagist

    Versions
    • 2.3.0
    • 2.3.1
    • 2.3.10
    • 2.3.2
    • 2.3.3
    • 2.3.4
    • 2.3.5
    • 2.3.6
    • 2.3.7
    • 2.3.8
    • 2.3.9
    • 2.4.0
    • 2.4.0-RC1
    • 2.4.1
    • 2.4.2
    • 2.4.3
    • 2.4.4
    • 2.5.0
    • 2.5.1
    • 2.5.2
    • 2.5.3
    • 2.5.4
    • 2.5.5
    • 2.5.6
    • 2.5.7
    • 2.5.8
    • 2.6.0
    • 2.6.1
    • 2.6.2
    • 2.6.3
    • 2.6.4
    • 2.6.5
    • 2.6.6
    • 2.7.0
    • 2.7.1
    • 2.7.2
    • 2.7.3
    • 2.7.4
    • 2.7.5
    • 2.7.6
    • 2.7.7
    • 2.7.8
    • 2.7.9
    • 2.8.0
    • 2.8.1
    • 2.8.10
    • 2.8.11
    • 2.8.12
    • 2.8.2
    • 2.8.3
    • 2.8.4
    • 2.8.5
    • 2.8.6
    • 2.8.7
    • 2.8.8
    • 2.8.9
    • 2.9.0
    • 2.9.0-RC1
    • 2.9.1
    • 2.9.2
    • 2.9.3
    • 2.9.4
    • 2.9.5
    Affected ranges
    • ECOSYSTEM: ≥ 2.3.0, < 2.9.6

    Update to 2.9.6

  • composer/composer Packagist

    Versions
    • 1.0.0
    • 1.0.1
    • 1.0.2
    • 1.0.3
    • 1.1.0
    • 1.1.0-RC
    • 1.1.1
    • 1.1.2
    • 1.1.3
    • 1.10.0
    • 1.10.0-RC
    • 1.10.1
    • 1.10.10
    • 1.10.11
    • 1.10.12
    • 1.10.13
    • 1.10.14
    • 1.10.15
    • 1.10.16
    • 1.10.17
    • 1.10.18
    • 1.10.19
    • 1.10.2
    • 1.10.20
    • 1.10.21
    • 1.10.22
    • 1.10.23
    • 1.10.24
    • 1.10.25
    • 1.10.26
    • 1.10.27
    • 1.10.28
    • 1.10.3
    • 1.10.4
    • 1.10.5
    • 1.10.6
    • 1.10.7
    • 1.10.8
    • 1.10.9
    • 1.2.0
    • 1.2.0-RC
    • 1.2.1
    • 1.2.2
    • 1.2.3
    • 1.2.4
    • 1.3.0
    • 1.3.0-RC
    • 1.3.1
    • 1.3.2
    • 1.3.3
    • 1.4.0
    • 1.4.1
    • 1.4.2
    • 1.4.3
    • 1.5.0
    • 1.5.1
    • 1.5.2
    • 1.5.3
    • 1.5.4
    • 1.5.5
    • 1.5.6
    • 1.6.0
    • 1.6.0-RC
    • 1.6.1
    • 1.6.2
    • 1.6.3
    • 1.6.4
    • 1.6.5
    • 1.7.0
    • 1.7.0-RC
    • 1.7.1
    • 1.7.2
    • 1.7.3
    • 1.8.0
    • 1.8.1
    • 1.8.2
    • 1.8.3
    • 1.8.4
    • 1.8.5
    • 1.8.6
    • 1.9.0
    • 1.9.1
    • 1.9.2
    • 1.9.3
    • 2.0.0
    • 2.0.0-RC1
    • 2.0.0-RC2
    • 2.0.0-alpha1
    • 2.0.0-alpha2
    • 2.0.0-alpha3
    • 2.0.1
    • 2.0.10
    • 2.0.11
    • 2.0.12
    • 2.0.13
    • 2.0.14
    • 2.0.2
    • 2.0.3
    • 2.0.4
    • 2.0.5
    • 2.0.6
    • 2.0.7
    • 2.0.8
    • 2.0.9
    • 2.1.0
    • 2.1.0-RC1
    • 2.1.1
    • 2.1.10
    • 2.1.11
    • 2.1.12
    • 2.1.14
    • 2.1.2
    • 2.1.3
    • 2.1.4
    • 2.1.5
    • 2.1.6
    • 2.1.7
    • 2.1.8
    • 2.1.9
    • 2.2.0
    • 2.2.0-RC1
    • 2.2.1
    • 2.2.10
    • 2.2.11
    • 2.2.12
    • 2.2.13
    • 2.2.14
    • 2.2.15
    • 2.2.16
    • 2.2.17
    • 2.2.18
    • 2.2.19
    • 2.2.2
    • 2.2.20
    • 2.2.21
    • 2.2.22
    • 2.2.23
    • 2.2.24
    • 2.2.25
    • 2.2.26
    • 2.2.3
    • 2.2.4
    • 2.2.5
    • 2.2.6
    • 2.2.7
    • 2.2.8
    • 2.2.9
    Affected ranges
    • ECOSYSTEM: ≥ 1.0.0, < 2.2.27

    Update to 2.2.27

  • composer Ubuntu:Pro:16.04:LTS

    Versions
    • 1.0.0~alpha10+20150602-1
    • 1.0.0~alpha10+20150602-2
    • 1.0.0~alpha11-1
    • 1.0.0~alpha11-1ubuntu1
    • 1.0.0~alpha11-2
    • 1.0.0~alpha11-3
    • 1.0.0~beta1-1ubuntu1
    • 1.0.0~beta2-1
    • 1.0.0~beta2-1ubuntu0.1~esm1
    • 1.0.0~beta2-1ubuntu0.1~esm2
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • composer Ubuntu:Pro:18.04:LTS

    Versions
    • 1.5.1-1
    • 1.5.2-1
    • 1.6.2-1
    • 1.6.3-1
    • 1.6.3-1ubuntu0.1~esm1
    • 1.6.3-1ubuntu0.1~esm2
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • composer Ubuntu:Pro:20.04:LTS

    Versions
    • 1.9.0-2
    • 1.9.1-1
    • 1.9.2-1
    • 1.9.3-1
    • 1.10.0-1
    • 1.10.1-1
    • 1.10.1-1ubuntu0.1~esm1
    • 1.10.1-1ubuntu0.1~esm2
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • composer Ubuntu:Pro:22.04:LTS

    Versions
    • 2.0.9-2ubuntu2
    • 2.0.9-2ubuntu3
    • 2.0.13-1ubuntu1
    • 2.1.12-1ubuntu1
    • 2.2.6-2ubuntu4
    • 2.2.6-2ubuntu4+esm1
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • composer Ubuntu:Pro:24.04:LTS

    Versions
    • 2.5.8-1
    • 2.6.5-1
    • 2.6.6-1
    • 2.7.1-2
    • 2.7.1-2ubuntu0.1~esm1
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • composer Ubuntu:25.10

    Versions
    • 2.8.6-1
    • 2.8.8-1
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • composer Ubuntu:26.10

    Versions
    • 2.9.5-1
    • 2.10.1-2
    • 2.10.2-1
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • composer Ubuntu:26.04:LTS

    Versions
    • 2.8.8-1
    • 2.9.5-1
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

Original sources

Check your server →