JustAppSec
Back to news

Composer patches Perforce command injection via malicious package metadata

2 min readPublished 14 Apr 2026Updated 15 Apr 2026Source: GitHub Advisory Database

TL;DR — Composer’s Perforce VCS handling can be abused for command injection, enabling arbitrary shell command execution during dependency installs/updates from source when malicious Perforce metadata is encountered.

What happened

Composer is the de-facto dependency manager for PHP applications and build pipelines, commonly used to fetch and update third-party packages.

A GitHub-reviewed advisory for composer/composer describes a command injection issue in Composer’s Perforce VCS support. The advisory states that Perforce::syncCodeBase() appends an attacker-controlled $sourceReference into a shell command without proper escaping, enabling injection via shell metacharacters. It further notes a related injection surface in Perforce::generateP4Command() (also referenced in a separate advisory) through unescaped Perforce connection parameters.

Two details make this operationally relevant for platform teams: (1) Composer may execute the injected command even if Perforce is not installed, and (2) the malicious values can be delivered via package metadata served by a Composer package repository, turning this into a supply-chain-shaped risk when repositories are compromised or untrusted.

Who is impacted

  • Any environment running composer/composer in the affected version ranges.
  • Highest-risk workflows are installs/updates from source (e.g., --prefer-source, and the advisory notes this is the default when installing dev-prefixed versions), where Composer will process VCS metadata.
PackageAffected versions (per advisory ranges)Fixed versions (per advisory)
composer/composer>= 2.3.0 and < 2.9.62.9.6
composer/composer>= 1.0.0 and < 2.2.272.2.27

Severity is marked HIGH in the advisory, with CVSS v3.1 vector CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.

What to do now

  • Follow vendor remediation guidance and apply the latest patched release available at the time of writing.

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

  • If you cannot update immediately, apply the vendor-listed workaround to reduce exposure.

    "Avoid installing dependencies from source by using --prefer-dist or the preferred-install: dist config setting."

  • Treat repository trust as part of your control plane.

    "Only use trusted Composer repositories."

  • Inventory where Composer executes in your org (developer workstations, CI runners, release builders) and prioritize upgrades where dependency installs occur with --prefer-source or dev-prefixed versions.

Content is AI-assisted and reviewed by our team, but issues may be missed and best practices evolve rapidly, send corrections to [email protected]. Always consult official documentation and validate key implementation decisions before making design or security choices.

Need help?Get in touch.