Skip to content

Get the clock through Tor onion services and remove NTP and the clearnet htpdate fallback #4149

Open

Description

@pithead-developer

What's the problem

The owner ruled (2026-11-16) that time comes from onion-service pools in the sdwdate style, written as a small client, with HTTPS through exits only as a fallback, and no NTP. Today the box gets time from NTP and a clearnet HTTP fallback:

  • systemd-timesyncd is installed and enabled (os/rootfs/Dockerfile:66,300) and speaks NTP to DHCP-supplied or built-in servers on UDP 123.
  • pithead-firstboot.service:33 and pithead-setup-again.service:36 run htpdate -s www.debian.org unless NTPSynchronized=yes. Once timesyncd is gone that clause always runs, as plain HTTP over local DNS. setup-again also runs on provisioned boxes and rigs, so this is a recurring leak, not only a first-boot one.
  • The htpdate package is installed (Dockerfile:75). Whether its unit is enabled in the built image is not checked (the check is in Truth first: log-only egress firewall, netwatch in a KVM leg, honest dashboard labels, egress map as data #4145 (step 1: log-only firewall and netwatch)).
  • The doctor reads NTPSynchronized (05-doctor-checks.sh:62) and tells the owner to "make sure NTP is running" (06-doctor.sh:83), which a Tor time source never satisfies.
  • Units order against systemd-timesyncd.service (pithead-firstboot.service and pithead-setup-again.service Wants=/After=, and pithead-boot.service).
  • A clock that is far ahead stalls Tor bootstrap with no repair.

What it impacts

  • Every boot on both roles: clock accuracy for Tor, TLS, RAUC certificate checks, and chain consensus. Tari is the tightest: RFC-0120 gives a 540 s future limit (from the RFC, the code constant was not read). Monero allows 2 h ahead and P2Pool's only tolerance found is hours wide. Tor bootstraps within roughly a day of skew per informal 2019 tests on Tor 0.4.1, to be re-measured on today's Tor.
  • The first-boot wizard, the setup-again wizard and the doctor.
  • Rigs: independent of Pithead, they get time through their own Tor client.
  • Owners whose clock is far ahead cannot be fixed automatically and need manual entry.

How I found it

The 2026-11-15 and 2026-11-16 research passes on Tor-compatible time and on the egress inventory, each checked by a second reader. Corrections applied: the skew tolerance figures come from the tor-dev 2019 testing thread; stock htpdate verifies certificates only with -c and defaults to plain HTTP, and fails on a clock that is behind, so it cannot be used as is. I re-read pithead-firstboot.service:33 and pithead-setup-again.service:36 on origin/develop and confirmed the clause. Nothing was tested live.

How important is it

High for 2.0.5, and it must ship in one change. Removing timesyncd or the fallbacks without the new client makes every wizard boot fall back to plain HTTP before Tor exists. It follows #4148 (step 4: DNS through Tor) and precedes #4154 (step 9: enforce the firewall), which drops UDP 123.

Acceptance criteria

  • A small time client uses three source groups of onion-service servers, picks one source at random in each, and takes the median of their Date values.
  • It rejects an answer outside Tor's consensus validity window (valid-after to valid-until) or below the monotonic floor, which is the maximum of the saved good time, Tor's cached consensus time and the build date. It steps the clock once when the offset is above a documented threshold and slews otherwise, never goes below the floor, and persists the new floor after every accepted result.
  • It re-checks every few hours. The doctor reports the age of the last accepted stamp, with a warning and a failure threshold, instead of NTPSynchronized, and the "make sure NTP is running" text is gone.
  • HTTPS Date headers fetched through Tor exits are used only if the onion groups cannot give a quorum. Any fallback use is logged and shown on the doctor. No NTP, no plain HTTP, and no clearnet fallback in any case.
  • NTP= and FallbackNTP= are empty, UseNTP=no is set, the htpdate package is removed and the unit is masked or absent in a built image (systemctl is-enabled htpdate is asserted), and nothing orders against timesyncd. A capture across first boot, reboot, update, setup-again and an hour of mining shows no UDP 123 and no direct HTTP.
  • The firstboot and setup-again units no longer call htpdate or NTPSynchronized, in the same change that removes timesyncd; the wizard does not block waiting for time, and boots on the saved clock until Tor is up.
  • CLOCK_SKEW from Tor is detected, no clearnet fallback is attempted, and the wizard and the rig console say so plainly and offer manual time entry for a far-ahead clock. The manual value is checked against the floor and the build date.
  • Works on rigs through the rig Tor client (Rig Tor client: persistent state, runs as debian-tor, control socket, shared by updates, time and probes #4151 (step 6: rig Tor client)), including a rig with Tor stopped between checks.
  • Boots with a wrong RTC are tested: a 1970 clock, a clock days behind and a clock hours ahead. Behind and 1970 recover without clearnet; far ahead fails safe.
  • Through [benchmark] Stability and mining impact of Tor-only egress #4155 (benchmark) (hours per arm, at most 24 h per run, no multi-day soak): offset against a reference clock over each arm, boot-to-good-time, source failure rate per group, client CPU and memory, Tor bootstrap success per RTC fault, and the stability of monerod, Tari and P2Pool (no block or share rejected for time, no timestamp warnings), with hashrate and shares within the noise band of the control arm.

Possible solutions

  • Write the client as a small script, not a port: sdwdate is AGPL-3+ and not in Debian, so use its design, not its package. Keep Whonix's practice of keeping Debian domains out of the pools so one outage does not break both time and apt.
  • Floor sources: timesyncd's clock file is not available once it is gone, so the client writes its own stamp; Tor's persistent data directory already holds a cached consensus whose valid-after is a usable floor.
  • Detect skew by starting Tor with networking disabled and watching its control port for CLOCK_SKEW; use the loopback control listener, since Harden the Tor container: SOCKS policy, SafeSocks, dedicated ports, no bridge control listener #4152 (step 7: Tor hardening) may remove the bridge one.
  • Rig surface for manual time entry (console prompt or a documented command) is to be decided.
  • Unknowns: how many onion servers expose a usable Date header with good availability; how much skew today's Tor really tolerates; whether the rig boards have a usable RTC.

Sibling work: #4144 (tracker), #4148 (step 4: DNS through Tor), #4151 (step 6: rig Tor client), #4154 (step 9: enforce the firewall). Related: #4143, #4139.

Activity

  1. added this to the v2.0.5 milestone on Nov 16, 2026
  2. added
    security
    appliance
    operator-action
    on Nov 16, 2026
  3. added
    blocked
    on Nov 16, 2026
  4. pithead-developer commented on Nov 16, 2026

    @pithead-developer
    ContributorAuthor

    Blocked on #4148.

    Step 5 of the rollout order in #4144: it follows step 4. It still lands in the same change that removes timesyncd and the htpdate fallbacks.

  5. removed
    operator-action
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    applianceblockedsecurity

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions