Consensus vote hex malleability / quorum forgery, conflict staging & accepted lease rollback flaws, ZeroAddress delegation collision, and P2P sync crash
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:
- 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) - Competing
BlockReceive,BlockLeaseSettle,BlockLeaseCancel, andBlockLeaseForceSettleBlocks Rejected Before Conflict Detection + Unhandled AcceptedBlockLeaseUnwind &ReducePendingCascade Desync (core/ledger.go,core/rollback.go,core/cascade_commit.go) - Unauthenticated Delegation Hijack & Quorum Deadlock via
ZeroAddress("0000...0000") Canonical Encoding Collision on Non-Genesis Blocks &sys.representativesAllowlist Case-Mismatch Fail-Open Bypass (core/encoding.go,core/repeligibility.go,core/ledger.go) - Remote P2P Sync Node Crash (
nilBlock Panic) & Stream Read / Empty-Page Amplification in/xe/sync/1.0.0and/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) decodesv.ConflictAccount,v.ConflictPrev,v.BlockHash, andv.RepPubKeyviahex.DecodeString(...)into raw 32-byte arrays before signing/verifying. Becausehex.DecodeStringis case-insensitive ("a"and"A"decode to identical bytes), a single valid Ed25519 signature over aVoteremains cryptographically valid across $2^k$ uppercase/lowercase hex permutations ofRepPubKey,BlockHash,ConflictAccount, andConflictPrevwithout possessing the representative's private key.- In
store/mem_store.go,memVoteKeybuilds map keys from raw strings (account + ":" + prevHash + ":" + repPubKey) withoutstrings.ToLower. Incore/quorum.go(finalTally) andcore/finalization.go(convergeWeights,gatherCandidates), votes returned byGetVotesByConflictare summed directly without deduplicating by representative account (v.RepAccount()). OnMemStore-backed nodes, replaying case-variantRepPubKeycopies 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),voteKeylowercases the key on write (PutVote), overwriting the legitimate vote record with an attacker-mutated uppercasev.BlockHash. WhenfinalTallyreaches 67% on the uppercaseWinnerHash,FinalizeConflictcompareswinnerHash == conflict.WinnerHash(case-sensitive), falsely assumes the winner differs from the frontier block, callsSwapBlock(which fails with"replacement block <UPPERCASE> not found"), and skipsMarkFinalizedwhile deleting the conflict (DeleteConflict)—leaving the winning chain unfinalized forever. - Additionally,
receiveVoteInner(core/vote.go) only blocked overwriting aFinal: truevote with aFinal: falsevote, but did not checkv.Timestamp <= existing.Timestampwhenv.Final == false. Anyone could replay an older signed prelim (Final: false) vote from a representative to revert their latest prelim vote choice duringconvergeWeights.
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
Previoushash (b.Previous != frontier.Hash),Ledger.AddBlockroutes the second block toValidateStagedBlock(core/ledger.go) so it can be stored and registered as a fork conflict. - However,
ValidateStagedBlockchecked live ledger state (PendingSendExistsforBlockReceive, andGetLease(b.Source)forBlockLeaseSettle,BlockLeaseCancel, andBlockLeaseForceSettle) 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 tosettled/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,
ValidateStagedBlockforBlockReceivedid not verifyb.Asset == pendingAsset(unlikeValidateBlock), allowing cross-asset staged receive blocks. - In
swapBlockLocked(core/ledger.go),planRollbackOfSendandplanRollbackOfReceivewere called when unwindingBlockSendorBlockReceive, but there was noplanRollbackOfLeasewhen unwinding an unfinalizedBlockLease. If a provider had already appended an unfinalizedBlockLeaseAcceptreferencingoldBlock.Hash, swapping out theBlockLeaseleft the provider'sBlockLeaseAcceptandProviderStakeorphaned on the provider's chain, or silently overwrotelease_activeeven if the provider'sBlockLeaseAcceptwas finalized or built upon. - In
core/cascade_commit.go,cascadeBuild.addUndoandgetPendingSendOverlaytrackedrestorePendinganddeletePendingacross multi-account cascade steps, but ignoredu.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,MarshalBlockCanonicalencodesb.Representative(andb.AccessPubKey) by decoding the 64-char hex string into 32 bytes, or writing 32 zero bytes when the field is empty (""). Consequently,Representative: ""andRepresentative: ZeroAddress("0000000000000000000000000000000000000000000000000000000000000000") produce byte-for-byte identical canonical bytes, identicalBlock.Hash, and identical Ed25519 signatures. - In
core/ledger.go, bothaddBlockandrebuildDelegationevaluateif 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 reassignl.delegatedTo[b.Account] = ZeroAddress. BecausetotalEligibleWeightsumsrepWeight[ZeroAddress]while no private key exists forZeroAddress, redirected stake remains in the quorum denominator (67%oftotalWeight) as phantom weight that can never vote, enabling unauthenticated quorum deadlock. - In
core/repeligibility.go,RepresentativeConfig.allowlist()populated thesys.representativesmap from comma-separated addresses withoutstrings.ToLower. If an operator configured an uppercase/mixed-case hex address insys.representatives,allow[addr]failed to match lowercase account addresses—and if all entries were uppercase alongside any invalid entry reducinglen(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) andstatechain/sync.go(/xe/statechain-sync/1.0.0) decodeSyncResponsewithBlocks []*core.Block/Blocks []*Block. A peer returning{"blocks":[null]}passes JSON decoding with anilpointer element and immediately panics with a nil-pointer dereference (b.Accountinnet/sync.go,b.Sequenceinstatechain/sync.go,b.TypeinLedger.addBlock, orb.Versioninstatechain.Chain.AddBlock), crashing the syncing node process. - In
net/sync.go,RequestSyncwrapped the stream inio.LimitReader(s, maxSyncResponseBytes)(64 MiB), but resetlr.N = maxSyncResponseByteson every loop iteration across up tomaxSyncPages(10,000) pages and did not break whenlen(resp.Blocks) == 0 && resp.HasMore, allowing a single sync stream to force up to640 GiBof stream reads or spin10,000empty-page iterations.
Thread
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.
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:
-
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.
-
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.
-
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.
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, phantomweight(ZeroAddress) = 90e12 - 1stays 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.
addBlockis 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-263writes 32 zero bytes forRepresentative == ""(identical to ZeroAddress); the only ZeroAddress guard in the repo isvalidateGenesisRepresentative(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).
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
BlockSendwithRepresentative: ""and the same block withRepresentative: "000…0"(64 zeros) hash identically (238a3e3d…a7689); the original signature still verifies on the mutated block andVerifyBlockpasses — 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
AccessPubKeyinstance collides the same way (lease blocks, hash7dbaf8b1…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 mutatedRep=zeroform is rejected (multisig: insufficient signatures: got 1, need 2, viachangesRepresentative). 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.