GHSA-4GFW-9V29-GP9H
libxml request-scoped error state leaks across worker-mode requests (parse-error fragments and server paths)
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:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-4GFW-9V29-GP9H divulgada · CVSS 3.7 (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
In worker mode, FrankenPHP does not reset libxml's request-scoped module state between requests on the same worker thread. One client's accumulated libxml error entries — containing parse-error message fragments (often embedding fragments of the offending document) and server filesystem paths — survive and can be read by a later client served on the same worker thread via `libxml_get_errors()` / `libxml_get_last_error()`. This is the same structural class as the already-fixed cross-request session ID leak (GHSA-v3ph-cgqh-r8p5 / CVE-2026-82416) but affects a different extension (libxml) and a different request-scoped global (`LIBXML(error_list)`), and is unpatched.
## Root Cause
FrankenPHP's worker loop replaces PHP's normal per-request lifecycle with a hand-rolled shutdown/startup. `frankenphp_worker_request_shutdown()` (frankenphp.c:517) reruns `request_shutdown_func` only for modules listed in `MODULES_TO_RELOAD[]` (frankenphp.c:74-88) — which contains only `filter` (and `session` when the session extension is a shared module). It never calls `zend_post_deactivate_modules()` and performs no per-request Zend memory-manager wipe.
libxml's request-scoped state (`error_list`, `stream_context`, `error_buffer`) is freed exclusively in `php_libxml_post_deactivate()` (ext/libxml/libxml.c:1063-1085), registered as the module's `post_deactivate_func`. That hook runs only via `zend_post_deactivate_modules()` inside `php_request_shutdown` — which the worker path bypasses. (It is NOT freed in `PHP_RSHUTDOWN_FUNCTION(libxml)`, which clears only the entity-loader callback.) `error_list` is `emalloc`'d (libxml.c:1148) and `GINIT` sets it to NULL only once per thread (libxml.c:411), so the list persists on the thread-persistent heap across worker requests.
## Impact
Cross-client information disclosure: a later client can read an earlier client's libxml parse-error entries. Each entry holds `message` (formatted error text, frequently embedding fragments of the parsed document) and `file` (`parser->input->filename` — a server filesystem path for file-based loads), plus line/column/code. Read-only disclosure of another client's parsed-document fragments and server paths. Weaker than the previously-fixed cross-request session ID leak (GHSA-v3ph-cgqh-r8p5 / CVE-2026-82416) (metadata/fragment disclosure rather than a session identity primitive), hence LOW severity.
## Proof of Concept
No executed PoC (requires a running FrankenPHP worker build); the attack chain is fully traced to source with file:line references below. Outline:
1. Deploy any worker-mode PHP app that parses XML/HTML/SVG with `libxml_use_internal_errors(true)` (DOMDocument::loadHTML/loadXML, SimpleXML, SVG sanitizers, XML API endpoints) and does not clear errors at end of request.
2. Victim request A parses a document that emits libxml errors; entries accumulate in `LIBXML(error_list)`.
3. Attacker request B lands on A's worker thread, calls `libxml_get_errors()` / `libxml_get_last_error()`, and reads A's entries.
## Attack Chain
1. Entry: Unauthenticated HTTP request to a worker-mode PHP app that parses XML/HTML with `libxml_use_internal_errors(true)`.
- Guard: per-request module teardown would free `error_list` via `php_libxml_post_deactivate()`.
- Bypass proof: worker shutdown (frankenphp.c:517) never calls `zend_post_deactivate_modules()`; libxml is not in `MODULES_TO_RELOAD[]` (frankenphp.c:74-88) → the post_deactivate hook never runs.
2. Accumulation (request A): libxml appends xmlError entries to `LIBXML(error_list)` (ext/libxml/libxml.c:662); each holds `message` and `file` (= `parser->input->filename`, libxml.c:674). App leaves them unread/uncleared.
3. Persistence: `frankenphp_worker_request_shutdown()` runs (`php_output_deactivate` + `sapi_deactivate` + `frankenphp_free_request_context`).
- Guard: a per-request MM wipe would free the `emalloc`'d list.
- Bypass proof: no `zend_mm_shutdown`/`shutdown_memory_manager`/`zend_deactivate` in the worker path (grep absent); `frankenphp_reset_super_globals` touches only $_FILES/$_SESSION/autoglobals; `frankenphp_release_temporary_streams` touches only temp php_streams; `sapi_deactivate` touches only SAPI request_info. None touch libxml globals. The emalloc'd `error_list` survives on the thread-persistent heap.
4. Sink (request B): Attacker request B on A's worker thread calls `libxml_get_errors()` (libxml.c:1197) / `libxml_get_last_error()` → returns A's entries.
- Guard: `libxml_use_internal_errors(true)` in B, or B clearing the list.
- Bypass proof: `libxml_use_internal_errors(true)` allocates a new list only `if (LIBXML(error_list) == NULL)` (libxml.c:1145-1150) — a carried-over non-NULL list is preserved, not wiped.
5. Impact: B reads A's parse-error fragments and server filesystem paths = cross-client information disclosure.
## Bypass Evidence
- `MODULES_TO_RELOAD[]` (frankenphp.c:74-88): `filter` (+`session` only when session is a shared module). libxml/dom/xml/xmlreader/xsl absent (grep count 0).
- Worker path contains no `zend_post_deactivate_modules()` / `zend_deactivate_modules()` / `zend_mm_shutdown` / `shutdown_memory_manager` call (grep absent from the tree).
- `php_libxml_post_deactivate()` (ext/libxml/libxml.c:1063-1085) is registered as `post_deactivate_func` (libxml.c:108) and is the only automatic free path for `error_list` — it runs via `zend_post_deactivate_modules()` which the worker path bypasses.
- `PHP_RSHUTDOWN_FUNCTION(libxml)` (libxml.c:1041-1048) frees only `entity_loader_callback`, not `error_list`.
- `libxml_use_internal_errors(true)` preserves a non-NULL list (libxml.c:1145-1150). `GINIT` sets `error_list=NULL` once per thread (libxml.c:411), not per request.
- Not documented as by-design: `grep -rniE 'libxml|error_list|internal error|dom'` over docs/security.md, docs/internals.md, docs/worker.md → no match. The accepted-persistence list (security.md:49) names only `$_ENV`, `putenv()`, statics, class statics, globals, `ini_set()`, default stream context, timezone, cwd. libxml `error_list` falls under the general request-isolation guarantee (security.md:40), so this is a defect against FrankenPHP's own threat model — distinct from the documented putenv persistence.
## Affected Versions
`<= 1.13.1` (latest release; also present on HEAD, commit 5e3e36c). libxml evidence from php-src branch PHP-8.5 (matches craft.yml PHP 8.5 pin).
## Suggested Fix
Either call `zend_post_deactivate_modules()` in the worker request-shutdown path (the correct general fix — it reinstates PHP's full module post-deactivate lifecycle), or add libxml (and the related dom/xml/xmlreader/xsl modules) to the reset set so their request-scoped state is cleared between worker requests. Note: lead the fix with `error_list`; `stream_context` is adjacent to the documented "default stream context" caveat.
---
Reported by zx (Jace) — GitHub: @manus-use
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-4gfw-9v29-gp9hLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
