GHSA-RGPJ-F2QX-XWHF
Use-after-free when putenv() is called during request shutdown
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-RGPJ-F2QX-XWHF divulgada · CVSS 6.5 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| 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
If an application calls `putenv()` from code that runs during request shutdown (a shutdown function, the destructor of an object alive at the end of the script, or a session `write()`/`close()` handler), FrankenPHP keeps a pointer to a freed environment table. The next script on the same PHP thread uses it on its first `getenv()` or `putenv()` call, which most frameworks make on every request.
On a release build of PHP 8.5 with the default allocator, this crashes the whole process (segmentation fault). With `USE_ZEND_ALLOC=0`, the next request can read the previous request's value back.
Classic mode is affected on every thread. Worker mode is affected when a worker script restarts.
Patches
Fixed in 1.13.4 by https://github.com/php/frankenphp/commit/ab174aa6c27738b9ee56c97ac276d152bfb38f5e.
Workarounds
Don't call `putenv()` from shutdown functions, destructors or session handlers.
Details
The first `putenv()` of a script allocates FrankenPHP's environment sandbox on the request heap. FrankenPHP released the sandbox before `php_request_shutdown()`, but shutdown functions, destructors and session handlers run inside `php_request_shutdown()`. A `putenv()` there allocated a new sandbox, which `php_request_shutdown()` then freed along with the request heap, leaving the thread-local pointer dangling. FrankenPHP now clears the pointer once `php_request_shutdown()` returns.
Proof of concept
With one PHP thread, request 1 runs:
<?php
register_shutdown_function(static fn () => putenv('LATE=1'));Request 2 runs `getenv('LATE');`, which reads the freed table (heap use-after-free under ASan, segmentation fault on a release build).
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-rgpj-f2qx-xwhfLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
