RFC 9116 & squad-proto security design

Security & Cryptography Specification

SquadAir enforces end-to-end encryption over untrusted UDP networks and hardens its stateless rendezvous coordinator against amplification and brute-force attacks.

1. Cryptographic Primitives

Subsystem Primitive & Construction Scope
Media & Chat AEAD ChaCha20-Poly1305 Every voice frame, 1080p60 video fragment, chat message, inline image, and file chunk. Key derived from 256-bit room secret via BLAKE3 KDF with volatile stack zeroization.
Packet Nonce & AAD [peer_id:2B][type:1B][seq:8B][0x00] Deterministic 96-bit nonce bound to the 18-byte cleartext P2pHeader as Additional Authenticated Data (AAD) with 16-byte Poly1305 tag.
Friend Invites (sqf_) X25519 (Dual DH) + BLAKE3 + ChaCha20-Poly1305 Combines ephemeral-static and static-static X25519 shared secrets, rejecting weak all-zero outputs and binding sender, recipient, and ephemeral keys in 96-byte AAD.
6-Digit Codes & LAN Locks SPAKE2 (Ed25519Group) Password-Authenticated Key Exchange seals (room_id, secret) so neither an eavesdropper nor the coordinator can recover room keys.
Integrity & Identity BLAKE3 Derives AEAD subkeys, verifies 1024 B swarm file chunks against root hashes, and generates deterministic 5x5 visual identicons.

2. Replay Defense & Wire Framing

All P2P datagrams fit inside a 1200-byte UDP MTU (MAX_UDP_PAYLOAD = 1200) to avoid IP fragmentation. Incoming packets must pass AEAD tag verification before body decoding and are tracked per sender via sliding sequence bitmasks:

  • ReplayWindow (128 packets): Protects audio, chat, control, and file transfer streams against duplicate or replayed datagrams.
  • LargeReplayWindow (2048 packets): Accommodates high-throughput 60 FPS video fragment bursts and interleaved XOR-FEC recovery while rejecting stale replays.

3. Tier 3 Server Relay Anti-Amplification Hardening

When squad-rendezvous runs with opt-in --enable-relay for strict CGNAT voice fallback, multiple layers prevent UDP amplification, bandwidth exhaustion, and spoofed reflection:

  • Disabled by Default: Without --enable-relay, all relay datagrams are dropped silently at the socket boundary.
  • Strict Payload Cap (320 B): Any relay datagram larger than MAX_SERVER_RELAY_DATAGRAM_BYTES (320 bytes) is dropped before inspection.
  • Video & Bulk Transfer Blocklist: is_server_relay_allowed() blocks all screen-share opcodes (VideoFrameFrag, StreamAudioOpus, StreamSubscribe, StreamPli) and file-swarm opcodes at the header layer.
  • Exact Socket & Room Membership Validation: Both source IP:port and target peer_id must belong to the same active room_id within the 6-second heartbeat TTL, and self-relay is rejected.
  • Zero Reflection on Drop: Spoofed or unauthenticated relay probes produce zero outbound error packets and never allocate rate-limit state.
  • Token Bucket & Brute-Force Limits: Authenticated relay senders are capped at 150 packets/sec, signaling is capped at 30 packets/sec per IP (burst 45), and 5 failed 6-digit code attempts within 60 seconds block that IP for 60 seconds.

4. Release Integrity & Hardened Deployment

Every release published on GitHub Releases ships with SHA256SUMS.txt. The built-in client updater verifies downloaded release bytes in pure Rust over TLS using SHA-256 before launching platform installers. Self-hosted coordinator deployments support a hardened Docker configuration with read_only: true and cap_drop: ["ALL"].

5. Coordinated Vulnerability Disclosure

Report security issues directly to [email protected]

Please include reproduction steps, affected crate or release tag, and impact summary instead of opening a public GitHub issue for unpatched vulnerabilities. Machine-readable policy metadata is hosted at /.well-known/security.txt per RFC 9116.