buzz icon indicating copy to clipboard operation
buzz copied to clipboard

Error 401 when building a profile

Open fredperes opened this issue 4 months ago • 2 comments

Describe the bug I'm trying to create a community and a profile. I get stuck in the "build your profile" step.

relay returned 401 Unauthorized: NIP-98: NIP-98 HTTP Auth verification failed: event timestamp outside ±60s window (delta: 109s)

Steps to reproduce

  1. Go to Create a community
  2. Click on next
  3. Fill an username
  4. See error

Version and platform Find your version at the bottom of the Settings sidebar. Write "unknown" if you can't determine it.

  • Buzz version: 0.5.1
  • OS: macOS 15.3.1

Logs / additional context Paste any relevant logs, error messages, or screenshots here.

fredperes avatar Jul 30 '26 14:07 fredperes

Reporting from a triage pass — this is a real-user clock-skew issue. The reporter's system clock was 109s behind the relay's, putting their NIP-98 sign time outside Buzz's hard-coded ±60s tolerance (crates/buzz-auth/src/nip98.rs:32).

Root cause

The ±60s tolerance is duplicated as a private constant in both nip98.rs and nip42.rs (and referenced in a comment in nip98_replay.rs). No config exposure. Internet NTP can easily drift 1–2 minutes on machines that sleep (laptops) or with manual clock set.

Why I haven't opened a PR

Widening the tolerance isn't a one-line change — it cascades into replay safety:

  • crates/buzz-auth/src/nip98_replay.rs:50 documents DEFAULT_REPLAY_TTL_SECS = 120 as covering 2× the timestamp tolerance — so a widened window needs a widened TTL (360s if we go to ±180s), or duplicate NIP-98 event ids can slip through the second-gate replay check.
  • Many Nostr relays also settle on a 5-minute window, but Buzz's exact value is a security invariant the maintainers should pin consciously, especially for self-hosted deployments.

Proposal (for maintainers)

If widening is acceptable:

  1. Make TIMESTAMP_TOLERANCE_SECS a single pub const in lib.rs (replaces the duplicated private constants).
  2. Widen to ±180s (covers realistic laptop-clock drift; still well under typical 5-min Nostr norms).
  3. Bump DEFAULT_REPLAY_TTL_SECS to 360s to preserve the 2× invariant.
  4. Improve the error message to surface the detected skew (event timestamp outside ±Ns window (delta: Ns)) — already there — plus a hint to the end user: (check your system clock).
  5. Update three tests: nip98::tests::expired_timestamp_rejected, nip42 equivalent, and any TTL-coupled assertions in nip98_replay.

In the meantime, reporter workaround: enable network time / run ntpdate -u pool.ntp.org (or on macOS sudo sntp -sS time.apple.com) and re-try the flow.

If the maintainers confirm ±180s is acceptable, I'll open the PR immediately.

iroiro147 avatar Aug 02 '26 08:08 iroiro147

Additional real-world report: this is a complete blocker for team adoption

I am hitting this error while inviting people into Buzz, not just while creating an initial profile.

What happened

  • I use macOS; the people I am inviting use Windows.
  • I can generate invitation links, but the invited people cannot complete entry into the community.
  • The error reported on our self-hosted relay was:
relay returned 401 Unauthorized: NIP-98 NIP-98 HTTP Auth verification failed: event timestamp outside +- 60 s window (delta: 69s)
  • I then created a new community hosted by Block and tried there. The same type of timestamp rejection occurred. Moving away from our self-hosted infrastructure did not resolve it.
  • The computers are configured for Brasilia time. I understand that timezone selection is different from clock synchronization; the affected Windows machines' actual clock offsets have not yet been measured. I am not claiming their clocks are synchronized merely because the timezone is correct.
  • Exact affected Windows/Buzz versions have not yet been collected.

Checks already performed

A diagnostic probe against our self-hosted relay used a throwaway identity and read-only queries; it did not redeem any invitation or add a member. A fresh NIP-98 signature passed timestamp verification and reached the expected membership rejection. Artificial offsets of ±69 seconds reproduced the timestamp error. Boundary tests at ±59 and ±61 seconds behaved consistently with the configured window. This checked the relay against the diagnostic Mac, not the invited Windows computers.

Why this blocks adoption

I need to invite a team using ordinary Windows and Mac computers. Requiring an administrator or manual clock-repair procedure on each affected person's machine is not a viable onboarding experience. A workaround for one computer is not a deployable solution for a team.

For our rollout, this is a complete adoption blocker. I cannot advocate for using Buzz in this state. I am not asserting that every invitation fails, but the failures we have already encountered are enough to prevent a reliable rollout.

This also compounds problems we have encountered with agent separation across relays/communities—another basic expectation for a multi-community workspace. That is a separate concern, not a claim that it causes this timestamp failure. Together, these problems undermine confidence in foundational behavior before we can even onboard the team.

What we need

  • A supported, reliable onboarding path across Windows and macOS, for both self-hosted and Block-hosted communities.
  • Detection and an actionable explanation of clock skew or stale signatures, rather than a raw protocol error that leaves users stuck.
  • A product-level remediation that does not make per-user administrator intervention the default answer.
  • A maintainer assessment and a clear fix/release plan for this failure mode. If authentication tolerance changes, replay protection and both HTTP/WebSocket authentication need to remain consistent; this is not a request to blindly disable security.

Related: #3133 demonstrates that automatic time synchronization can appear healthy while a Windows machine follows an incorrect upstream time source. Simply telling users to enable automatic time is therefore not always sufficient.

alm36918 avatar Oct 06 '26 18:10 alm36918