Bounty
XE-0100 · Bounty

Directory registrations have no freshness check: far-future timestamps are immortal

Closed · duplicate —claimed Medium xe#169 filed 2026-10-29 04:37 UTC by 0xMissy22

Report

Directory registrations have no freshness check: far-future timestamps are immortal

Summary

directory/verify.go checks fields, key derivation, and signature but never timestamp freshness — unlike chat, which enforces a 5-minute skew window. directory.go expires entries only on now − ts > TTL, so a future timestamp never expires and never prunes; the monotonic rule then rejects all later normal re-registrations for that account while the API still answers ok: true. Directory.Remove is never called anywhere in the codebase, so no operator remedy exists at any layer.

Impact

Two honest halves, kept separate:

  • Mass immortal self-registrations are a Track-2 memory-growth vector: the directory map is uncapped, measured at ~498 bytes per entry, so ~50 MB per 100,000 immortal entries per node, multiplied by gossip fan-out. Growth is per distinct account — each entry needs its own valid keypair and signature, which is cheap ed25519 key generation but not per-message.
  • Victim self-lock via clock skew is an accidental footgun, not an attacker primitive: forging a victim's entry requires the victim's key (proven below — both forgery shapes are rejected), so an attacker cannot lock someone else out this way. A victim whose clock jumps forward can, however, lock itself out of its own directory entry with no remedy.

Suggested program tier: Medium (validation gap).

Root cause

  • directory/verify.go VerifyRegistration (function body ~lines 31-57): checks only missing fields, core.VerifyPayloadKey (the pubkey must derive the account), and the ed25519 signature over canonical bytes (account + pubkey + nodepeer + timestamp). No time comparison anywhere in the function.
  • directory/directory.go expiry logic (Lookup/List/Prune region): Lookup keeps an entry when `time.Since(time.Unix(0, reg.Timestamp))

    d.ttlis false — negative for a future timestamp, so the entry is kept;Pruneremoves only whennow - reg.Timestamp > ttl` — negative for future timestamps, so 0 are pruned.

  • directory/directory.go monotonic rule in Register: if ok && existing.Timestamp >= reg.Timestamp { return nil } — a later normal re-registration is silently dropped with a nil error.
  • api/directory.go handleDirectoryRegister maps a nil Register error to HTTP 200 {"ok": true} — so the silent drop is confirmed to the caller as success. This was verified literally, not figuratively.
  • Directory.Remove (defined at directory.go:68) has zero callers in production code and zero in tests, and api/directory.go exposes only Register/List/Lookup — no delete endpoint.
  • Contrast that proves the omission: chat/envelope.go:19 MaxEnvelopeSkew = 5 * time.Minute, enforced in both directions at envelope.go:92. Directory has no equivalent.
  • Gossip amplification, traced in code: node/node.go selfRegister (2359-2374: local Register + DirGossip.Publish) → net/gossip.go DirectoryGossip.Publish (421-426: bare JSON marshal, no validation) → Subscribe (429-461: only checks Account/Signature non-empty, never calls VerifyRegistration) → node/node.go handleDirectoryGossip (2376-2384: Directory.Register on receipt). Strongest link: directoryReRegisterLoop (2399-2423) re-publishes the victim's own stored entry every TTL/2 — since a future entry never expires, the victim's node re-seeds the immortal entry to peers forever.

Proof of concept

Target: xeprotocol/xe @ 978785929bc17a2f4ab30c383e5fc9cf4d634512 (2026-10-15). Harness rebuilt from the dossier steps for re-validation (the original scratch harness was deleted after use); it uses real keypairs via core.GenerateKeyPair plus directory.NewRegistration, the same path as production selfRegister. The repository itself is not modified.

Attached PoC: pocs/f07-reval-test.go.txt, byte-identical copy of the runnable source.

Run (Go 1.25.14):

export PATH="$HOME/.local/go/bin:$PATH"
GOPROXY=off go test ./directory/ -run 'TestF07' -count=1 -vet=off -v

Observed output (verbatim, re-validation run 2026-10-29):

=== RUN   TestF07Reval
    f07_reval_test.go:36: lookup after future register: ok=true ts=+100y
    f07_reval_test.go:42: prune: pruned=0
    f07_reval_test.go:56: re-register: err=nil (API would answer ok:true), stored ts STILL +100y (silently dropped)
--- PASS: TestF07Reval (0.02s)
=== RUN   TestF07GossipReceiverMirror
    f07_reval_test.go:85: peer retains future entry, rejects fresh re-registration (monotonic rule)
--- PASS: TestF07GossipReceiverMirror (0.00s)
=== RUN   TestF07ForgedVictimRejected
    f07_reval_test.go:100: forged key binding rejected: registration key: public key does not derive account c002b07b…
    f07_reval_test.go:110: forged victim signature rejected: signature verification failed
--- PASS: TestF07ForgedVictimRejected (0.02s)
=== RUN   TestF07MemoryShape
    f07_reval_test.go:139: map uncapped: len=100000 after 100000 inserts; heap delta/entry=498 bytes
--- PASS: TestF07MemoryShape (2.97s)
PASS

Reproduction steps

  1. Register a directory entry with ts = now + 100 years (valid key and signature).
  2. Observe: the entry never expires, never prunes.
  3. Re-register normally → silently dropped, while the API still answers ok: true.

Recommended fix

Reject timestamps beyond a small future skew (mirror chat's 5-minute rule) and wire an operator removal path.

Severity

  • CVSS 3.1: 6.5 — CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L
  • CWE-20 (Improper Input Validation)

Caveats

  • Gossip amplification rests on the traced loop plus the receiver-executed mirror test above, not on a live two-node run: delivery is generic pubsub and the security-relevant receiver behavior (retain + reject fresh) is fully executed, but two live nodes were not paired for this report.
  • The memory figure is a measured storage shape (bulk map insert of realistic entries); the per-entry validity requirement (own keypair + signature) is proven separately by the forgery-rejection test, not inside the bulk insert.
  • The victim self-lock half is a footgun, not an attacker primitive, and is not claimed otherwise: both forgery shapes (wrong key binding, wrong signature) are rejected verbatim above.
  • No public prior report of the chat/directory mechanisms was found (dedup query Q5 recorded in the audit's DEDUP-BASELINE.md).
  • This reproduction runs against the repository code at the stated HEAD. No testnet transactions were sent as part of this report.

Payout address (XE): eff2c51dd8457df740b919226cd9b37a2944e5abea7501094db80234f87f010e

Best, Chaplin

f07-reval-test.go.txt

Thread

Joseph Denneteam2026-11-05 22:19 UTCgithub

Thanks. This is the same finding as https://bounty.xe.network/XE-0097, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, reply with what differs and we will look again.