Sets your clock from HTTPS servers through the Nym mixnet, without trusting any one of them
and without telling anyone on the network that this machine is checking the time. It asks a random handful of
independent HTTPS sites (Tor Project, Debian, Mullvad, RIPE, ...) for their Date header through Nym's
nym-socks5-client. Each answer becomes an interval that contains the true offset by construction, and it uses
the offset that a majority of the operators agree on. One Go binary, standard library only, MIT.
mixdate nym setup # starts nym-socks5-client on a random active exit gateway (port 1094)
mixdate check # how far off is the local clock? changes nothing
mixdate set # step the clock if the servers agree (root or CAP_SYS_TIME)
mixdate check --bootstrap # the clock is so far off that certificates look expired
mixdate probe # ask every server in the pool once, show who answers
mixdate servers # the default pool, one line per operator
$ mixdate check --simulate-skew -3h
asking 5 servers through the mixnet (certificates checked at local time)...
www.torproject.org Date 04:05:54 rtt 0.38s setup 1.6s offset in [+2h59m59.282s, +3h0m0.282s] (local-time)
duckduckgo.com Date 04:05:54 rtt 0.25s setup 1.4s offset in [+2h59m59.642s, +3h0m0.642s] (local-time)
tails.net Date 04:05:54 rtt 0.91s setup 1.0s offset in [+2h59m58.63s, +3h0m0.536s] (local-time)
proton.me Date 04:05:56 rtt 0.29s setup 2.6s offset in [+2h59m59.608s, +3h0m0.894s] (local-time)
www.kernel.org Date 04:05:55 rtt 0.24s setup 2.5s offset in [+2h59m59.795s, +3h0m0.795s] (local-time)
agreement: 5 of 5 answers overlap in [+2h59m59.795s, +3h0m0.282s]: www.torproject.org, duckduckgo.com, ...
local clock is 3h0m0.038s slow (true time = local +3h0m0.038s ± 0.243s), 3.9s
--simulate-skew -3h pretends the local clock is 3 hours behind (the real one was NTP-synced), which is what a
wrong clock looks like. Full log in examples/live-netns.txt.
Time sync is a beacon. An NTP client sends a packet to a time server every few minutes for as long as the
machine is on, in clear text, from your real IP. The server names often say which OS asked
(2.debian.pool.ntp.org, time.apple.com, time.windows.com), and the pool operators and everyone on the path
see when the machine is online and where it moved to. That's the one connection most people never think to hide.
Plain NTP is not authenticated. Anyone on the path can answer with a different time. A wrong clock is not
harmless: certificates and TOTP codes stop working or old ones start working again, revoked material comes back
into its validity window, logs and timelocks lie, and a skewed clock is a fingerprint of its own. NTS
authenticates NTP, but few servers offer it, and NTP is UDP: nym-socks5-client carries TCP streams only.
mixdate uses HTTPS instead. Every web server already says what time it is in the Date header of every
answer, and TLS keeps anyone in between from changing it. Asked through the mixnet, the servers see a Nym exit
gateway, not you; the exit sees which sites are asked, not the answers, and can't change them. No server gets
to decide the time alone: they have to agree.
Tails (htpdate) and Whonix (sdwdate) do the same over Tor, for the same reasons. mixdate is that idea for Nym,
with the answers turned into intervals and combined the way NTP combines its sources.
export MIXDATE_NYM_SOCKS5=/path/to/nym-socks5-client # official Nym release binary
go install github.com/apeirs/mixdate/cmd/mixdate@latest
mixdate nym setup # SOCKS5 on 127.0.0.1:1094 (--port to change; then set MIXDATE_PROXY)
mixdate check
sudo mixdate set # or: setcap cap_sys_time=+ep $(which mixdate)
Or point it at a Nym client you already run: mixdate check --proxy 127.0.0.1:1080.
Flags (mixdate check -h for all of them):
| flag | default | |
|---|---|---|
--servers N |
5 | how many servers to ask, at most one per operator, picked at random from the pool |
--min-agree K |
3 | the agreeing group must have at least K servers, and be a majority of those that answered |
--server HOST |
repeatable or comma-separated; replaces the pool (host or host:port) |
|
--rounds N |
2 | requests per server on one connection; the intervals are intersected |
--bootstrap |
off | check certificates at each server's own time instead of the local time (below) |
--timeout D |
30s | for the whole run |
--json |
machine-readable result, every sample included | |
-v |
print each server's line as it answers, not after the run | |
--threshold D |
1s | set only: don't touch a clock that is closer than this (or than the uncertainty) |
--max-step D |
none | set only: refuse to step by more than this |
--dry-run |
set only: say what it would do |
|
--simulate-skew D |
testing: pretend the local clock is off by D; set refuses it without --dry-run |
Exit codes: 0 when the servers agreed (and, for set, the clock was stepped or didn't need it), 3 when they did
not agree or too few answered, 1 for anything else. set steps the clock once with settimeofday; it does not
slew. If an NTP daemon (systemd-timesyncd, chrony) is also running it will fight mixdate; turn it off
(timedatectl set-ntp false) if mixdate is to be the clock's source.
Periodically: contrib/mixdate.service and contrib/mixdate.timer run mixdate set 2 minutes after boot and
every 4 hours, as a user mixdate that holds CAP_SYS_TIME and nothing else, against a Nym client on port 1094.
The units pass systemd-analyze verify; I have not run them on a machine whose clock they own.
- Pick servers. 5 from a pool of 25 HTTPS sites run by 25 different organisations (privacy projects, Linux
distributions, standards bodies, a few big companies), at most one per operator, at random each run. Each was
checked through the mixnet: it answers a plain
HEADwith a freshDate. Sites that served cached answers, needed a User-Agent, sent noDateor ran consistently seconds behind were left out (clock/run.gosays which and why). nym.com is not in the pool: the network you are routing through shouldn't be one of the votes. - Through the mixnet, by name. Each server is a SOCKS5 stream through
nym-socks5-clientwith the hostname (ATYP 3), so nothing is resolved locally: the exit gateway looks the name up. TLS is end to end with the server and verified for its name. There is no fallback: if the Nym client is not running, nothing is sent. - Ask twice. Two
HEADrequests on the one connection, each to a fresh random path (/?3f9a0c1d) withCache-Control: no-cache, and no User-Agent, cookies or anything else. An answer withAgeabove 0 came from a cache, not the server's clock, and is rejected. - An interval, not a guess. The server wrote
Datesomewhere between the moment the request left (sent) and the moment the answer's first byte came back (recv), andDateis truncated to the second. So the server's clock minus ours lies in[Date - recv, Date + 1s - sent], whatever the mixnet did in between. Delays, a slow exit or an exit that holds packets on purpose can only make the interval wider; they can't move it out from under the true offset. The two rounds are intersected: the tighter one wins, and if they don't overlap the server's clock jumped and the server is not used. - Agree. Marzullo's algorithm (the core of NTP's selection step) finds the smallest range that the largest
group of servers all allow. It counts only if that group has at least
--min-agreemembers and is a majority of those that answered. One server with a wrong clock, or two, is outvoted, and its name is missing from theagreement:line. The result is the middle of the range, ± half its width. - Bootstrap. With a clock far enough off, every certificate looks expired or not yet valid, and the normal
check fails with a hint to use
--bootstrap. Then each handshake completes without the time check, and the certificate chain is verified (same roots, same hostname) at the time the server's ownDategives. A certificate that wasn't valid at the time its server claims is still rejected, and so is one from an untrusted CA.
- Precision is about ±0.3 s.
Datehas one-second resolution; two rounds and five servers narrow it to a typical ±0.25-0.4 s. That's plenty for TLS, TOTP, Tor and wallets; it's not a replacement for NTP on a server that needs milliseconds. - It trusts the majority. If most of the servers it picks have wrong clocks, or are run by one attacker, the
answer is wrong. That's why it asks independent operators, picks them at random and requires agreement.
--serverreplaces the pool with yours;--servers 7 --min-agree 5asks for more. - Bootstrap is weaker. In bootstrap mode a server's certificate is checked at the time that server claims,
so a stolen key of an old, expired certificate could be used with a matching fake
Date. It would need that for a majority of the operators picked. Use bootstrap to recover a clock that is far off, not as the default. - The exit gateway sees which sites are asked and when (the hostnames, as SOCKS5 targets), and the size and timing of the TLS traffic. It can delay or drop answers: delays only widen the intervals, and drops make the run fail ("no agreement"), not return a wrong time. Nym's reply SURBs keep your mixnet address from the exit.
- The servers see a
HEADrequest to a random path from a Nym exit's IP, every time mixdate runs. - It steps, it doesn't slew. One
settimeofdayper run; programs that watch the wall clock see a jump.--thresholdkeeps it from touching a clock that is already close. - Speed. A run takes 3-9 s (stream setup plus TLS through the mixnet is 1-4 s per server, in parallel).
go test ./... runs 31 tests (23 top level, 8 cases) against a fake nym-socks5-client that records every
CONNECT and fake HTTPS time servers with a throwaway CA, whose clocks can be set ahead, behind, cached, delayed
or made to jump:
- every request goes through the SOCKS5 proxy, by name (ATYP 3); with the proxy down nothing is sent;
- two requests per connection, each to a different random path, with
no-cacheand no User-Agent or cookies; Age: 3600is rejected,Age: 0accepted; noDateis an error;- the interval math: wherever between send and receive the server stamped its answer, the true offset is inside; a 1.5 s delay widens the interval and it still holds the truth; a slow second round doesn't widen a fast first one; a server whose clock jumps 10 s between rounds is dropped;
- Marzullo: one liar out of five, touching ends, nested intervals, two against two (no majority);
- agreement needs a majority and at least
--min-agree; 2 of 3 with the default of 3 fails; - a certificate for another name is rejected; 400 days of skew gives the hint, and bootstrap gets the right answer; bootstrap still rejects a certificate that was expired at the server's own time, and an unknown CA;
- the CLI end to end:
checkagainst five fake servers (one lying), exit code 3 on no agreement,set --dry-run,--simulate-skewrefused byset,setwithout permission.
Every guard was then broken on purpose, one at a time in a copy of the tree (18 mutations: direct dial
instead of SOCKS5, User-Agent sent, no cache-busting, cached answers accepted, certificates not checked,
bootstrap without the chain check or at local time, Date resolution ignored, send and receive swapped, Marzullo
closing before opening at a tie, last round only, no majority, --min-agree ignored, two servers of one
operator, --simulate-skew allowed to set the clock, --max-step and --threshold ignored). A test failed for
every one of them (examples/mutate.py, results in examples/mutations.txt).
The Nym client used exit gateway node 1920 (DE). The test machine's clock was NTP-synced, so the right answer is "about 0".
36 candidate servers probed through the mixnet: 28 answered with a usable Date
(examples/live-probe-candidates.txt). That's where the pool and the exclusions came from: github.com's Date ran
1.7-8 s behind everyone else's in three probes, and several sites served Age > 0 answers even for a fresh path.
Ten runs in a row (examples/runs.sh, examples/live-runs.txt): 10 of 10 agreed, 50 of 50 servers
answered. Every result contained the true offset (0): the furthest was -0.210 s ± 0.307 s. Median uncertainty
±0.307 s, median run 5.7 s, slowest 8.6 s.
In a network namespace with no route out (examples/netns-check.sh, examples/live-netns.txt): unshare -rn gives a namespace with only loopback, where curl https://1.1.1.1 fails and there is no DNS. The only way
out is a Unix socket to the Nym client on the host. Inside it:
| run | result |
|---|---|
mixdate check |
5 of 5 agree, local clock +0.038 s ± 0.302 s, 6.6 s |
--simulate-skew -3h |
+3h0m0.038 s ± 0.243 s, 3.9 s |
--simulate-skew -9600h (400 days) |
every certificate rejected at local time, no agreement, exit 3, hint to use --bootstrap |
the same with --bootstrap |
+9600h0m0.098 s ± 0.299 s, 4.1 s |
set --dry-run --threshold 0s |
+0.229 s ± 0.489 s: within the uncertainty, not changed |
A leak or a clearnet fallback could not have worked in there.
Things the live runs taught the code: CDNs in front of some sites answer from cache with the origin's old Date
(hence the random path, no-cache and the Age check); one site was consistently seconds behind (out of the
pool); and a single server timing out held a run for 90 s (the default timeout is now 30 s, and a run uses the
servers that answered).
cmd/mixdate CLI: check, set, probe, servers, nym
clock intervals, Marzullo, sampling over the mixnet, server pool, settimeofday
mixnet SOCKS5 to nym-socks5-client, names sent to the exit, no fallback
nym set up and run the official nym-socks5-client
internal/fakes fake SOCKS5 proxy, CA and HTTPS time servers for the tests
contrib systemd service and timer
examples live logs, the mutation script, the namespace test
MIT