H5: Security review, and fixes for connection-slot exhaustion
docs/SECURITY_REVIEW.md lists the scope, nine findings and what was done. - High, fixed: a peer that connects and stops answering kept its ENet slot for up to 15 s after being turned away, so one address could fill every slot. Flood refusals now disconnect at once (reason in the disconnect data, which NetClient now honours for REASON_BUSY), peers told to leave get 1 s to acknowledge, and when slots run short the longest-waiting silent guest makes room. - Medium, mitigated: ENet holds half-open slots for spoofed CONNECTs that the script never sees. The host now has 512 slots (NetServer.peer_slots). - Medium, fixed: SourceLimiter, handshakes per source and the list server's per-address cap count an IPv6 /64 as one source. - Low, fixed: CommandLog refuses a header with non-numeric fields instead of raising errors. - tools/godot.sh unsets DISPLAY and WAYLAND_DISPLAY so the engine's error alerts can never reach the host desktop. - A test fixture's 10.0.0.9 is now the documentation address 192.0.2.9. Tests: 4 new handshake tests with real non-acknowledging ENet peers, test_source_limiter (3), a CommandLog type test. make check, make fuzz, make client-check, make discovery-check and make soak-selfcheck pass. Closes #58 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+13
-6
@@ -160,13 +160,14 @@ People join a server three ways, none needing a third-party service:
|
||||
a CHALLENGE carrying a token derived from a per-start secret and the sender's
|
||||
address and port, and lists the server only when a REGISTER echoes it. Servers are
|
||||
listed under the address their packets come from, never a claimed one. Entries
|
||||
expire after 45 s, with at most 8 per address and 256 in all. Clients ask for the
|
||||
expire after 45 s, with at most 8 per address (per /64 for IPv6) and 256 in all. Clients ask for the
|
||||
list four servers per page, one page after another.
|
||||
|
||||
The messages are in `NetDiscovery`. Every QUERY is padded to 512 bytes and no answer
|
||||
is larger, so neither the beacon nor the list server can amplify a spoofed request.
|
||||
Both rate-limit each source address (`SourceLimiter`: 20 packets a second, at most
|
||||
4,096 addresses tracked per second).
|
||||
Both rate-limit each source (`SourceLimiter`: 20 packets a second, at most 4,096
|
||||
sources tracked per second). A source is an IPv4 address, or an IPv6 address's whole
|
||||
/64, since one ordinary connection is handed a /64 (H5).
|
||||
|
||||
**Lobby, backfill and late arrivals.** People who connect during the lobby or the
|
||||
countdown take places (`Match.join()`); bots are only added when the match starts,
|
||||
@@ -199,9 +200,15 @@ likes. The server's defences, and the tests that attack them
|
||||
commands and an exact length, or it is dropped whole. At most 32 game packets per
|
||||
player are kept per poll. Anything on the control channel after the handshake is
|
||||
dropped.
|
||||
- **Bounded connections.** At most 32 new connections per address per 10 s and 8
|
||||
handshakes in progress per address (`REASON_BUSY`), a 5 s handshake timeout, and
|
||||
ENet's own peer limit.
|
||||
- **Bounded connections.** At most 32 new connections per source per 10 s and 8
|
||||
handshakes in progress per source (`REASON_BUSY`), and a 5 s handshake timeout.
|
||||
No slot is left to a silent stranger for long (H5): a connection turned away for
|
||||
flooding is dropped at once, with the reason only in the disconnect's data; a peer
|
||||
told to leave has 1 s to acknowledge before it is cut off; and when ENet's slots
|
||||
run short, the guest that has waited longest for its HELLO makes room. The host
|
||||
has 512 slots whatever the player limit, because ENet takes a slot for every
|
||||
CONNECT before the sender has proved its address and never reports those
|
||||
half-open slots to the script; see docs/SECURITY_REVIEW.md.
|
||||
- **Parsers.** Every decoder refuses malformed input by returning an empty result,
|
||||
never by raising an error. `make fuzz` feeds 1,000,000 mutated and random messages
|
||||
to all of them, the snapshot receiver and the list server, and checks for engine
|
||||
|
||||
Reference in New Issue
Block a user