infrastructure audit
Guide for infrastructure audit
Infrastructure Audit: Zone Tokens & Tick Sync
Zone Token TTL
Status: ✅ SECURE
The
TransferToken implementation in logic-core/src/zone_manager.rs enforces Time-To-Live (TTL) correctly.Mechanism
- Tokens are created with a
timestamp. TOKEN_EXPIRY_SECONDSis set to 60 seconds.validate()method explicitly checks:if now - self.timestamp > Self::TOKEN_EXPIRY_SECONDS { anyhow::bail!("Transfer token expired"); }- Redis is used for Anti-Replay (tokens are deleted after use).
- Redis keys also have a TTL (
SETEX) to auto-expire unused tokens.
Client Tick Drift
Status: ⚠️ KNOWN ISSUE
Problem
The client and server run independent game loops.
- Server runs strict 600ms ticks.
- Client attempts to run at 600ms but relies on
requestAnimationFrameorsetTimeoutwhich are subject to browser throttling and lag. - Over time, or during lag spikes, the client's tick count desynchronizes from the server's.
Consequences
- Animations may play out of sync.
- Prediction logic (where client predicts movement) may be corrected by server "snaps" (rubber-banding).
- Timers on client (e.g., potion duration) may drift from server reality.
Recommended Fix (Future Work)
Implement a Server Authoritative Tick Sync packet:
- Server includes
server_tickin everyGamePacket. - Client adjusts its local
client_tickto matchserver_tickif drift > 1 tick. - Client speeds up or slows down loop to catch up smoothly (tick rate adjustment).