GHSA-7FR9-XWW6-MFP3
TLS\Listener runs TLS handshakes one at a time and without a deadline, so one silent client blocks the listener indefinitely
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-7FR9-XWW6-MFP3 divulgada · CVSS 7.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Impact
`Psl\TLS\Listener::accept()` accepts a connection from the listener it wraps and runs that connection's TLS handshake before returning, with nothing but the caller's cancellation token to stop it. Accept loops usually call `accept()` without a token, or with one that only signals shutdown, and `Psl\Network\CompositeListener` calls the `accept()` of its inner listeners without one. A client that opens a TCP connection and then sends nothing, or stops partway through its ClientHello, therefore holds `accept()` for as long as it keeps the connection open, and every later connection waits behind it. A failed handshake also left the plain connection open until it was garbage collected.
Any server that accepts connections from an untrusted network through `TLS\Listener` is affected. A single TCP connection, with no TLS and no credentials, stops the server from completing any new TLS connection; connections already established keep working. Servers that accept plain streams themselves and run `Psl\TLS\Acceptor::accept()` per connection, with their own timeout, are not affected.
Patches
Fixed in 6.4.0 https://github.com/php-standard-library/php-standard-library/releases/tag/6.4.0.
- `TLS\Listener` runs handshakes concurrently. While an `accept()` call waits, the listener takes connections from the inner listener and runs the handshake of each in a fiber of its own, and `accept()` returns connections in the order their handshakes complete. A peer that connects and stays silent holds only its own handshake, not the connections behind it.
- Each handshake has its own deadline, 10 seconds by default and configurable with the new optional `$handshakeTimeout` constructor argument (a `Psl\DateTime\Duration`). The deadline starts once the inner listener has accepted the connection, independently of the caller's token.
- At most 256 handshakes are pending at a time, configurable with the new optional `$maxPendingHandshakes` constructor argument (`Listener::DEFAULT_MAX_PENDING_HANDSHAKES`). Each pending handshake holds a connection, a fiber and a timer, so the limit bounds what silent peers cost. While it is reached, the listener takes no further connection from the inner listener, and new connections wait in the inner listener's backlog until a handshake ends.
- A handshake that fails or exceeds its deadline closes its connection and is reported to the next `accept()` call as `HandshakeFailedException`, with the `CancelledException` that ended an exceeded deadline as the previous exception, so accept loops that already skip failed handshakes keep serving.
- Cancelling an `accept()` call now ends that call only; pending handshakes run to completion or to their deadline. `close()` cancels every pending handshake and closes its connection.
The limit bounds cost, not every flood: a client that opens silent connections faster than the limit divided by the deadline (about 26 a second with the defaults) keeps every slot busy, and later connections wait until a slot frees, as with any server that limits concurrent connections. Servers exposed to untrusted clients can shorten `$handshakeTimeout`, raise `$maxPendingHandshakes` and limit connections per client address.
Workarounds
Before 6.4.0, accept plain streams from the inner listener and run each handshake in its own fiber with its own timeout, instead of using `TLS\Listener` (6.4.0 does this inside `TLS\Listener`):
$acceptor = new TLS\Acceptor($configuration);
while (true) {
$stream = $listener->accept();
Async\run(static function () use ($acceptor, $stream): void {
try {
$tls = $acceptor->accept($stream, new Async\TimeoutCancellationToken(DateTime\Duration::seconds(10)));
} catch (Throwable) {
$stream->close();
return;
}
// ... handle $tls
})->ignore();
}References
- RFC 8446 (TLS 1.3), which leaves how long a server waits for a client's handshake messages to the implementation
- 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/tls |
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-7fr9-xww6-mfp3Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
