Commit f6a8c5b
committed
Fix race condition between 0-RTT and Incoming
Closes #1820
The fix:
- Endpoint now maintains a slab with an entry for each pending Incoming
to buffer received data.
- ConnectionIndex now maps initial DCID to that slab key immediately
upon construction of Incoming.
- If Incoming is accepted, association is overridden with association
with ConnectionHandle, and all buffered datagrams are fed to newly
constructed Connection.
- If Incoming is refused/retried/ignored, or accepting errors,
association and slab entry are cleaned up to prevent memory leak.
Additional considerations:
- The Incoming::ignore operation can no longer be implemented as just
dropping it. To help prevent incorrect API usage, proto::Incoming is
modified to log a warning if it is dropped without being passed to
Endpoint::accept/refuse/retry/ignore.
- To help protect against memory exhaustion attacks, per-Incoming
buffered data is limited to twice the receive window or 10 KB, which-
ever is larger. Excessive packets silently dropped.
- Does this introduce a new vulnerability to an attack in which an
attacker could spam a server with 0-RTT packets with the same
connection ID as it observed a client attempting to initiate a 0-RTT
connection to the server? I do think so.
Is this a severe problem? Here's two reasons I don't think so:
1. The default receive window is set to max value, so this won't
actually kick in unless the user is already hardening against
adverse conditions.
2. It is already possible for an on-path attacker to distrupt a
connection handshake if 0.5-RTT data is being used, so this
probably doesn't actually expand the set of situations in which
it's vulnerable to this kind of vulnerability.
Could this be avoided? Possibly by introducing additional state to
the buffering state to validate whether these packets are validly
encrypted for the associated connection? However, that may risk
making these operations costly enough that they start to defeat the
DDOS-resistance abilities of the Incoming API.1 parent 82a67db commit f6a8c5b
5 files changed
Lines changed: 166 additions & 53 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
989 | 989 | | |
990 | 990 | | |
991 | 991 | | |
992 | | - | |
| 992 | + | |
993 | 993 | | |
994 | 994 | | |
995 | 995 | | |
996 | 996 | | |
997 | 997 | | |
998 | | - | |
| 998 | + | |
999 | 999 | | |
1000 | 1000 | | |
1001 | 1001 | | |
| |||
3346 | 3346 | | |
3347 | 3347 | | |
3348 | 3348 | | |
3349 | | - | |
| 3349 | + | |
3350 | 3350 | | |
3351 | 3351 | | |
3352 | 3352 | | |
3353 | | - | |
| 3353 | + | |
3354 | 3354 | | |
3355 | 3355 | | |
3356 | 3356 | | |
| |||
0 commit comments