VulnWatch by ve1ve2
critical 9.2 EPSS 7.25%

GHSA-8mjj-2r7p-4hg2 / CVE-2026-129474: Use-after-free in magic method backtraces can lead to remote code execution

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

https://github.com/php/php-src/security/advisories/GHSA-8mjj-2r7p-4hg2 ↗

repo-advisoryphpCWE-416securityrepo:php/php-src

Use-after-free in magic method backtraces can lead to remote code execution ### Summary PHP can access freed memory when collecting the arguments of a method handled by `__call()` or `__callStatic()` for a backtrace. On PHP 8.5 and later, an unauthenticated attacker may be able to trigger this through a crafted request that causes a fatal error while the application enters such a method. Successful exploitation can execute arbitrary code with the privileges of the PHP worker. The demonstrated remote attack requires `fatal_error_backtraces=1` and `zend.exception_ignore_args=0`. Fatal error backtraces are enabled by default in PHP 8.5. PHP's built-in default also includes arguments, but `php.ini-production` sets `zend.exception_ignore_args=1` and prevents this attack path. ### Details Applications and frameworks commonly use `__call()` and `__callStatic()` to forward method calls to another object, including logging facades, database interfaces and service proxies. Before PHP enters the actual magic method, it briefly represents the requested method as a separate call. A backtrace taken during this interval can collect values left behind by an earlier call instead of the current arguments. Some of those values can refer to memory that has already been freed. The demonstrated attack submits crafted JSON to an import endpoint that processes the body and then logs it through a magic static method. The request is sized so that constructing a logging argument crosses `memory_limit`. PHP 8.5.12 introduced delayed handling of this allocation failure, allowing the fatal error to be reported while the magic method call is being entered. If fatal error backtraces include arguments, PHP can then treat request-controlled bytes in reused memory as live values. Processing or releasing the backtrace can corrupt memory or transfer control to an attacker-chosen address. Fatal error backtraces were introduced in PHP 8.5.0. An execution time limit expiring during the same interval is another possible trigger. PHP 8.2–8.4 contain the underlying backtrace error, but reaching it requires a PCNTL signal handler or another component to inspect an interrupted call. No attacker-controlled remote trigger has been established for those branches. They are therefore outside this advisory’s affected version range. ### Impact Remote code execution has been confirmed on PHP 8.5 and later. Exploitation depends on the application and requires control over enough request data to influence memory allocation, a reachable magic method call, and a fatal error at the relevant point. The demonstrated code execution chain also requires knowledge of usable memory addresses despite address space randomisation. Other attempts can crash the worker or produce an ordinary resource limit error. Potentially relevant paths include [Laravel facades](https://github.com/laravel/framework/blob/v13.40.0/src/Illuminate/Support/Facades/Facade.php#L356) and [Magento guest shipping estimation](https://github.com/magento/magento2/blob/2.4.9/app/code/Magento Affected packages: php:engine Patched: engine 8.5.13

Linked vulnerabilities (2)

CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N

Use-after-free in magic method backtraces can lead to remote code execution

CWE: CWE-416Aliases: CVE-2026-129474, CVE-2026-129538, GHSA-5j3f-64r7-f564, GHSA-2fjv-p558-g82m
CVE-2026-129474 critical 9.2 EPSS 7.25% (p94) NVDCVE.orgGHSAGHSAGHSA
CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/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

Use-after-free in magic method backtraces can lead to remote code execution

CWE: CWE-416, CWE-825Aliases: GHSA-8mjj-2r7p-4hg2, CVE-2026-129538, GHSA-5j3f-64r7-f564, GHSA-2fjv-p558-g82mNVD: Awaiting Analysis

Also reported by (1)