Skip to content
Threat Feed
high advisory PoC

Shivammathur setup-php: Command injection via repository configuration (CVE-2026-46420)

The shivammathur/setup-php GitHub Action is vulnerable to command injection when processing PHP version strings from repository-controlled files like composer.json, allowing attackers to achieve arbitrary code execution in CI/CD environments.

CVE search metadata

CVE search record: CVE-2026-46420. Severity: medium. CVSS: 5.6. EPSS: 2.01%. KEV: no. Product: setup-php. Brief: Shivammathur setup-php: Command injection via repository configuration (CVE-2026-46420). Brief link: https://feed.craftedsignal.io/briefs/2026-11-setup-php-command-injection-cve-2026-46420/

Triage facts

Revision 1
Applicability
setup-php
Evidence
Unknown
Severity
High
Action
Immediate escalation
Sources
3 public sources
Freshness
Revision 1Nov 17, 14:12 UTC
Vulnerabilities
1 CVE
Source quality
A1Very likely

Overview

Shivammathur/setup-php versions 2.25.0 through 2.37.0 are vulnerable to command injection (CVE-2026-46420). The GitHub Action, used to configure PHP environments, insecurely processes PHP version constraints defined in repository-controlled files such as .php-version, composer.lock, and composer.json. An attacker can supply a malicious PHP version string containing shell metacharacters, which the action subsequently incorporates into generated shell or PowerShell setup scripts. Execution occurs within the context of the GitHub Actions runner.

Attack Chain

  1. An attacker identifies a target repository using the shivammathur/setup-php GitHub Action.
  2. The attacker creates a pull request from a controlled branch to the target repository.
  3. The attacker modifies the repository's composer.json to include a malicious PHP version string containing shell metacharacters (e.g., "8.2;<COMMAND> #").
  4. The target repository's CI/CD pipeline triggers, running a workflow that invokes setup-php with the attacker-controlled input.
  5. setup-php reads and insufficiently sanitizes the malicious version string.
  6. The action executes the embedded shell command on the GitHub Actions runner.
  7. The attacker-supplied command executes with the privileges of the runner process.

Recommendation

  • Upgrade shivammathur/setup-php to version 2.37.1 or later immediately.
  • Review workflows utilizing pull_request_target triggers, as these are primary vectors for injecting malicious code into CI/CD environments.
  • Audit repository configuration files (composer.json, .php-version, composer.lock) for unexpected changes in pull requests.

Immediate actions

Upgrade shivammathur/setup-php to 2.37.1 or later

DevOps 24h

Threat Hunt

Identify workflows using setup-php that trigger on pull_request or pull_request_target events

T1059.003 high high confidence hunt now

Data: GitHub Actions workflow definitions, Git commit history

Mitigations

Upgrade to shivammathur/setup-php 2.37.1

immediate DevOps

CVE-2026-46420