buzz icon indicating copy to clipboard operation
buzz copied to clipboard

Desktop: client clock a few tens of seconds fast breaks every image silently (media read token allows only +5s skew)

Open Eight8Kane opened this issue 1 month ago • 0 comments

Summary

On a Windows desktop whose system clock ran ~36 s fast, every image in every channel rendered as a broken image, with no error or hint. Chat, sending and uploads kept working, so nothing pointed at the clock. Syncing the Windows clock fixed it immediately.

This is the read-side counterpart of #4075 (uploads, explained by #6929): the failing request here is the media GET that the desktop's loopback media proxy makes, and its failure is invisible — the <img> just breaks.

Why only images break

  • The desktop loads relay media through its loopback proxy (http://127.0.0.1:<port>/media/...), which attaches a Blossom read token (kind 24242, t get, expiration = created_at + 60).
  • The relay verifies that token in strict mode with created_at <= now + 5s (crates/buzz-media/src/auth.rs, freshness bounds).
  • NIP-42 and NIP-98 tolerate ±60 s, so the WebSocket session, message sends and the HTTP bridge all keep working with a clock that is 6–60 s fast.

So any client clock between roughly +5 s and +60 s ahead gives a working chat with every image broken.

Evidence (self-hosted relay, image sha-e982f70, Desktop on Windows)

  • Relay metrics: http_requests_total{action="/media/{sha256_ext}",code="401"} rose by exactly the number of media GETs from the affected desktop (12 in a 5-minute window), while other members' GETs returned 200.
  • Decoding the Authorization: Nostr tokens of those 12 requests: created_at was consistently +36 s ahead of the arrival time. Other clients: 0–3 s.
  • The relay logs nothing for these denials at the default info level, so the operator also sees nothing.
  • After the user pressed "Sync now" in Windows date & time settings, images loaded.

Suggestions

  1. Desktop: when the media proxy gets a 401 from the relay, compare the local clock against the relay's Date header (the same approach as #6929) and show a "your system clock is N s ahead" banner, instead of passing the bare 401 to the <img>.
  2. Relay (optional): log media read denials with their reason (e.g. created_at in future by 36s), at least at debug, so operators can diagnose without packet captures.
  3. Possibly reconsider the 5 s future bound for read tokens, or align it with the ±60 s used by NIP-42/NIP-98. A mismatch of 5 s versus 60 s is what makes this failure look so unrelated to the clock.

Eight8Kane avatar Oct 27 '26 08:10 Eight8Kane