{"id":"XE-0001","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"6","source_url":"https://github.com/xeprotocol/xe/issues/6","reporter_id":2,"title":"Multisig threshold & conflict unwind bypass, forged performance certificate score/expiry, and directory/chat P2P poisoning","area":"consensus","claimed_tier":"critical","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:12.473373+00:00","updated_at":"2026-11-05T22:06:32.700793+00:00","source_created_at":"2026-10-18T05:56:53+00:00","told_at":null,"status_changed_at":"2026-11-05T04:17:38.780966+00:00","url":"https://bounty.xe.network/XE-0001","body":"## Summary\n\nDuring an audit of the consensus/multisig validation layer (core/), governance statechain (statechain/), performance certificate validation (perf/, \node/), account directory (directory/), and signed chat subsystem (chat/, \node/), we identified four vulnerabilities:\n\n---\n\n### 1. [Critical] 1-of-N Multisig Threshold Bypass on Representative Hijack & Lease Stake Operations, BlockMultisigUpdate Conflict Lockout, and Case-Variant Duplicate Signer Bypass (core/, statechain/)\n\n#### Root Cause\n1. **Consensus Representative Hijack via 1-of-N BlockReceive (core/ledger.go:1421-1445)**:\n   - IsSpendingOp (core/multisig.go:140-147) classifies BlockReceive as a non-spending operation requiring only a single signature (VerifyMultisigAny, 1-of-N), even when the account keyset has Threshold > 1.\n   - However, \u0007pplyBlock (core/ledger.go:1645-1653) updates l.delegation[b.Account] = b.Representative unconditionally on every block—including BlockReceive. Any 1-of-N multisig member can receive 1 dust unit of XE with Representative set to an attacker-controlled address, hijacking 100% of the multisig account's consensus voting weight without meeting Keyset.Threshold.\n2. **Lease Stake & Commitment Operations Missing from IsSpendingOp (core/multisig.go:140-147)**:\n   - BlockLeaseAccept deducts and locks a 10% XUSD security stake from the provider's balance (core/ledger.go:1185-1208), and BlockLeaseCancel, BlockLeaseForceSettle, and BlockLeaseSettle mutate active lease and stake positions. Because none of these block types were included in IsSpendingOp, a single 1-of-N multisig signer could unilaterally lock the account's XUSD balance into provider stakes or cancel active leases.\n3. **BlockMultisigUpdate Conflict Detection Deadlock & Missing Keyset Unwind (core/ledger.go:1421-1445, core/rollback.go:246-248)**:\n   - When an unfinalized BlockMultisigUpdate at sequence $ rotates an account's keyset from  \to K_2$, l.SetKeyset(b.Account, &b.MSKeyset) immediately overwrites the active keyset in memory.\n   - If a competing valid block at the same sequence $ (signed under the parent keyset $ that was active at -1$) arrives, \u000berifyBlockCredential runs before conflict detection (checkConflict) and validates the incoming block against l.GetKeyset(b.Account) ($), rejecting the valid sibling block before conflict detection can trigger.\n   - Furthermore, \buildBlockUndo (core/rollback.go:246-248) returned an error (prior keyset unrecoverable) whenever unwinding a BlockMultisigUpdate, preventing SwapBlock from ever rolling back an unfinalized keyset rotation during consensus conflict resolution, even though prior keysets are deterministically recoverable by scanning earlier BlockMultisigUpdate blocks in chain.Blocks (or deleting the keyset if reverting to single-sig).\n4. **Case-Variant Hex Public Key Deduplication Bypass & Intra-Block epoch.* Mutation (statechain/chain.go:248-358, core/attestation.go:145-162)**:\n   - statechain.verifyMultisig, statechain.verifyOracleMultisig, statechain.validateSysKeyValue, and core.ValidateAttestations tracked seen signers using raw string keys (seen[sig.PublicKey]) while hex.DecodeString accepts both uppercase and lowercase hex. A single signer could submit two signatures with the same public key in lowercase (\u0007a...) and uppercase (AA...) to satisfy a 2-of-N threshold alone.\n   - In addition, statechain/chain.go validated each operation in a StateBlock against the pre-block c.kv snapshot rather than a staged KVStore that reflects prior operations in the same block, and did not forbid delete operations on write-once epoch.* keys or require oracle. prefix on OpOracleUpdate.\n\n---\n\n### 2. [Critical] Self-Signed Performance Certificate Score/Seed Forgery, Infinite Expiry (ExpiresAt = MaxInt64), and Unbounded Provider Sybil Storage Exhaustion (perf/, \node/, \net/)\n\n#### Root Cause\n1. **Unverified Score, Seed, Timestamps, and Expiry Window (perf/certificate.go:156-197, \node/perf.go:462-477)**:\n   - VerifyCertificateContent only checked c.Score <= 0, allowing Score = math.NaN(), Score = +Inf, or an arbitrary fabricated Score (e.g., 1e9) that does not match 1.0 / (float64(c.EndMedian-c.StartMedian)/1e9).\n   - It did not verify that c.StartMedian > 0, c.EndMedian > c.StartMedian, that c.Seed matches SeedHex(DeriveSeed(c.StartMedian, pubBytes)), that WorkProof, StartAttestationRoot, and EndAttestationRoot are valid non-zero 32-byte hex digests, or that c.ExpiresAt - c.IssuedAt <= int64(CertificateValidity) (30 days) and c.IssuedAt is not far in the future.\n   - Any node could broadcast a self-signed certificate claiming an arbitrary performance score and ExpiresAt = math.MaxInt64 that never expires.\n2. **Unbounded Provider Map & Persistent BadgerDB Exhaustion (\node/certset.go:25-54)**:\n   - certSet limited certificates per provider (MaxCertsPerProvider = 4) but placed no bound on total distinct providers (\byProvider) and persisted every accepted gossiped certificate via saveCertFn, allowing trivial Ed25519 Sybil key generation to exhaust node memory and BadgerDB storage.\n\n---\n\n### 3. [High] Account Directory Future-Timestamp Poisoning (Permanent Registration Lockout), Negative-Timestamp int64 Overflow, and Unbounded Map Growth (directory/)\n\n#### Root Cause\n- VerifyRegistration (directory/verify.go:29-53) only checked \neg.Timestamp == 0, without checking for negative timestamps or future timestamps.\n- Because Directory.Register (directory/directory.go:53-55) rejects updates when existing.Timestamp >= reg.Timestamp, a registration with Timestamp = math.MaxInt64 permanently locks the entry and is never evicted by Prune() (\now - reg.Timestamp > int64(d.ttl) is negative).\n- Conversely, a negative \neg.Timestamp (e.g., math.MinInt64) causes signed int64 subtraction overflow in \now - reg.Timestamp <= int64(d.ttl), wrapping around to a negative value and bypassing TTL checks in Get(), Lookup(), List(), and Prune().\n- Directory.registrations also had no maximum capacity bound.\n\n---\n\n### 4. [High] Chat Envelope Cross-Network Replay, Unvalidated Recipient Addresses, and Unauthenticated Arbitrary-Account P2P Storage Sink (chat/, \node/)\n\n#### Root Cause\n- envelopeCanonical (chat/envelope.go:33-58) did not include a domain separator or core.GetNetworkID(), allowing signed chat envelopes to be replayed across networks.\n- VerifyFull (chat/envelope.go:121-156) did not validate e.From / e.To via core.ValidateAddress, did not reject self-sends (e.From == e.To), and computed diff := now - e.Timestamp using signed int64 arithmetic that overflows when e.Timestamp is negative (math.MinInt64).\n- \negisterChatHandler (\node/node.go:2465-2480) accepted and stored gossiped chat envelopes for any arbitrary env.To address even when the node neither owned nor hosted that account, and ChatStore (chat/chat.go) had no bound on the number of tracked recipient accounts.\n\n---\n\n## Verification & Proof of Concept\n\nDeterministic unit tests reproducing and verifying each issue are included in:\n- core/multisig_conflict_security_test.go\n- statechain/security_test.go\n- perf/certificate_security_test.go\n- \node/cert_chat_security_test.go\n- directory/directory_security_test.go\n- chat/chat_security_test.go\n\nAll tests pass via go test -v ./....\n","patch_refs":[{"id":110,"repo":"xeprotocol/xe","kind":"pr","ref":"7","title":"fix(core,statechain,perf,directory,chat): harden multisig threshold & conflict unwind, certificate verification, directory & chat bounds","url":"https://github.com/xeprotocol/xe/pull/7","note":"","state":"open","author":"Khanhtnq","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[]}