GHSA-37XV-5QFQ-7QXC
HTTP/2 connections buffer oversized frames and unbounded header blocks and sections before enforcing limits, and share rate limiter state across connections, enabling denial of service
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:L/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-37XV-5QFQ-7QXC divulgada · CVSS 7.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Impact
Three flaws in `Psl\H2\ServerConnection` and `Psl\H2\ClientConnection` let a remote peer exhaust the memory of the process or get unrelated connections closed.
Oversized frames were buffered before their size was checked. RFC 9113 section 4.2 requires an endpoint to treat a frame larger than its `SETTINGS_MAX_FRAME_SIZE` (16,384 bytes unless raised) as an error. The connection read the 24-bit length from each frame header and then buffered the whole payload, up to 16 MiB, before comparing it with that limit, and frames on stream 0 (`SETTINGS`, `PING`, `GOAWAY`, `WINDOW_UPDATE`) were not compared at all. Flow control did not bound this either, because it is only applied once a frame has been read. A peer can therefore make each connection hold about 16 MiB, plus a copy of the payload, instead of 16 KiB, and keep it held by sending the frame slowly. A few such connections exceed PHP's default `memory_limit` of 128 MiB, and the fatal error ends every connection served by that process.
- Server side: any client that sends the connection preface can do this to an application that accepts untrusted traffic with `Psl\H2\ServerConnection`. No authentication is involved.
- Client side: a malicious or compromised server can do the same to a process that uses `Psl\H2\ClientConnection`, including `Psl\HTTP\Client` over HTTP/2 (6.2.0 and later).
Received field blocks and field sections were buffered without a default limit. A HEADERS or PUSH_PROMISE frame that does not carry END_HEADERS is continued by CONTINUATION frames, and a field block can only be HPACK-decoded once it is whole, so the connection accumulated the fragments of one block until it ended. The maximum block size defaulted to 0, meaning unlimited, in `Configuration`, `ServerConfiguration` and `ClientConfiguration`, and in the state machine and assembler behind them. A peer that opens a block and sends CONTINUATION frames that never set END_HEADERS therefore made a default connection buffer every fragment, without bound, for the life of the connection: the CVE-2023-45288 pattern. Separately, the HPACK decoder was built with the local `SETTINGS_MAX_HEADER_LIST_SIZE`, whose RFC initial value is unlimited, so even a bounded block could decode to an unbounded field section, since one byte of a block can reference a dynamic-table entry of up to about 4 KiB. Either path exhausts memory: on a 128 MiB process, a never-ending block is a fatal error in a fraction of a second.
- Server side: any client that sends the connection preface can do this to an application that accepts untrusted traffic with `Psl\H2\ServerConnection`.
- Client side: a malicious or compromised server can do the same to a process that uses `Psl\H2\ClientConnection`. `Psl\HTTP\Client` is not affected: its HTTP/2 configuration passes a 65,536-byte block limit and a 16,384-byte header-list limit, so it bounded both before 6.4.0.
Rate limiter state was shared between connections. A `Psl\H2\RateLimiter` keeps a count of the frames it records. Both connection classes recorded their peer's frames on the limiter held by their configuration, so every connection built from the same configuration, or given the same `RateLimiter` instance, counted against one shared budget. With `RateLimiter::default()`, which allows 100 `SETTINGS` frames per 10 seconds, one client can send 100 `SETTINGS` frames on its own connection; for the rest of the window, every other connection that receives a `SETTINGS` frame, including the one each new client sends in its preface, is closed with `GOAWAY`. Repeating this every 10 seconds keeps the server unavailable to new clients. The budget of every other limited frame type can be used up the same way, so existing clients are also disconnected when they next send such a frame, for example a `PING`. A busy server can also reach the shared limit with legitimate traffic alone, since every new connection sends at least two `SETTINGS` frames. This part only affects applications that pass a `RateLimiter` in a `Configuration`, `ServerConfiguration` or `ClientConfiguration` and use that configuration, or that limiter, for more than one connection. `Psl\HTTP\Client` does not configure a rate limiter and is not affected by it.
PSL 6.x does not ship an HTTP server, so on the server side only applications that use `Psl\H2\ServerConnection` directly are exposed.
Patches
Fixed in 6.4.0 https://github.com/php-standard-library/php-standard-library/releases/tag/6.4.0.
- Every frame, connection-level frames included, is checked against the local `SETTINGS_MAX_FRAME_SIZE` as soon as its 9-byte header arrives, and the connection is closed with `FRAME_SIZE_ERROR` before any of the payload is read.
- While a frame is being read, transport reads are limited to the bytes that frame still needs.
- Each `ClientConnection` and `ServerConnection` counts its peer's frames on a limiter of its own, created from the configured limits with no recorded frames. The limiter passed in a configuration only supplies limits and is never recorded on.
- Every configuration defaults the maximum field block size to the new `DEFAULT_MAX_HEADER_BLOCK_SIZE` (65,536 bytes) instead of unlimited. The assembler checks a fragment before buffering it, so the block buffer never exceeds the limit, and a block the limit refuses is discarded and the connection closed with `PROTOCOL_ERROR`. A block that arrives whole in one END_HEADERS frame is not buffered and is bounded by `SETTINGS_MAX_FRAME_SIZE` instead. 0 still lifts the limit.
- Without a configured `SETTINGS_MAX_HEADER_LIST_SIZE`, the HPACK decoder now limits a decoded field section to the new `DEFAULT_MAX_RECEIVED_HEADER_LIST_SIZE` (65,536 bytes), counted as RFC 9113 section 6.5.2 does, without advertising it, and fails a larger section with `COMPRESSION_ERROR`. A configured setting is advertised and enforced as before, and passing `DEFAULT_MAX_HEADER_LIST_SIZE` lifts the limit.
Workarounds
For the frame size flaw, none at the protocol layer. Limiting the number of concurrent connections per process and per client address reduces the memory an attacker can tie up, but does not remove the flaw.
For the rate limiter flaw, give every connection a new limiter instead of sharing one, for example by passing `$configuration->withRateLimiter(RateLimiter::default())` to each `ServerConnection` or `ClientConnection` you construct.
For the field block and field section flaw, pass a non-zero `maxHeaderBlockSize` (for example 65,536) in the configuration and configure `Setting::MaxHeaderListSize` to a finite value, as `Psl\HTTP\Client` already does, so both the buffered block and the decoded section are bounded.
References
- RFC 9113 section 4.2 (frame size)
- RFC 9113 section 6.2 (CONTINUATION frames)
- RFC 9113 section 6.5.2 (`SETTINGS_MAX_FRAME_SIZE` and `SETTINGS_MAX_HEADER_LIST_SIZE`)
- RFC 9113 section 10.5 (denial-of-service considerations)
- CVE-2023-45288 (HTTP/2 CONTINUATION flood)
- https://github.com/php-standard-library/php-standard-library/releases/tag/6.4.0
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistphp-standard-library/h2 |
Corregida | 6.4.0 | — | — |
Packagistphp-standard-library/php-standard-library |
Corregida | 6.4.0 | — | — |
6.4.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/php-standard-library/php-standard-library/security/advisories/GHSA-37xv-5qfq-7qxcLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
