Menu
Meta Engineering·October 6, 2026

Meta's NTS: Building an Authenticated, Stateless Time Service at Scale

Meta discusses the implementation of Network Time Security (NTS) to provide authenticated time, addressing the long-standing vulnerability of unauthenticated NTP. The article details the stateless architecture for cookie management and key derivation, ensuring high availability and scalability while protecting against critical security risks like certificate invalidation and token expiry due to manipulated clocks. This system design is crucial for modern internet security where precise and verifiable time is a fundamental building block.

Read original on Meta Engineering

The Critical Need for Authenticated Time

NTP, a foundational internet protocol, has historically lacked authentication, making it susceptible to man-in-the-middle (MITM) attacks. This vulnerability is no longer merely an 'operational annoyance' but a critical security risk. Modern systems heavily rely on accurate and verifiable time for a multitude of security functions, making a secure time service a load-bearing component of any secure distributed system.

  • Certificate Validation: TLS certificates use `notBefore` and `notAfter` timestamps, which are useless without a trusted clock. Skewed clocks can lead to premature expiration or acceptance of expired certificates.
  • Token and Credential Expiry: The validity window of access tokens and credentials is directly tied to system time. A manipulated clock can extend token validity, creating security bypasses.
  • Replay Windows: Rejecting requests older than a certain threshold relies on an accurate local clock, preventing replay attacks.
  • Log Correlation: Discrepancies in host clocks lead to inconsistent and unreliable log timelines, severely hindering incident response and debugging in distributed environments.

NTS Architecture and Stateless Design

NTS (Network Time Security, RFC 8915) addresses NTP's lack of authentication by introducing a two-phase process: Key Establishment (NTS-KE) over TLS 1.3 and Authenticated NTP over UDP. A key architectural decision by Meta is to maintain a completely stateless server design for the NTP responses, even though NTS uses cookies.

  • Phase 1: Key Establishment (NTS-KE): A client connects to an NTS-KE server via TLS 1.3 to establish shared AEAD session keys and receive initial opaque cookies. This happens once, not per packet, to minimize overhead.
  • Phase 2: Authenticated NTP: Standard NTPv4 packets are exchanged, but now include NTS extension fields carrying a unique identifier, a cookie, and an authenticator. The server uses the cookie to recover session keys (without storing state), verifies the authenticator, and replies with a fresh, encrypted cookie and its own authenticator.

To avoid a distributed state problem, Meta's NTS implementation derives the cookie sealing key dynamically. Each server generates its sealing key from a shared master secret and the current 'epoch day' (Unix epoch divided by 24-hour periods). This allows any server to open any valid cookie without needing to replicate or share key rings, enabling horizontal scalability and high availability. This mechanism means NTS-KE servers and NTP responders can be different, disconnected machines, greatly simplifying deployment and scaling.

💡

Design Lesson: Statelessness for Scalability

The NTS cookie design demonstrates a powerful pattern for scaling distributed systems: offloading state to the client in an encrypted, verifiable manner. By making servers stateless regarding client sessions, system complexity is reduced, and horizontal scaling becomes trivial. This approach is highly resilient to failures and allows independent scaling of different service components.

NTSNTPTime SynchronizationAuthenticationStateless ArchitectureDistributed SecurityTLSInfrastructure

Comments

Loading comments...