Bounty
XE-13387 · Bounty

[SDK] src/attestation.ts wraps out-of-range int64 timestamps, evicts honest timekeeper endpoints on /node spoofing, and accepts duplicate-key quorums

Closed · duplicate — xe#546 filed 2026-11-13 10:39 UTC by Khanhtnq

Report

Summary

src/attestation.ts diverges from Go ledger consensus (core/attestation.go) and allows quorum/discovery bypasses across four coupled paths:

  1. Out-of-range int64 timestamp wrapping in attestationPayload, verifyAttestation, and attestedTime:
    • Go consensus (core/attestation.go) strictly enforces 0 <= timestamp <= math.MaxInt64 (9223372036854775807).
    • attestationPayload called u64be(BigInt.asUintN(64, timestamp)) without bounds checks, silently wrapping negative timestamps (-1n -> 0xffffffffffffffff) and timestamps > MAX_INT64 into two's-complement 8-byte payloads that verifyAttestation accepted as true and attestedTime incorporated into median calculation, producing blocks rejected on-chain.
  2. Timekeeper discovery DoS via /node public_key spoofing and case-sensitive key matching:
    • discoverTimekeepers matched set.keys case-sensitively and deduplicated discovered candidates solely by seen.has(t.publicKey). An untrusted candidate URL listed earlier in candidates that returned an honest timekeeper's public_key from /node (without holding the private key) evicted the real timekeeper's endpoint URL from the returned Timekeeper[] list, causing subsequent gatherAttestations signature verification to fail even though the honest timekeeper URL was passed.
  3. Duplicate-key quorum inflation & missing set.threshold bounds in gatherAttestations:
    • gatherAttestations checked timekeepers.length < set.threshold instead of counting distinct trusted publicKeys (set.keys), did not validate 1 <= set.threshold <= MAX_ATTESTATIONS_PER_BLOCK (20), did not filter caller-supplied Timekeeper[] against set.keys, and did not deduplicate returned Attestation[] by normalized publicKey. Passing two Timekeeper entries backed by the same key (or mirrors of one node) satisfied atts.length >= set.threshold with duplicate attestations from a single key, which Go consensus rejects as duplicate timekeeper attestations.

Impact

  • Consensus rejection / invalid lease settlement blocks: Out-of-range bigint timestamps or duplicate-key attestations pass SDK helpers and fail Go node block validation.
  • Availability / failover DoS: Any spoofed candidate endpoint claiming a known public_key in /node shadows honest endpoints for that timekeeper during discovery; uppercase hex keys in TimekeeperSet or /node responses fail discovery/verification.

Fix

  • Enforce 0n <= timestamp <= MAX_INT64 ((1n << 63n) - 1n) in attestationPayload, verifyAttestation, and attestedTime.
  • Normalize public keys to lowercase hex in discoverTimekeepers and deduplicate by ${publicKey}@${client.url} so spoofed /node endpoints cannot evict honest failover endpoints.
  • Validate 1 <= set.threshold <= MAX_ATTESTATIONS_PER_BLOCK (20), filter timekeepers against set.keys, require distinctKeys.size >= set.threshold before network fan-out, verify normalized att.publicKey against both tk.publicKey and set.keys, deduplicate valid attestations per publicKey, and cap at MAX_ATTESTATIONS_PER_BLOCK.

Thread

Khanhtnq2026-11-13 10:39 UTCgithub

Fix opened in https://github.com/xeprotocol/sdk/pull/16.

Joseph Denneteam2026-11-20 13:00 UTCgithub

Thanks. This is the same finding as an earlier report that is not public, 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, file a new report that links https://bounty.xe.network/XE-13387 and says what differs; it is read like any other.