Description
Harden the networking layer with replay protection, rate limiting, and per-action player verification. Current auth (PocketBase token) and AEAD encryption (AEGIS-256/ChaCha20-Poly1305) with serialization bounds checking are solid, but the application layer lacks replay detection (no sequence numbers), per-action player ID verification, rate limiting (client could spam actions), and periodic token refresh for long games.
Steps
- Add
SequenceNumber (uint64_t) to NetworkEvent, track LastSeenSequence in PeerState, reject packets with seq <= last seen
- Add
PlayerID field to BuildTowerPayload and SendCreepPayload, server verifies it matches sender
- Add per-peer rate limiting: max actions per tick, drop excess, reset counter each tick
- Consider periodic token refresh for games > N minutes
- Update fuzzer corpus entries for new packet format
Description
Harden the networking layer with replay protection, rate limiting, and per-action player verification. Current auth (PocketBase token) and AEAD encryption (AEGIS-256/ChaCha20-Poly1305) with serialization bounds checking are solid, but the application layer lacks replay detection (no sequence numbers), per-action player ID verification, rate limiting (client could spam actions), and periodic token refresh for long games.
Steps
SequenceNumber(uint64_t) toNetworkEvent, trackLastSeenSequenceinPeerState, reject packets with seq <= last seenPlayerIDfield toBuildTowerPayloadandSendCreepPayload, server verifies it matches sender