CVE-2026-46420
JSON

5.6medium

setup-php: Command Injection in Repository-Derived PHP Version Resolution

Severity
5.6medium CVSS:3.1 by GitHub_M
Exploit likelihood
2.01% (higher than 81% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-pqwm-q9pv-ph8r

Description

setup-php is a GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and tools. From 2.25.0 prior to 2.37.1, shivammathur/setup-php resolves the PHP version from repository-controlled files such as .php-version, composer.lock through platform-overrides.php, and composer.json through config.platform.php, and insufficiently constrains those values before incorporating them into generated shell or PowerShell setup scripts, allowing command injection on a GitHub Actions runner when workflows such as pull_request_target check out attacker-controlled contents before invoking setup-php. This issue is fixed in version 2.37.1.

Affected

Product or packageVersionsReported by
shivammathur setup-php>= 2.25.0, < 2.37.1CVE List
shivammathur/setup-php (GitHub Actions)from 2.25.0 before 2.37.1GitHub Advisory Database
shivammathur setup_phpfrom 2.25.0 before 2.37.1NVD

All scores

GitHub_M5.6medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L
GitHub5.6medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L
NVD9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-78

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

setup-php is a GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and tools. From 2.25.0 prior to 2.37.1, shivammathur/setup-php resolves the PHP version from repository-controlled files such as .php-version, composer.lock through platform-overrides.php, and composer.json through config.platform.php, and insufficiently constrains those values before incorporating them into generated shell or PowerShell setup scripts, allowing command injection on a GitHub Actions runner when workflows such as pull_request_target check out attacker-controlled contents before invoking setup-php. This issue is fixed in version 2.37.1.

GitHub Advisory Database
Summary

A command injection vulnerability was identified in shivammathur/setup-php when the action resolves the PHP version from repository-controlled files and uses that value while generating the platform setup script.

In affected versions, setup-php may read the PHP version from:

  • .php-version
  • composer.lock via platform-overrides.php
  • composer.json via config.platform.php

If an attacker can influence one of these files and the workflow executes setup-php in a trusted context, they may be able to execute commands on the GitHub Actions runner.

Impact

This issue is exploitable when setup-php is run after checking out attacker-controlled repository contents and resolves the PHP version from repository files.

The most significant example is a privileged workflow such as pull_request_target that checks out untrusted pull request code before invoking setup-php. Similar risk can also arise in other workflows that operate on attacker-controlled refs, branches, or repository contents in a trusted context.

This is not a separate security boundary when an attacker can already modify the workflow definition itself or directly control the php-version workflow input, since that level of access already permits arbitrary command execution in GitHub Actions.

Technical details

In affected versions, repository-derived PHP version values were insufficiently constrained before being incorporated into the generated shell or PowerShell setup script executed by the action. This could allow attacker-controlled values from supported repository files to influence script execution in trusted workflow contexts.

Remediation

If you are using shivammathur/setup-php@v2, no action is needed on your end. Users who pin the setup-php release version or release version SHA should upgrade to a patched version.

The fix validates PHP version inputs, constrains manifest-derived versions, hardens script generation at the execution, and includes additional checks in related input-handling paths.

NVD (es)

setup-php es una acción de GitHub para configurar PHP con extensiones, configuración de php.ini, controladores de cobertura y herramientas. Desde la versión 2.25.0 anterior a la 2.37.1, shivammathur/setup-php resuelve la versión de PHP de archivos controlados por el repositorio como .php-version, composer.lock a través de platform-overrides.php, y composer.json a través de config.platform.php, y restringe insuficientemente esos valores antes de incorporarlos en scripts de configuración de shell o PowerShell generados, permitiendo la inyección de comandos en un ejecutor de GitHub Actions cuando flujos de trabajo como pull_request_target extraen contenido controlado por el atacante antes de invocar setup-php. Este problema está solucionado en la versión 2.37.1.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-46420 changed 2026-07-20CVE Terms of Use
GitHub Advisory DatabaseGHSA-pqwm-q9pv-ph8r changed 2026-05-20CC-BY-4.0
NVDCVE-2026-46420 changed 2026-10-24Public domain