{"id":"XE-7924","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":827,"title":"[node] Unauthenticated remote node crash via nil block in ledger-sync response (requestSync dereferences nil block, no recover)","area":"p2p-sync","claimed_tier":"high","assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0002","tracked":true,"internal_ref":"#1064","internal_url":"https://github.com/xeprotocol/core/issues/1064","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-11T19:23:37.517522+00:00","updated_at":"2026-11-17T09:38:18.232248+00:00","source_created_at":null,"told_at":"2026-11-17T09:38:18.270608+00:00","status_changed_at":"2026-11-17T09:38:18.242139+00:00","url":"https://bounty.xe.network/XE-7924","body":"## Summary\nA remote, unauthenticated peer can crash any node that syncs the ledger from it by answering a ledger-sync request with a response containing a JSON `null` block. The sync client dereferences the nil `*core.Block` and panics; there is no `recover()` anywhere on the sync-client path, so the panic kills the node process.\n\n## Severity\nHigh. Unauthenticated remote node crash (availability). No stake, key, funds, or privileged position required — any peer the victim syncs from can do it, and sync is automatic on every new connection and periodically thereafter. Claimed tier: high.\n\n## Evidence (code-level, xe repo HEAD 89a542e)\n- `net/sync.go:529` `requestSync`: decodes pages into `SyncResponse{Blocks []*core.Block}` and appends them verbatim: `allBlocks = append(allBlocks, resp.Blocks...)` — a JSON `null` element becomes a nil `*core.Block` and is never checked.\n- `net/sync.go:592` quarantine filter: `for _, b := range allBlocks { if quarantine.contains(b.Hash) { ... } }` — `b.Hash` on a nil block is a nil-pointer dereference.\n- The same nil block would also panic one line deeper: `core/ledger.go` `addBlock` starts with `bc := *b`.\n- No recover on the whole path: `gate.spawn` (`net/sync.go:403-412`) runs the callback bare; the `ConnectedF` handler (`net/sync.go:320-343`) and the periodic resync (`net/sync.go:345-395`) both call `requestSync` directly. An unrecovered panic in any of these goroutines is fatal to the process.\n- The sibling code already knows about this shape and guards it: `net/blocksync.go` `PullBlocks` skips nil blocks (`if b == nil { continue }`). `requestSync` is the unguarded copy.\n\n## Reproduction (runnable PoC, passes against HEAD 89a542e)\nTest `net/zz_r5_nilblock_test.go` (`TestR5LedgerSyncNilBlockCrash`, package `net`): two in-process libp2p hosts; the \"attacker\" host serves protocol `/xe/sync/1.0.0` and answers the victim's `SyncRequest` with `{\"blocks\":[null],\"has_more\":false}`; the victim calls `requestSync` against it. Result:\n```\n=== RUN   TestR5LedgerSyncNilBlockCrash\n    requestSync panicked as expected: runtime error: invalid memory address or nil pointer dereference\n--- PASS: TestR5LedgerSyncNilBlockCrash (0.03s)\n```\nUnrecovered stack (same test without the recover wrapper):\n```\npanic: runtime error: invalid memory address or nil pointer dereference\ngithub.com/xeprotocol/xe/net.requestSync(...)\n        /home/hatch/workspace/bounty-hunting/xe-bounty/work/xe-repo/net/sync.go:592\n```\n`go test ./net/ -run TestR5LedgerSyncNilBlockCrash -v` reproduces it. No mainnet/testnet nodes were touched — the crash was demonstrated locally only.\n\n## Impact\n- Any node that syncs ledger state from a malicious peer crashes. Sync runs automatically when a peer connects and on the periodic resync, so the attacker only has to be a peer of the victim (discovery is ambient: DHT rendezvous + mDNS + bootstrap dials).\n- After a restart the node re-syncs and can be crashed again by the same peer, so this is a repeatable availability kill, not a one-off.\n- Affected parties: every node operator on the network (providers, representatives, plain nodes). No funds are at risk directly, but a crashed representative stops voting and a crashed provider stops serving leases.\n\n## Remediation\nSkip nil blocks in `requestSync` exactly as `PullBlocks` already does (`if b == nil { continue }`), ideally in both the decode loop and the quarantine filter; and/or add a `recover()` around the sync-client goroutines (`gate.spawn`) so one bad peer cannot kill the process. A nil check in `Ledger.addBlock` / `AddSyncedBlock` would harden the shared entry point too.\n\n## Dedup note\nThis is the LEDGER-sync instance, not the statechain one. XE-4845 (\"[High] Unauthenticated remote node crash via nil block in statechain-sync response\") covers `statechain/sync.go` (`/xe/statechain-sync/1.0.0`) only — different file, different protocol, different trigger. Board API queries before filing, all clean for this path: `q=nil+block` returns XE-4845 (statechain), XE-0436, XE-7692 (both unrelated); `q=null+block`, `q=requestSync+panic`, `q=ledger+sync+crash`, `q=nil+panic` return 0 tickets; `q=sync+crash` returns XE-2821 and XE-0002 (unrelated). No ticket mentions a nil block in `net/sync.go` `requestSync`.\n\n## Scope note\nIn scope: everything shipping with the XE node and everything the public testnet runs (bounty policy, test.network/bounty). Node repo `xeprotocol/xe`, HEAD `89a542e`.\n\n## Environment\nxe repo HEAD `89a542e` (\"release: testnet-0005 quorum withhold fix\"), audited 2026-11-12. PoC run locally with Go 1.25.4, `go test ./net/ -run TestR5LedgerSyncNilBlockCrash -v`.\n\n## Payout address (XE)\nxe:952f5eaffd7af01d1c452ea68f2b37ed340ab773ed6ae4fb73c18fb2ef4edc8d","patch_refs":[],"thread":[{"id":9731,"source":"desk","source_ref":"reply:8169","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0002, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-7924 and says what differs; it is read like any other.","created_at":"2026-11-17T09:38:18.232248+00:00"}]}