skip to content

NTP

Four timestamps give offset and delay, a stratum hierarchy spreads reference time, and selection rejects bad sources. Interviewers reach for it whenever expiry, logs or ordering depend on clocks.

on this pageshow

explore

questions

30

In plain NTP, why can an on-path attacker who shifts a client's clock make expired certificates and replayed tokens valid again?

level: juniorimportance: must knowfreq 32%

answer

  1. validity checks read the local clock
  2. backwards revives, forwards denies
  3. plain NTP is unauthenticated by default
  4. origin timestamp only stops off-path forgers
  5. authenticate the server, not just the packet

basics

~20 s

Certificate lifetimes, time-based one-time codes and replay windows all compare against the local clock. Plain NTP replies are unauthenticated UDP, so an attacker on the path can rewrite them and move the clock back until expired credentials pass again.

solid answer

~50 s

Nearly every security check that involves time compares a value with the local clock: a certificate's `notBefore` and `notAfter`, a time-based one-time code, a signed token's expiry, a replay window. RFC 7384 makes the point for NTP: certificate validation for TLS and IKEv2 needs roughly synchronised clocks, and a clock pushed back may let a node use a key that has already expired. In its standard configuration NTP runs over UDP with no authentication (RFC 8633). The client's origin-timestamp check discards forged replies from an off-path attacker who never saw the request, but an attacker on the path sees the request, copies that value and writes any time it likes; if it sits on the path to every server, the client's majority vote cannot help. The fix is to authenticate the server: Network Time Security (RFC 8915) for client-server mode, AES-CMAC symmetric keys (RFC 8573) for peers, plus several sources.

go deeper

for a junior

Recall that certificates, one-time codes and token expiry all read the local clock, and that plain NTP over UDP is unauthenticated by default.

for a middle

Explain why the origin-timestamp check stops an off-path forger but not an on-path one, and why moving the clock back and forward hurt in different ways.

for a senior

Show where several sources help and where they do not, and why a panic threshold ignored on every restart offers no protection.

for a principal

Weigh which systems need authenticated time at all, and what the organisation loses if every host trusts an unauthenticated path.

## Time is a security input Many controls that look unrelated to NTP quietly ask one question: *what time is it now?* The answer comes from the local system clock, and NTP is what sets that clock. RFC 7384 (Informational), the IETF's threat analysis for time protocols, says so directly: certificate validation requires sender and receiver to be roughly time synchronised, so protocols such as **TLS** and **IKEv2** depend on it, and if a time protocol is compromised a node may use a key that was already used in the past and has expired. | Control | What it compares with the clock | Clock moved **back** | Clock moved **forward** | |---|---|---|---| | Certificate validity | `notBefore` / `notAfter` | an expired certificate passes again | valid certificates look expired; connections fail | | Time-based one-time code | the current time step | codes captured earlier are accepted again | current codes are rejected | | Signed token or session expiry | the expiry claim | expired tokens are honoured | fresh tokens are refused | | Replay window keyed on timestamps | message timestamp against "now" | old captured messages fall back inside the window | legitimate messages fall outside it | Moving the clock back is the dangerous direction for **authentication**; moving it forward is a **denial of service**. Either way, whoever controls the clock controls these checks. ## What plain NTP gives an attacker on the path In its standard configuration NTP packets are exchanged unprotected; RFC 8633 (BCP 223) notes that an adversary able to become a man in the middle can drop, replay or modify them. NTP does have built-in sanity checks, and it is worth knowing exactly how far they reach: - **The origin-timestamp check.** RFC 5905 calls a reply *bogus* when its origin timestamp does not match the transmit timestamp the client sent, and discards it. That stops an **off-path** attacker, who never sees the request and must guess the value. RFC 8915 adds that the 64-bit origin timestamp is a weak nonce, since depending on the implementation most of its bits may be predictable; RFC 9109 makes off-path guessing harder still by recommending a randomised client source port. - **An on-path attacker sees the request.** It copies the transmit timestamp into its reply's origin field, so the forged reply passes the bogus check, and it can write any receive and transmit timestamps it likes. - **Several servers help only against bad servers.** The client's selection outvotes a minority of wrong sources, but RFC 8633 warns that if an attacker controls the network, the time from all servers could be compromised. An attacker on the client's own uplink is on the path to every server at once. - **Authentication is not correctness.** RFC 5905 itself notes that authentication in NTP does not necessarily imply the time is correct; it proves who sent the packet. ## The thresholds are not a defence by themselves RFC 5905 gives a **step threshold** (125 ms) and a **panic threshold** (1000 s): an offset beyond the panic threshold should make the client exit with a diagnostic rather than set the clock. That caps the size of one jump, not the direction of travel. RFC 8633 describes how it fails in practice: if a process supervisor restarts the client automatically and the client is configured to ignore the panic threshold on every restart, a large forged offset is simply accepted on the second start. Operators SHOULD NOT ignore the panic threshold on all cold starts. ## What closes the gap 1. **Authenticate the server.** For client-server mode use **Network Time Security** (RFC 8915): TLS-based key establishment, then authenticated NTP packets. For symmetric peers and broadcast, use pre-shared keys with **AES-CMAC** (RFC 8573), which deprecates MD5. 2. **Use at least four independent, diverse sources** (RFC 8633), so one wrong or compromised server is outvoted. 3. **Keep the panic threshold**, and require manual intervention for very large steps instead of accepting them silently after a restart. 4. **Monitor** for the signatures RFC 8633 lists: replies whose origin timestamp does not match, zero origin timestamps, and packets with invalid MACs. Even authenticated NTP leaves one gap: an on-path attacker can delay packets in one direction without changing a byte, and the error that adds is bounded by half the round-trip delay. Measuring durations inside an application with a monotonic clock rather than the wall clock is a separate, application-level concern.

  • Why doesn't NTP's origin-timestamp check stop an attacker who sits on the path?
    The check discards a reply whose origin timestamp differs from the transmit timestamp the client sent. An off-path attacker must guess that value, so its forgeries fail. An on-path attacker reads the request, copies the value into its reply and passes the check. Only a reply authenticated with a key the attacker lacks, as with NTS or a symmetric-key MAC, stops on-path forgery.
  • Does pointing a client at four public NTP servers protect it against this attack?
    Partly. Selection outvotes a minority of bad sources, so one compromised server is ignored. An attacker on the client's own uplink sits on the path to all four and can shift every reply together, and then the majority agrees on the wrong time. Diverse sources defend against bad servers; authentication defends against a bad path.

saying these in an interview costs you the question

  • NTP time cannot be tampered with because it comes from trusted stratum 1 servers.
  • Pushing a clock forward is harmless; only moving it backwards matters.
  • The origin-timestamp check already stops forged NTP replies from any attacker.
  • Using four unauthenticated NTP servers makes authentication unnecessary.
  • TLS certificate validation does not depend on the client's clock.
open as a page

Why does a computer clock left without NTP drift, and how far does a 50 PPM oscillator error move it in a day?

level: juniorimportance: must knowfreq 38%

basics

~20 s

A clock counts oscillator ticks, and no oscillator runs at exactly its nominal frequency, so the error accumulates. 50 PPM is 50 microseconds per second: 50 x 10^-6 x 86,400 s is about 4.3 seconds a day.

open as a page

What does an NTP server's stratum number tell you, and why is a lower stratum not the same as better time?

level: juniorimportance: must knowfreq 45%

basics

~20 s

Stratum counts how many NTP hops a server sits from a reference clock: 1 is a primary server, 2-15 are secondary servers, 16 means unsynchronized. It measures distance in the tree, not the size of the clock's error.

open as a page

In Network Time Security, how does NTS-KE give a client its keys and cookies, and why can the NTP server keep no per-client state?

level: middleimportance: must knowfreq 22%

basics

~20 s

NTS-KE runs TLS 1.3 on TCP 4460, exports two AEAD keys and hands the client cookies: those keys sealed under a server secret. Each NTP request carries one cookie, so the server recovers the keys from it and stores no per-client state.

open as a page

An NTP client records T1 = 1000, T2 = 1045, T3 = 1050 and T4 = 1055 ms; what are the delay and offset?

level: middleimportance: must knowfreq 38%

basics

~10 s

Delay is (T4-T1)-(T3-T2) = 55 - 5 = 50 ms. Offset is ((T2-T1)+(T3-T4))/2 = (45 - 5)/2 = +20 ms: the server is 20 ms ahead, assuming each leg took 25 ms.

open as a page

When an NTP client measures its clock offset, when does it slew and when does it step the clock, and why does that matter?

level: middleimportance: must knowfreq 32%

basics

~20 s

Below RFC 5905's 125 ms step threshold an NTP client slews, running the clock slightly fast or slow so time never jumps. In normal operation larger offsets are stepped only after persisting 900 s; beyond 1000 s it should exit.

open as a page

When one of an NTP client's two time servers starts serving time 3 s off, what does the client do, and why recommend four servers?

level: middleimportance: must knowfreq 35%

basics

~20 s

Two NTP servers that disagree cannot outvote each other, so the client finds no majority and stops correcting its clock from either. Four independent sources let a client still outvote one wrong server after another has become unreachable.

open as a page

An NTP exchange crosses a path taking 40 ms out and 10 ms back; how wrong is the computed offset, and why can the client not tell?

level: seniorimportance: must knowfreq 30%

basics

~20 s

The offset comes out 15 ms too high, half the 30 ms gap between the legs. The same four timestamps fit a symmetric path with another offset, so the exchange cannot reveal it; the error is bounded by half the 50 ms delay.

open as a page

Which of SNTP, NTPv4 or PTP fits each requirement - battery IoT sensors needing seconds, a trading venue's matching engines needing microseconds, a mobile fronthaul needing sub-microsecond phase - and why?

level: seniorimportance: must knowfreq 30%

basics

~20 s

Sensors needing seconds: an SNTP client. Trading engines needing microseconds: PTP with hardware timestamps and PTP-aware switches. Fronthaul needing sub-microsecond phase: PTP with every hop on-path. Full NTPv4 sits between, for servers needing milliseconds to a few hundred microseconds.

open as a page

Why does an NTP client not simply set its clock to the transmit time carried in the server's reply?

level: juniorimportance: should knowfreq 40%

basics

~20 s

The server's transmit time is already stale when it arrives, because the reply spent an unknown time crossing the network. NTP records four timestamps so the client can measure the round trip and assume each leg took half of it.

open as a page

Why do operators give an NTP client several time servers instead of one, beyond simply having a spare if one fails?

level: juniorimportance: should knowfreq 42%

basics

~20 s

With one server, an NTP client copies whatever error that server has and cannot notice it. With several, the client compares them, discards a server whose time disagrees with the majority (a falseticker) and averages the rest.

open as a page

What does an SNTP client leave out compared with a full NTPv4 implementation, and where in a time hierarchy is SNTP an acceptable choice?

level: juniorimportance: should knowfreq 30%

basics

~20 s

SNTP sends the same NTPv4 packets on UDP 123 but need not run the mitigation algorithms: clock filter, source selection and the discipline loop. RFC 5905 intends it for leaf clients with one server and no dependants, and for single-reference primary servers.

open as a page

In NTPv4 symmetric-key authentication, what does the per-packet MAC prove, and what does running it across a fleet cost?

level: middleimportance: should knowfreq 18%

basics

~20 s

The MAC proves a packet came from a holder of the shared key and was not altered; it says nothing about whether the time is right. RFC 8573 replaces MD5 with AES-CMAC, but keys still travel out of band, one per association.

open as a page

How does an NTP client choose its poll interval between MINPOLL and MAXPOLL, and why does it lengthen the interval once its clock is stable?

level: middleimportance: should knowfreq 25%

basics

~20 s

An NTP poll interval is a power of two seconds. RFC 5905 raises the exponent while measured offsets stay small relative to jitter and lowers it when they grow, so a stable clock polls rarely, averaging over longer spans and loading servers less.

open as a page

Why does an NTP client keep the last eight samples from each server and use the lowest-delay one rather than the newest?

level: middleimportance: should knowfreq 22%

basics

~20 s

Queueing delay is what corrupts an NTP offset, and it rarely hits both directions equally. Of the last eight samples, the lowest-delay one was queued least, so its offset has the smallest error bound; the newest may have been queued heavily.

open as a page

How do NTP's client-server, symmetric active/passive and broadcast modes differ in who synchronises whom, and where does each belong?

level: middleimportance: should knowfreq 22%

basics

~20 s

In client-server mode a client (mode 3) pulls time from a server (mode 4) that never takes time back; symmetric peers (modes 1 and 2) push and pull with each other; a broadcast server (mode 5) pushes time to listening clients.

open as a page

What does the NTP Reference ID field carry at each stratum, and how does it help a server avoid a timing loop?

level: middleimportance: should knowfreq 14%

basics

~20 s

The 32-bit Reference ID holds a kiss code at stratum 0, a reference clock code such as GPS at stratum 1, and the upstream server's identity above that. A server seeing its own address there knows that source follows it.

open as a page

Why do ordinary Ethernet switches degrade PTP accuracy, and how do PTP boundary clocks and transparent clocks each remove that error?

level: middleimportance: should knowfreq 15%

basics

~20 s

A switch queues each PTP message for a varying time, which lands in the slave's offset. A boundary clock terminates PTP and re-serves time from its own synchronised clock; a transparent clock forwards messages and adds each one's residence time to correctionField.

open as a page

How does PTP's best master clock algorithm choose a grandmaster, and what happens when that grandmaster loses its GNSS reference?

level: middleimportance: should knowfreq 15%

basics

~20 s

Every PTP clock compares the Announce messages it hears against its own data set, ranking priority1, then clockClass, clockAccuracy, variance, priority2 and clock identity. When the grandmaster loses GNSS its clockClass worsens, and a better-advertising backup can win.

open as a page

Why were NTP mode 6 and mode 7 queries usable for amplification, and how should a company's public NTP server be hardened against it?

level: seniorimportance: should knowfreq 15%

basics

~20 s

Mode 6 control and mode 7 private queries answer a small, spoofable UDP request with a much larger reply, so forged requests turn the server into an amplifier. Refuse them from outside, serve only time requests, rate-limit, and filter spoofed sources.

open as a page

After a company moves its laptops to Network Time Security, which attacks on their clocks still work, and how should the clients limit each?

level: seniorimportance: should knowfreq 12%

basics

~20 s

NTS stops forged replies, not delay: an on-path attacker can still hold packets in one direction (error up to half the round trip), drop them, forge NTSN kiss-o'-death replies, or push a naive client back to plain NTP. Clients should never downgrade silently.

open as a page

What does NTP's 64-bit timestamp hold, and what does its seconds field wrapping in February 2036 actually break?

level: seniorimportance: should knowfreq 14%

basics

~20 s

It holds 32 bits of seconds since 0h 1 January 1900 UTC and a 32-bit binary fraction. The 2036 wrap leaves offset and delay differences intact but makes a raw timestamp ambiguous as a date, because NTPv4 sends no era number.

open as a page

A cluster's NTP servers must cross a leap second; how does inserting the second differ from smearing it, and why must clients never mix the two?

level: seniorimportance: should knowfreq 22%

basics

~20 s

Inserting adds a 61st second to the month's final minute, announced by NTP's leap indicator. Smearing runs servers slightly slow for hours, so no second repeats. Mixed sources disagree by up to a second, which RFC 8633 forbids.

open as a page

When an NTP client in a VM resumes seconds off after live migration, how does discipline correct it, and when should stepping be allowed?

level: seniorimportance: should knowfreq 15%

basics

~20 s

A multi-second offset exceeds RFC 5905's 125 ms step threshold, so the client treats it as a spike and steps after 900 s; past 1000 s it should exit. A common policy steps at boot and alerts on later steps.

open as a page

After NTP's selection step leaves five truechimers a few milliseconds apart, how do the cluster and combine steps produce one offset and pick the system peer?

level: seniorimportance: should knowfreq 14%

basics

~20 s

NTP's cluster step repeatedly discards the survivor whose offset sits furthest from the others, until that stops helping or three remain; the combine step averages the rest weighted by inverse root distance, and the top-ranked survivor becomes the system peer.

open as a page

What do the NTP kiss-o'-death codes DENY, RSTR and RATE tell a client, and why must the client validate one before obeying it?

level: middleimportance: nice to knowfreq 8%

basics

~20 s

A kiss-o'-death is an NTP reply with stratum 0 and a four-letter code in the Reference ID. DENY and RSTR mean stop using this server; RATE means poll less often. It is usually unauthenticated, so clients obey one only if it matches an outstanding request.

open as a page

Why does an NTP client save its learned clock frequency to a file, and what happens at restart when that file is missing?

level: middleimportance: nice to knowfreq 10%

basics

~20 s

Measuring an oscillator's frequency error takes time. With a saved frequency, RFC 5905's discipline starts in FSET and disciplines at once; without one it starts in NSET and spends the 900 s stepout interval measuring frequency first.

open as a page

Why can NTP's majority-based source selection not protect a client whose servers are mostly attacker-controlled, and what does Khronos (RFC 9523) change?

level: seniorimportance: nice to knowfreq 6%

basics

~20 s

NTP's selection outvotes a minority of bad servers but follows a majority, so an attacker controlling most of a client's few servers can shift its time. Khronos, an Informational watchdog, samples random servers from a large pool and trims outliers.

open as a page

An NTP client shows stratum 3, root delay 0.8 ms and root dispersion 1.2 ms; what error bound do these give, and how did they accumulate?

level: seniorimportance: nice to knowfreq 10%

basics

~20 s

Root synchronization distance is root dispersion plus half the root delay: 1.2 + 0.8 / 2 = 1.6 ms, RFC 5905's bound on the client's error from all causes relative to the primary reference, assuming that reference itself is right.

open as a page

Why can't an NTPv4 server normally put its hardware transmit timestamp into the reply it is sending, and how do RFC 9769 interleaved modes fix that?

level: seniorimportance: nice to knowfreq 8%

basics

~20 s

A hardware transmit timestamp exists only after the packet has left, too late to write into it. RFC 9769 interleaved modes have the server send, in its next reply, the precise transmit timestamp of its previous reply, keyed by the origin field.

open as a page