{"id":"XE-0005","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"14","source_url":"https://github.com/xeprotocol/xe/issues/14","reporter_id":5,"title":"A gossiped block can end the node process: no recover on the block ingestion goroutine","area":"consensus","claimed_tier":"medium","assessed_tier":"high","verdict":"valid","duplicate_of":null,"tracked":true,"internal_ref":"#1028","internal_url":"https://github.com/xeprotocol/core/issues/1028","status":"awarded","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":3500000000,"award_approved":true,"paid_ref":"","created_at":"2026-10-29T13:57:13.433739+00:00","updated_at":"2026-11-07T14:52:30.859075+00:00","source_created_at":"2026-10-23T09:47:58+00:00","told_at":null,"status_changed_at":"2026-11-06T19:46:39.854003+00:00","url":"https://bounty.xe.network/XE-0005","body":"**Area:** State chain and multisig governance / P2P\n**Suggested tier:** Medium (2,500 XE). Policy row: \"Validation, accounting & load edge cases: validation gap\". Read the overlap note below before assigning.\n**Version tested:** `978785929bc17a2f4ab30c383e5fc9cf4d634512` (HEAD)\n**CWE:** CWE-248 (Uncaught Exception), CWE-400\n\n## Overlap note, read this first\n\nThe concrete panic I used to reach the crash, `pk[:12]` in `core/multisig.go:99`,\nis already covered by the open PR #7, which replaces it with `shortHash(pk)`.\n`shortHash` at `core/ledger.go:2711` checks the length before slicing, so once PR\n#7 merges the slice panic is gone and the executable path I describe below with\nit.\n\nSo the panic itself is not novel, and I am not claiming it as such. What PR #7\ndoes not change is the reason that panic killed the process instead of one\nmessage: the goroutine that ingests gossip blocks has no `recover`, and the\ngossip block validator never checks that `signatures[].public_key` is a\nwell-formed 64 character hex string. Either of those alone turns the next panic\non that path into a process exit.\n\nIf you treat the slice panic as the whole finding, this is a duplicate of PR #7\nand I would rather you close it than pay for it. If you treat the missing\n`recover` and the validator gap as separate defects, they are unfixed by every\nopen PR and this is a validation gap worth fixing before the next crash lands\nthere.\n\n## Summary\n\nAny libp2p peer can kill the entire node process with one gossiped block, and\nneeds no account, balance, XUSD or valid key material to do it.\n\nThree defects cover for each other:\n\n1. `core/multisig.go:99` slices `signatures[].public_key` to twelve characters\n   with no length check. A five character string panics.\n2. `net/gossip_validate.go:63` does not validate `public_key` length, so the\n   malformed block passes gossip validation and is accepted as\n   `ValidationAccept`.\n3. `node/node.go:570` runs `handleIncoming` in a goroutine with no `recover`, so\n   a panic there ends the process, while the same panic over HTTP only ends one\n   request.\n\nThe third point is what separates this from the ordinary HTTP panic. Through\n`POST /blocks/multisig_open`, `net/http` recovers per connection and the node\nsurvives. Through gossip, nothing catches it.\n\n## Evidence\n\nThe victim was built from the audited source with the `testnet-0005` genesis and\nno other peers. The attacker is a separate process importing the `net` and\n`core` packages from the same repo, so handshake and framing match a real node.\n\n```\nvictim pid=1291925\nBEFORE health=200\nvictim multiaddr: /ip4/127.0.0.1/tcp/29711/p2p/12D3KooWGgkhY5EXnz9xCVEee4UNAMFPMVe8SzqpQNgwwdn4ChMs\nattacker peer id: 12D3KooWJdW3QwvrjNjA9RwcsiXxQShmvKrDpWR9ajt6FZ6FKiYT\nconnected to victim: 12D3KooWGgkhY5EXnz9xCVEee4UNAMFPMVe8SzqpQNgwwdn4ChMs\nnetcheck: handshake answered\npeers on topic: 1\nblock: hash=72b72e2815... pk=\"abcde\" (len 5)\nPoW nonce=3770910114026266168 (difficulty 0xfffff80000000000)\npublish attempt 1 (peers=1) ... PUBLISHED\nDIAGNOSTIC: gossipsub delivered the message — topic path is live\n\nAFTER health=000\nPROC=DEAD\npanic count: 1\nhandleIncoming in stack: 1\n```\n\nStack trace showing the gossip path rather than the HTTP path:\n\n```\npanic: runtime error: slice bounds out of range [:12] with length 5\n\ngoroutine 228 [running]:\ngithub.com/xeprotocol/xe/core.VerifyMultisig({0x33d531297440, 0x40}, {0x33d52babdbe0, 0x1, 0x7f6da10a24e8?}, 0x33d52babdbc0)\n\t/root/xe-src/core/multisig.go:99 +0x70e\ngithub.com/xeprotocol/xe/core.(*Ledger).verifyBlockCredential(0x33d52ba96000, 0x33d52bcf0820)\n\t/root/xe-src/core/ledger.go:1436 +0x219\ngithub.com/xeprotocol/xe/core.(*Ledger).addBlock(0x33d52ba96000, 0x33d52bcf0680, 0x0)\n\t/root/xe-src/core/ledger.go:801 +0x9df\ngithub.com/xeprotocol/xe/core.(*Ledger).AddBlock(...)\n\t/root/xe-src/core/ledger.go:732\ngithub.com/xeprotocol/xe/node.(*Node).handleIncoming(0x33d52b908788, 0x33d52ba03dc0)\n\t/root/xe-src/node/node.go:711 +0xd2\ngithub.com/xeprotocol/xe/node.New.func25()\n\t/root/xe-src/node/node.go:570 +0x72\ncreated by github.com/xeprotocol/xe/node.New in goroutine 1\n```\n\n`node.New.func25` at `node/node.go:570` is\n`go func() { defer n.wg.Done(); n.handleIncoming(...) }()`. There is no `recover`\nin that goroutine or inside `handleIncoming`.\n\n## How the block gets past the gossip filter\n\n`net/gossip.go:150` drops blocks where `len(b.Signature) != 128`:\n\n```go\nb := bm.Block\nif len(b.Hash) != 64 || len(b.Signature) != 128 || len(b.Account) != 64 {\n    continue\n}\n```\n\nA multisig block does not use the single `Signature` field, so it arrives empty\nand the filter drops it. That does not stop an attacker, because `Signature` is\nnot part of the hash. `MarshalBlockCanonical` and `MarshalBlockAux` never write\n`b.Signature`, so filling that field with 128 junk characters leaves the hash and\nthe proof of work valid and the block passes.\n\nConfirmed both ways: with an empty `Signature` the node survives because the\nfilter drops the block, and with 128 junk characters the node dies.\n\n## What I did not prove\n\n- Execution against a live testnet node. That would take a public node down and\n  spread through the mesh. All evidence comes from nodes built from the audited\n  commit with the same `testnet-0005` genesis.\n- That the live binaries are byte-identical here. Live reports `xe/92d83d1`, a\n  commit that is not in the public repo. However `core/multisig.go` and\n  `net/gossip.go` have not changed since `a47b973` (testnet-0003), and\n  `core/multisig.go` was last touched by `e5e65ba` (testnet-0005), so the logic\n  at all three points is the same live.\n- Any path to stealing funds. This is availability only.\n\n## Controls\n\n- A block with a correctly sized `public_key` (64 hex) does not panic; it is\n  rejected with `signer ... not in keyset`.\n- The malicious block with an empty `Signature` leaves the node alive because the\n  gossip filter drops it. That shows the filter works and that the panic comes\n  from the block contents rather than from publishing.\n- An attacker without a `/xe/netcheck/1` implementation gets its connection\n  closed and the node survives. That shows the handshake has to be passed, and\n  that netcheck does not reject a peer for having no credentials.\n\n## Fix\n\n1. Add `recover` to the goroutine at `node/node.go:570` and to\n   `spawnGate.spawn`, so a panic while replaying a block fails one round instead\n   of ending the process.\n2. In `blockValidator`, reject any block whose `Signatures` contain a\n   `public_key` that is not 64 hex characters, so malformed blocks die at gossip\n   validation and never reach the ledger.\n3. Validate `signatures[].public_key` in `VerifyMultisig` and\n   `VerifyMultisigAny` before use.\n4. Replace the remaining `pk[:12]` uses with a length safe helper such as\n   `shortHash`. PR #7 already does this one.\n\n## Prior art\n\nI read the body of every open issue and the actual patch of every open PR.\n\nPR #7 replaces the three `pk[:12]` uses in `core/multisig.go` with `shortHash`,\nwhich is the slice panic. Its `net/gossip_validate.go` change only swaps the\ncertificate validator, not `blockValidator`. Its `node/node.go` change only adds\n`isHostedChatRecipient` for chat. It does not add a `recover` to the gossip\ngoroutine.\n\nPR #9 changes `net/gossip.go` only by lowercasing the vote dedup key in\n`enqueueVote`. The `len(b.Signature) != 128` filter at line 150 is untouched.\n\nPR #5 and PR #11 do not touch the gossip path at all.\n\nSearching every issue body for `recover` returns one hit, \"unrecoverable keyset\"\nin issue #6, which is about lost keys rather than a `recover()` for a panic. No\nissue reports a goroutine without `recover`.","patch_refs":[{"id":118,"repo":"xeprotocol/xe","kind":"pr","ref":"28","title":"fix(core,net,node): validate multisig signature public keys and recover panics in block ingestion and sync","url":"https://github.com/xeprotocol/xe/pull/28","note":"","state":"open","author":"ocakciomursel-pixel","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"},{"id":194,"repo":"xeprotocol/xe","kind":"pr","ref":"1029","title":"","url":"https://github.com/xeprotocol/xe/pull/1029","note":"","state":"merged","author":"","added_by":"desk","created_at":"2026-10-29T14:22:09.061497+00:00"}],"thread":[]}