Replay Protection & Cache
Phantom Grid SPA V2 implements robust defenses against Replay Attacks.
The Replay Cache
The Verifier module (verifier.go) maintains a high-performance, thread-safe cache of all successfully authenticated SPA packets.
- Hashing: Upon receiving a valid SPA packet, its cryptographic payload is hashed using SHA-256.
- Storage: The hash is stored in a concurrent
sync.Mapalong with a timestamp. - Verification: When a new packet arrives, its hash is checked against the cache.
- Expiration: Hashes are automatically purged from the cache after 5 minutes (matching the maximum TOTP skew window).
This ensures that even if an attacker sniffs a valid SPA UDP packet, sending it again will result in an immediate rejection.
