GHSA-CCGP-CH9H-533F
Cyclic PHP arrays cause a process-wide stack overflow during PHP-to-Go conversion
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-CCGP-CH9H-533F divulgada · CVSS 5.9 (GitHub) | |
| Remediación | Parche v1.13.2 | github.com/dunglas/frankenphp · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
FrankenPHP's PHP-to-Go array converter does not detect circular references. Passing a self-referential PHP array to `frankenphp_log()` or returning one from a worker callback causes unbounded recursion and a fatal Go stack overflow, terminating the entire FrankenPHP process. Unrelated requests fail until the server is restarted.
The crash is reproducible in v1.13.1. An application must create or propagate a cyclic array into one of these APIs for the issue to be triggered.
Details
In `types.go` https://github.com/php/frankenphp/blob/99d4e119ca2e5a90a69d8dbee5d5c9a8016416c5/types.go#L74-L171, `goArray()` converts each array element using `goValue()`. When the element is another PHP array, `goValue()` https://github.com/php/frankenphp/blob/99d4e119ca2e5a90a69d8dbee5d5c9a8016416c5/types.go#L273-L358 enters `GoAssociativeArray()` or `GoPackedArray()` and repeats the traversal. There is no check for arrays already visited on the current conversion path, nor a recursion-depth limit.
This is reachable from:
- `go_log_attrs()`
https://github.com/php/frankenphp/blob/99d4e119ca2e5a90a69d8dbee5d5c9a8016416c5/frankenphp.go#L850-L873, which calls `GoMap[any]()` on the context supplied to `frankenphp_log()`. - `go_frankenphp_finish_worker_request()`
https://github.com/php/frankenphp/blob/99d4e119ca2e5a90a69d8dbee5d5c9a8016416c5/threadworker.go#L279-L289, which calls `GoValue[any]()` on a worker callback's return value.
For a cyclic array, the converter repeatedly enters the same Zend array until the Go runtime aborts:
runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflowThe stack trace repeatedly shows `goValue`, `goArray`, and `GoAssociativeArray` in `types.go`. This terminates the server process rather than raising a PHP exception or returning a conversion error.
Proof of concept
Tested with the official FrankenPHP v1.13.1 Linux x86_64 binary (PHP 8.5.11, Caddy 2.11.7), on Ubuntu 24.04. Release commit: `99d4e119ca2e5a90a69d8dbee5d5c9a8016416c5`.
1. `frankenphp_log()`
Create `public/logging.php`:
<?php
$ctx = ['tag'=>'healthy'];
if (($_GET['case'] ?? '') === 'cyclic') {
$ctx['self'] = &$ctx;
}
frankenphp_log('independent_recheck_log', 0, $ctx);
header('Content-Type: text/plain');
echo 'logger-ok';Create an unrelated endpoint `public/health.php`:
<?php echo 'healthy';Start FrankenPHP:
./frankenphp php-server -l 127.0.0.1:18882 -r "$PWD/public"In another terminal:
curl -i http://127.0.0.1:18882/logging.php
curl -i http://127.0.0.1:18882/health.php
curl -v 'http://127.0.0.1:18882/logging.php?case=cyclic'
curl -v http://127.0.0.1:18882/health.phpBoth control requests return HTTP 200. The cyclic-array request ends with an empty reply (`curl` exit 52). The FrankenPHP process exits with the stack overflow shown above, and the subsequent health request fails with `Connection refused` (`curl` exit 7).
2. Worker callback return value
Create `public/index.php`:
<?php
$handler = static function (): array {
header('Content-Type: text/plain');
echo 'independent-worker-handled';
if (($_GET['trigger'] ?? '') === 'cycle') {
$node = ['origin'=>'independent_worker'];
$node['backref'] = &$node;
return $node;
}
return ['status'=>'ok'];
};
while (frankenphp_handle_request($handler)) {}Create `public/status.txt` containing `healthy` and start FrankenPHP in worker mode:
./frankenphp php-server -l 127.0.0.1:18885 -r "$PWD/public" -w "$PWD/public/index.php,1"In another terminal:
curl -i http://127.0.0.1:18885/
curl -i http://127.0.0.1:18885/status.txt
curl -v 'http://127.0.0.1:18885/?trigger=cycle'
curl -v http://127.0.0.1:18885/status.txtThe normal worker request and static file return HTTP 200. Returning the cyclic array terminates the FrankenPHP process with the same fatal stack overflow. The subsequent request for the static file is refused.
Impact
This is a process-wide denial of service caused by uncontrolled recursion in PHP-to-Go conversion. It affects applications that pass cyclic PHP arrays to the logging context or return them from worker callbacks. A single occurrence terminates the process and interrupts all requests served by it, including unrelated sites or endpoints sharing that process.
Remote reachability depends on application behavior: ordinary HTTP parameters do not directly create PHP reference cycles. A remote attacker would need a reachable path that constructs or preserves such an array and passes it to an affected API. I have not established that path in an unmodified application. The demonstrated impact is availability loss; no confidentiality or integrity impact was observed.
The converter should detect recursive references (and preferably bound nesting depth) and return a recoverable error without terminating the server.
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.2 | 0 d | v1.13.6 no afectada |
v1.13.2Arsenal 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-ccgp-ch9h-533fLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
