Bounty
XE-0002 · Bounty

Consensus vote hex malleability / quorum forgery, conflict staging & accepted lease rollback flaws, ZeroAddress delegation collision, and P2P sync crash

Accepted xe#8 filed 2026-10-18 08:13 UTC by Khanhtnq

Report

Summary

During a security review of the consensus voting, conflict staging/rollback, canonical block encoding, representative allowlist, and P2P sync subsystems, we identified four non-overlapping vulnerabilities across core, store, net, and statechain:

  1. Consensus Vote Hex Case-Malleability, Quorum Forgery (MemStore), Finality Corruption (BadgerStore), and Stale Non-Final Vote Replay (core/vote.go, core/quorum.go, core/finalization.go, store/mem_store.go, net/gossip.go)
  2. Competing BlockReceive, BlockLeaseSettle, BlockLeaseCancel, and BlockLeaseForceSettle Blocks Rejected Before Conflict Detection + Unhandled Accepted BlockLease Unwind & ReducePending Cascade Desync (core/ledger.go, core/rollback.go, core/cascade_commit.go)
  3. Unauthenticated Delegation Hijack & Quorum Deadlock via ZeroAddress ("0000...0000") Canonical Encoding Collision on Non-Genesis Blocks & sys.representatives Allowlist Case-Mismatch Fail-Open Bypass (core/encoding.go, core/repeligibility.go, core/ledger.go)
  4. Remote P2P Sync Node Crash (nil Block Panic) & Stream Read / Empty-Page Amplification in /xe/sync/1.0.0 and /xe/statechain-sync/1.0.0 (net/sync.go, statechain/sync.go, statechain/chain.go, core/ledger.go)

Finding 1: Consensus Vote Hex Case-Malleability, Quorum Forgery (MemStore), Finality Corruption (BadgerStore), and Stale Non-Final Vote Replay

Root Cause

  • Vote.CanonicalBytes() (core/vote.go) decodes v.ConflictAccount, v.ConflictPrev, v.BlockHash, and v.RepPubKey via hex.DecodeString(...) into raw 32-byte arrays before signing/verifying. Because hex.DecodeString is case-insensitive ("a" and "A" decode to identical bytes), a single valid Ed25519 signature over a Vote remains cryptographically valid across $2^k$ uppercase/lowercase hex permutations of RepPubKey, BlockHash, ConflictAccount, and ConflictPrev without possessing the representative's private key.
  • In store/mem_store.go, memVoteKey builds map keys from raw strings (account + ":" + prevHash + ":" + repPubKey) without strings.ToLower. In core/quorum.go (finalTally) and core/finalization.go (convergeWeights, gatherCandidates), votes returned by GetVotesByConflict are summed directly without deduplicating by representative account (v.RepAccount()). On MemStore-backed nodes, replaying case-variant RepPubKey copies of a single representative's vote multiplies that representative's weight across distinct map entries, forging 67% finality quorum with arbitrary stake (<1%).
  • On BadgerStore-backed nodes (store/badger_store.go), voteKey lowercases the key on write (PutVote), overwriting the legitimate vote record with an attacker-mutated uppercase v.BlockHash. When finalTally reaches 67% on the uppercase WinnerHash, FinalizeConflict compares winnerHash == conflict.WinnerHash (case-sensitive), falsely assumes the winner differs from the frontier block, calls SwapBlock (which fails with "replacement block <UPPERCASE> not found"), and skips MarkFinalized while deleting the conflict (DeleteConflict)—leaving the winning chain unfinalized forever.
  • Additionally, receiveVoteInner (core/vote.go) only blocked overwriting a Final: true vote with a Final: false vote, but did not check v.Timestamp <= existing.Timestamp when v.Final == false. Anyone could replay an older signed prelim (Final: false) vote from a representative to revert their latest prelim vote choice during convergeWeights.

Finding 2: Competing BlockReceive, BlockLeaseSettle, BlockLeaseCancel, and BlockLeaseForceSettle Rejected Before Conflict Detection + Accepted BlockLease Unwind & ReducePending Desync

Root Cause

  • When an account signs two competing blocks sharing the same Previous hash (b.Previous != frontier.Hash), Ledger.AddBlock routes the second block to ValidateStagedBlock (core/ledger.go) so it can be stored and registered as a fork conflict.
  • However, ValidateStagedBlock checked live ledger state (PendingSendExists for BlockReceive, and GetLease(b.Source) for BlockLeaseSettle, BlockLeaseCancel, and BlockLeaseForceSettle) without accounting for an unfinalized sibling block on the same account (existing.Previous == b.Previous && existing.Source == b.Source) that already consumed the pending send or transitioned the lease to settled/cancelled. As a result, competing blocks of those types were rejected with an error before conflict detection, preventing fork resolution even if 100% of representatives voted for the competing block.
  • Furthermore, ValidateStagedBlock for BlockReceive did not verify b.Asset == pendingAsset (unlike ValidateBlock), allowing cross-asset staged receive blocks.
  • In swapBlockLocked (core/ledger.go), planRollbackOfSend and planRollbackOfReceive were called when unwinding BlockSend or BlockReceive, but there was no planRollbackOfLease when unwinding an unfinalized BlockLease. If a provider had already appended an unfinalized BlockLeaseAccept referencing oldBlock.Hash, swapping out the BlockLease left the provider's BlockLeaseAccept and ProviderStake orphaned on the provider's chain, or silently overwrote lease_active even if the provider's BlockLeaseAccept was finalized or built upon.
  • In core/cascade_commit.go, cascadeBuild.addUndo and getPendingSendOverlay tracked restorePending and deletePending across multi-account cascade steps, but ignored u.reducePending != nil, causing multi-hop cascades that partially unwind a multi-output send prior to unwinding a receive to read stale pending amounts.

Finding 3: ZeroAddress ("0000...0000") Canonical Encoding Collision on Non-Genesis Blocks & sys.representatives Allowlist Case-Mismatch Bypass

Root Cause

  • In core/encoding.go, MarshalBlockCanonical encodes b.Representative (and b.AccessPubKey) by decoding the 64-char hex string into 32 bytes, or writing 32 zero bytes when the field is empty (""). Consequently, Representative: "" and Representative: ZeroAddress ("0000000000000000000000000000000000000000000000000000000000000000") produce byte-for-byte identical canonical bytes, identical Block.Hash, and identical Ed25519 signatures.
  • In core/ledger.go, both addBlock and rebuildDelegation evaluate if b.Representative != "" { l.delegatedTo[b.Account] = b.Representative }. An attacker can take any valid signed block serialized in JSON with "representative": "" (intended to inherit the account's previous representative), replace the JSON field with "representative": "0000000000000000000000000000000000000000000000000000000000000000" without invalidating the block hash or Ed25519 signature, and cause every receiving node to reassign l.delegatedTo[b.Account] = ZeroAddress. Because totalEligibleWeight sums repWeight[ZeroAddress] while no private key exists for ZeroAddress, redirected stake remains in the quorum denominator (67% of totalWeight) as phantom weight that can never vote, enabling unauthenticated quorum deadlock.
  • In core/repeligibility.go, RepresentativeConfig.allowlist() populated the sys.representatives map from comma-separated addresses without strings.ToLower. If an operator configured an uppercase/mixed-case hex address in sys.representatives, allow[addr] failed to match lowercase account addresses—and if all entries were uppercase alongside any invalid entry reducing len(allow) or mismatched lookup, legitimate representatives were marked ineligible.

Finding 4: Remote P2P Sync Node Crash (nil Block Panic) & Stream Read / Empty-Page Amplification

Root Cause

  • Both net/sync.go (/xe/sync/1.0.0) and statechain/sync.go (/xe/statechain-sync/1.0.0) decode SyncResponse with Blocks []*core.Block / Blocks []*Block. A peer returning {"blocks":[null]} passes JSON decoding with a nil pointer element and immediately panics with a nil-pointer dereference (b.Account in net/sync.go, b.Sequence in statechain/sync.go, b.Type in Ledger.addBlock, or b.Version in statechain.Chain.AddBlock), crashing the syncing node process.
  • In net/sync.go, RequestSync wrapped the stream in io.LimitReader(s, maxSyncResponseBytes) (64 MiB), but reset lr.N = maxSyncResponseBytes on every loop iteration across up to maxSyncPages (10,000) pages and did not break when len(resp.Blocks) == 0 && resp.HasMore, allowing a single sync stream to force up to 640 GiB of stream reads or spin 10,000 empty-page iterations.

Thread

XE deskteam2026-11-10 00:16 UTCgithub

Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0002.

targammm2026-11-11 08:24 UTCgithub

Supplement from targammm (desk) — a new vector on this root cause, plus a HEAD status note on the Badger limb

While validating a related candidate I reproduced this root cause at current HEAD (89a542e) and found the live behaviour differs from Finding 1's Badger limb in one important way:

  1. The Badger limb as described (genuine first, malleated second, leading to overwrite plus a counted winner) no longer reproduces at HEAD. With that delivery order the stored vote stays lower-case (the existing.Final early return in core/vote.go discards the malleated copy) and finalTally counts the full weight — tested at 1,000,000 of 42,000,000,000,000 total delegated weight.

  2. The reverse delivery order is live, and is not described in Finding 1: if the upper-cased copy arrives FIRST, it verifies (the signing bytes are hex-decoded), is stored under the decoded key carrying the upper-case BlockHash string; the genuine vote then arrives and is discarded as duplicate-final; finalTally's block lookup with the raw upper-case string returns nil, so the stored vote is skipped — the representative's final-vote weight counts as 0 at that node while a weighted final vote sits in its store. Reproduced 5/5 formal runs (fresh store and keypairs each run) and 5/5 over the real PullVotes/libp2p path bound to production ReceiveVote ingest; the genuine-only control counts 1,000,000 in all runs.

  3. The identical test set on PR #351 tip (d9e82a7) gives identical outcomes — the new pull-layer checks do not inspect case. Flagging in case it helps PR #9's canonicalization work: the first-delivery suppression is the order worth a regression test.

Happy to share the test suite (TestR22C5FormalFiveX / TestR22C5WireFiveX) if useful. Posting this here as a supplement rather than a new report, since the root cause is the same.

akitaBugBounty2026-11-11 16:38 UTCgithub

Additional evidence: Findings 1 and 3 are still live at HEAD 89a542e (reproduced 2026-11-11)

This is a follow-up note on #8, not a new report. I re-verified Findings 1 and 3 against github.com/xeprotocol/xe @ 89a542ea51d38375299aee54c6c99102e9bfa666 with Go PoC tests (all passing, local only, no live traffic). Both holes are still open, and Finding 3's mechanism needs one correction (see below).

Finding 3 — ZeroAddress delegation hijack (still open)

Primitive. A signed block with Representative: "" and the same block with Representative: ZeroAddress ("0000...0000", 64 hex zeros) produce identical canonical bytes (MarshalBlockCanonical), the identical block hash, and the original signature still verifies on the mutated copy (verified: HashBlock equal, VerifyBlock and VerifyBlockSignatureWith pass on the mutated copy).

End-to-end (numbers). Whale 90e12 micro-XE delegated to rep A; total delegated weight 132e12, so A alone holds 68.18% — enough to finalise on its own.

  • Node L1 receives the original (Rep ""): rep(W) = A, weight(A) = 90e12 - 1; A's single Final vote finalises the funding block (control passes).
  • Node L2 receives the mutated copy first: rep(W) = ZeroAddress, phantom weight(ZeroAddress) = 90e12 - 1 stays in the denominator, weight(A) = 0. Max votable = 42e12 (genesis rep only) vs the 67% bar ≈ 88.44e12 — quorum deadlock: even 100% turnout of every real representative cannot finalise anything. A's Final vote at its true live weight (0) does not finalise.
  • Divergence, not uniform reassignment. L1 and L2 hold the same block hash but opposite weight views. addBlock is first-copy-wins on block hash, so whichever copy (original or mutated) reaches a node first fixes that node's delegation view permanently; the late-arriving original is silently dropped as a duplicate hash. The victim recovers only by publishing a block that explicitly names a real representative.
  • Correction to #8's description: #8 says "every receiving node" gets reassigned. In fact it is first-copy-wins per node — honest nodes fed the two copies of the same chain disagree on vote weights, which is a finality divergence between nodes, a strictly stronger consequence than a local deadlock. The fix must therefore close the canonical collision itself (reject ""/ZeroAddress as a representative on non-genesis blocks, or canonicalise "" to a non-zero sentinel), not only the genesis guard.
  • Root cause. encoding.go:260-263 writes 32 zero bytes for Representative == "" (identical to ZeroAddress); the only ZeroAddress guard in the repo is validateGenesisRepresentative (core/genesis.go:126), i.e. genesis-only; updateDelegation (core/ledger.go:2614) treats ZeroAddress as a live representative.

Finding 1 — Vote hex case-malleability (still open, MemStore half)

One rep holding 41.67% of live weight finalised a position with a single vote plus its uppercased-RepPubKey copy: the signature still verifies (voteSigningBytes decodes hex case-insensitively) and MemStore files the copy under a different key (memVoteKey does no lowercasing; finalTally never dedups by RepAccount) — stored weight counted 2x, FinalHeight = 1. Caveat: production nodes run BadgerStore (node/node.go:230), whose voteKey decodes hex to bytes, so the multiplication does not apply live there; on BadgerStore the same mutation instead overwrites the victim's legitimate vote with an uppercase BlockHash (also covered by Finding 1).

Reproduction

PoC tests (local, go test ./core/ -run TestXE16B -v, all passing at HEAD):

  • TestXE16BZeroAddressCanonicalCollision — primitive (identical canonical bytes/hash, signature verifies).
  • TestXE16BZeroAddressDelegationHijack — end-to-end hijack, deadlock arithmetic, split, first-copy-wins stickiness, recovery via explicit re-delegation.
  • TestXE16BVoteCaseMultiplicationMemStore — Finding 1, MemStore half.
  • TestXE16BSwapRepChangeWeightConsistent — control: swap path with rep-changing blocks keeps weights exact (sound, not a finding).

The full PoC test file is available on request (it is a test-only file; no production code was changed to produce it).

darendrarp2026-11-19 06:06 UTCgithub

Independent confirmation: Finding 3 is still reproducible at HEAD 8cc209d ("release: testnet-0006 build", 16 Nov) — the latest public release, after the 89a542e confirmation above. Reproduced locally (Go PoC, MemStore, throwaway keys, no live traffic):

  • A signed BlockSend with Representative: "" and the same block with Representative: "000…0" (64 zeros) hash identically (238a3e3d…a7689); the original signature still verifies on the mutated block and VerifyBlock passes — no re-signing, no new PoW.
  • Two ledgers fed the two forms of the same block both accept it, with hash-identical chains, but diverge on vote weight: ledger A keeps rep b50eba4b… at weight 999,900; ledger B moves all 999,900 to the zero address.
  • The AccessPubKey instance collides the same way (lease blocks, hash 7dbaf8b1… identical for "" vs zeros).
  • One bound worth noting for triage: multisig accounts fail closed — a 1-of-2 signed receive with Rep="" is accepted, but the mutated Rep=zero form is rejected (multisig: insufficient signatures: got 1, need 2, via changesRepresentative). The exposed class is single-key accounts.

Happy to share the full PoC (local-only Go program) if useful for a regression test.

Note: verified against public source only; the deployed build is not in this repo, so I can't speak to its status there.