GHSA-CM3Q-JW2Q-9RH5
Use-after-free of SplTempFileObject streams across worker-mode requests
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-CM3Q-JW2Q-9RH5 divulgada · CVSS 6.5 (GitHub) | |
| Remediación | Parche v1.13.4 | github.com/dunglas/frankenphp · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Impact
In worker mode, FrankenPHP freed the internal stream of any `SplTempFileObject` (or `SplFileObject` on `php://temp`) still alive when the next request started. The next use of the object, or its destructor, then used freed memory. On a release build of PHP 8.5 this returns garbage data with the default allocator and crashes the whole process with `USE_ZEND_ALLOC=0`.
The object survives a request boundary when it is kept on purpose (a service built at worker boot, a static cache), or by accident when it sits in a reference cycle that the garbage collector has not collected yet. Clients only need to send requests that reach code using the object.
`fopen('php://temp')` and `php://memory` streams, used by PSR-7 libraries, are not affected. Classic mode is not affected.
Patches
Fixed in 1.13.4 by https://github.com/php/frankenphp/commit/837b76880b33a1a78ae4f27dea85bdcddb6cf70c.
Workarounds
- Don't keep `SplTempFileObject` or `SplFileObject('php://temp')` instances across worker requests.
- Call `gc_collect_cycles()` after each request, as shown in the worker mode documentation. This covers objects left in reference cycles, not objects kept on purpose.
Details
PHP does not release the request body stream when a worker request ends, so FrankenPHP deleted every `php://temp` stream not exposed to userland with a single reference at the start of each worker request. SPL file objects keep a raw pointer to their stream without exposing it or adding a reference, so they matched this filter. FrankenPHP now releases only the request body stream.
Proof of concept
<?php
$tmp = new SplTempFileObject();
$tmp->fwrite("hello\n");
while (frankenphp_handle_request(static function () use ($tmp) {
$tmp->rewind();
echo $tmp->fgets();
})) {}The second request reads a freed stream (heap use-after-free under ASan).
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
gogithub.com/dunglas/frankenphp |
Corregida | v1.13.4 | 0 d | v1.13.6 no afectada |
v1.13.4Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/php/frankenphp/security/advisories/GHSA-cm3q-jw2q-9rh5Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
