VulnWatch by ve1ve2
medium 6.9 EPSS 12.8%

GHSA-5j3f-64r7-f564 / CVE-2026-129538: PHP-CGI out-of-bounds read and write during PATH_INFO correction

Source:
PHP releases (GitHub php/php-src tags)
Published:
Fetched:
Updated:
Affects:
php sapi-cgi

https://github.com/php/php-src/security/advisories/GHSA-5j3f-64r7-f564 ↗

repo-advisoryphpCWE-125CWE-787CWE-823securityrepo:php/php-src

PHP-CGI out-of-bounds read and write during PATH_INFO correction ### Summary The PHP CGI binary (`php-cgi`) can access memory outside the supplied path information when a web server passes inconsistent script and path values. Depending on the request and configuration, an unauthenticated attacker may be able to crash the PHP process, expose process memory, or corrupt memory. This affects `php-cgi` in both CGI and FastCGI mode when `cgi.fix_pathinfo=1`, the default. PHP-FPM and PHP running as an Apache module are not affected. ### Details The problem occurs when PHP removes a trailing path from `SCRIPT_FILENAME`, or from `PATH_TRANSLATED` in a redirected CGI request, but the supplied `PATH_INFO` is shorter than the path being removed. A present but empty `PATH_INFO` can also trigger the problem. This requires particular web server mappings; using CGI, FastCGI, or URL rewriting alone is not enough. In `init_request_info()`, PHP calculates the replacement `PATH_INFO` by subtracting the length of the removed suffix from the end of the supplied value. If the suffix is longer, the resulting pointer lies before the `PATH_INFO` buffer. Subsequent path correction can read, write and copy memory through this invalid pointer. The fix checks the lengths before deriving the pointer and skips the rewrite when no valid replacement exists. #### Apache CGI example A legitimate configuration that can produce these values is a legacy Apache CGI installation using `Action`, combined with a rewrite to an absolute filesystem path. For example, this virtual-host configuration routes a short public URL to a longer route handled by an existing `/srv/site/index.php`: ```apache DocumentRoot "/srv/site" ScriptAlias /cgi-bin/php "/usr/local/bin/php-cgi" AddHandler php-script .php Action php-script /cgi-bin/php AcceptPathInfo On RewriteEngine On RewriteRule "^/news/(.*)$" "/srv/site/index.php/content/articles/$1" [L] ``` This fragment assumes an otherwise working Apache CGI installation with the required modules and access permissions. The `Action` arrangement is described in the [PHP CGI installation documentation](https://www.php.net/manual/en/security.cgi-bin.force-redirect.php). A request for `/news/x` can then reach PHP with: ```text PATH_INFO = /news/x PATH_TRANSLATED = /srv/site/index.php/content/articles/x REDIRECT_URL = /news/x ``` PHP finds the existing `index.php`, but the remaining `/content/articles/x` is longer than the original `/news/x`. Attempting to reconcile these values triggers the invalid memory access. This was reproduced through an actual HTTP request with Apache 2.4.58 and an unmodified PHP CGI binary. An `Alias` that maps `/news` to `/srv/site/index.php/content/articles` produced the same result. The ordinary `Action` setup, a conventional rewrite to `index.php`, and a rewrite to the URL `/index.php/content/articles/x` did not trigger the issue in these tests. The vulnerable example is a valid routing confi Affected packages: php:sapi-cgi Patched: sapi-cgi 8.2.36, sapi-cgi 8.3.37, sapi-cgi 8.4.28, sapi-cgi 8.5.13

Linked vulnerabilities (2)

CVE-2026-129538 medium 6.9 EPSS 12.8% (p96) NVDCVE.orgGHSAGHSAGHSA
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

PHP-CGI out-of-bounds read and write during PATH_INFO correction. The PHP CGI binary (php-cgi), in CGI and FastCGI mode with cgi.fix_pathinfo enabled (the default), can perform an out-of-bounds read and write when the path removed from SCRIPT_FILENAME or PATH_TRANSLATED is longer than the supplied PATH_INFO, or when PATH_INFO is empty. This requires a web server mapping that passes such inconsistent values, or a FastCGI listener reachable by untrusted clients. An unauthenticated remote attacker can crash the process, may obtain process memory if the application exposes PATH_INFO or...

CWE: CWE-125, CWE-787, CWE-823Aliases: CVE-2026-115560, CVE-2026-126714, CVE-2026-127960, CVE-2026-128064, CVE-2026-128090, CVE-2026-129289, CVE-2026-129291, CVE-2026-129292, CVE-2026-129496, CVE-2026-129506, CVE-2026-15353, GHSA-5j3f-64r7-f564, CVE-2026-129474, GHSA-8mjj-2r7p-4hg2, GHSA-2fjv-p558-g82m, CVE-2026-129481, CVE-2026-129501NVD: Awaiting Analysis
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N

PHP-CGI out-of-bounds read and write during PATH_INFO correction

CWE: CWE-125, CWE-787, CWE-823Aliases: CVE-2026-129538, CVE-2026-129474, GHSA-8mjj-2r7p-4hg2, GHSA-2fjv-p558-g82m