Nonce
A value that must be used only once in a given context, such as per key in an AEAD or per request in a replay check.
A nonce (number used once) gives freshness or uniqueness. In AEAD ciphers it makes encrypting the same plaintext twice produce different ciphertexts; it does not need to be secret or random, only unique per key. In protocols it proves a response is fresh (OIDC nonce, attestation challenges, request signing). In CSP it marks which inline scripts the server intended to run.
Requirements differ by use. AES-GCM needs uniqueness per key, and a single repeat is fatal. A CSP nonce must be unpredictable and regenerated on every response, or an attacker can reuse it. A replay-protection nonce must be remembered by the server for as long as the request could be accepted, which is why replay caches pair nonces with a timestamp window.
Where it goes wrong: random nonces that are too short, counters that reset after a restart or are shared by two writers, CSP nonces cached in a CDN page, and replay caches that expire entries before the timestamp window closes.
Learn it properly
Compared
Also used in
- Cryptography you actually needSecEng · Foundations of Security EngineeringFree
- Identity: authentication, authorisation and tokensSecEng · Foundations of Security EngineeringFree
- AI in the security SDLCSecEng · AI, vibe coding & logic structuringFree
- The bugs that actually shipSecEng · Application Security & DevSecOpsFree
- Key rotation and crypto agilitySecEng · Applied cryptography engineeringFree
- Design an MFA and step-up serviceHLD · Design problems: Access & identityFree
- Design a secure file sharing serviceHLD · Design problems: communication securityFree
- Data protection: KMS, envelope encryption, tokenisationSecEng · Cloud & Platform SecurityPro