{"id":"XE-13387","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"546","source_url":"https://github.com/xeprotocol/xe/issues/546","reporter_id":2,"title":"[SDK] src/attestation.ts wraps out-of-range int64 timestamps, evicts honest timekeeper endpoints on /node spoofing, and accepts duplicate-key quorums","area":"sdk-docs-web","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:15.164984+00:00","updated_at":"2026-11-20T13:01:18.418749+00:00","source_created_at":"2026-11-13T10:39:13+00:00","told_at":"2026-11-20T13:00:18+00:00","status_changed_at":"2026-11-20T12:59:45.749095+00:00","url":"https://bounty.xe.network/XE-13387","body":"### Summary\n\n`src/attestation.ts` diverges from Go ledger consensus (`core/attestation.go`) and allows quorum/discovery bypasses across four coupled paths:\n\n1. **Out-of-range `int64` timestamp wrapping in `attestationPayload`, `verifyAttestation`, and `attestedTime`**:\n   - Go consensus (`core/attestation.go`) strictly enforces `0 <= timestamp <= math.MaxInt64` (`9223372036854775807`).\n   - `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.\n2. **Timekeeper discovery DoS via `/node` `public_key` spoofing and case-sensitive key matching**:\n   - `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.\n3. **Duplicate-key quorum inflation & missing `set.threshold` bounds in `gatherAttestations`**:\n   - `gatherAttestations` checked `timekeepers.length < set.threshold` instead of counting distinct trusted `publicKey`s (`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.\n\n### Impact\n\n- **Consensus rejection / invalid lease settlement blocks**: Out-of-range `bigint` timestamps or duplicate-key attestations pass SDK helpers and fail Go node block validation.\n- **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.\n\n### Fix\n\n- Enforce `0n <= timestamp <= MAX_INT64` (`(1n << 63n) - 1n`) in `attestationPayload`, `verifyAttestation`, and `attestedTime`.\n- Normalize public keys to lowercase hex in `discoverTimekeepers` and deduplicate by `${publicKey}@${client.url}` so spoofed `/node` endpoints cannot evict honest failover endpoints.\n- 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`.\n","patch_refs":[],"thread":[{"id":3149,"source":"github","source_ref":"6850510510","author":"Khanhtnq","team":false,"body":"Fix opened in https://github.com/xeprotocol/sdk/pull/16.","created_at":"2026-11-13T10:39:16+00:00"},{"id":14107,"source":"github","source_ref":"7040167693","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-13387 and says what differs; it is read like any other.","created_at":"2026-11-20T13:00:18+00:00"}]}