<!-- XE-13387 · [SDK] src/attestation.ts wraps out-of-range int64 timestamps, evicts honest timekeeper endpoints on /node spoofing, and accepts duplicate-key quorums · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13387>. The page is the record; this is the same page for reading.*

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](https://github.com/xeprotocol/xe/issues/546)
filed 2026-11-13 10:39 UTC
by Khanhtnq

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   SDK / docs / web

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 13:01 UTC

Told
:   2026-11-20 13:00 UTC

### Patches

None linked.

### History

- [599207](https://bounty.xe.network/log/599207) 2026-11-20 13:00 UTC reply.mirrored
- [598965](https://bounty.xe.network/log/598965) 2026-11-20 13:00 UTC github.state\_pushed
- [598903](https://bounty.xe.network/log/598903) 2026-11-20 13:00 UTC github.labels
- [597651](https://bounty.xe.network/log/597651) 2026-11-20 12:59 UTC proposal.adopted
- [597650](https://bounty.xe.network/log/597650) 2026-11-20 12:59 UTC reply.sent
- [597649](https://bounty.xe.network/log/597649) 2026-11-20 12:59 UTC ticket.status new → closed
- [594374](https://bounty.xe.network/log/594374) 2026-11-20 12:58 UTC proposal.adopted
- [594373](https://bounty.xe.network/log/594373) 2026-11-20 12:58 UTC ticket.facts area
- [594372](https://bounty.xe.network/log/594372) 2026-11-20 12:58 UTC proposal.adopted
- [594371](https://bounty.xe.network/log/594371) 2026-11-20 12:58 UTC ticket.facts
- [594370](https://bounty.xe.network/log/594370) 2026-11-20 12:58 UTC proposal.adopted
- [594369](https://bounty.xe.network/log/594369) 2026-11-20 12:58 UTC ticket.facts

[Full history](https://bounty.xe.network/log?ref=XE-13387) · [JSON](https://bounty.xe.network/v1/tickets/XE-13387) · [markdown](https://bounty.xe.network/XE-13387.md)

### 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 `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.

### 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

**Khanhtnq**2026-11-13 10:39 UTCgithub

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

**Joseph Denne**team2026-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.
