{"id":"XE-11679","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":2166,"title":"[node,net] Remote unauthenticated node-crash: sync client dereferences a JSON null block with no nil check and 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-13T07:28:53.119568+00:00","updated_at":"2026-11-20T00:33:21.596304+00:00","source_created_at":null,"told_at":"2026-11-20T00:33:21.626554+00:00","status_changed_at":"2026-11-20T00:33:21.603057+00:00","url":"https://bounty.xe.network/XE-11679","body":"Remote unauthenticated node-crash: sync client dereferences a JSON `null` block with no nil check and no recover.\n\n## Summary\nEvery XE node automatically runs `requestSync` against every peer it connects to (outbound `ConnectedF`, net/sync.go:320-326) and against every peer in its routing table on a periodic resync (net/sync.go:345-384). `requestSync` decodes attacker-supplied `SyncResponse` pages and then dereferences every block element without a nil check:\n\n```go\nallBlocks = append(allBlocks, resp.Blocks...)   // net/sync.go:571\n...\nfiltered := allBlocks[:0]\nfor _, b := range allBlocks {\n    if quarantine.contains(b.Hash) {            // net/sync.go:592 — b is *core.Block, nil-able\n        skipped++\n    } else {\n```\n\n`SyncResponse.Blocks` is `[]*core.Block` (net/messages.go:22), so a JSON `null` array element decodes to a **nil pointer with no error** — unlike the gossip `blockValidator`, which explicitly rejects nil (`if b == nil { return ValidationReject }`, net/gossip_validate.go:70). A single malicious page `{\"blocks\":[null],\"has_more\":false}` therefore panics with a nil-pointer dereference on `b.Hash`.\n\n`requestSync` runs on a bare goroutine spawned from `ConnectedF` with **no `recover()`** (the only `recover` in the wire layer is in net/msg.go:70-74; `grep -n recover()` net/sync.go returns nothing). The panic terminates the entire node process.\n\n## Remote reachability\n- No auth and no trust required. The victim initiates the sync itself: it dials every peer it connects to and re-syncs every peer in its routing table every 10 s (net/sync.go:345-384).\n- The attacker only has to accept the victim's inbound sync stream and write one crafted page. There is no rate-limit protection on this *client* path (the inbound limit at net/sync.go:313 protects the server, not this decode loop).\n\n## Affected code\n- net/sync.go:589-594 — the unguarded `for _, b := range allBlocks { ... b.Hash ... }` loop\n- net/sync.go:571 — `allBlocks = append(allBlocks, resp.Blocks...)`\n- net/messages.go:22 — `Blocks []*core.Block \\`json:\"blocks\"\\``\n- net/sync.go:320-326 — `ConnectedF` spawning `requestSync` on a bare goroutine (no recover)\n\n## Reproduction\nPoC of the exact decode→iterate path (runnable):\n```go\n// net/poc_sync_nullblock_test.go\nfunc Test_PoC_SyncNullBlockNilDeref(t *testing.T) {\n    defer func() {\n        if r := recover(); r != nil { t.Logf(\"PANIC CONFIRMED (node crash): %v\", r); return }\n        t.Error(\"no panic - guard exists; inspect\")\n    }()\n    page := []byte(`{\"blocks\":[null],\"has_more\":false}`)\n    var resp net.SyncResponse\n    if err := json.NewDecoder(bytes.NewReader(page)).Decode(&resp); err != nil {\n        t.Fatalf(\"decode: %v (json null should decode with no error)\", err)\n    }\n    var allBlocks []*core.Block\n    allBlocks = append(allBlocks, resp.Blocks...)\n    filtered := allBlocks[:0]\n    for _, b := range allBlocks {\n        if b.Hash == \"\" { continue }   // b is nil here -> nil-pointer dereference\n        filtered = append(filtered, b)\n    }\n}\n```\n`go test ./net/ -run Test_PoC_SyncNullBlockNilDeref -v` output:\n```\npoc_sync_nullblock_test.go:46: decoded 1 blocks; blocks[0]==nil? true\npoc_sync_nullblock_test.go:34: PANIC CONFIRMED (node crash): runtime error: invalid memory address or nil pointer dereference\n```\n\n## Impact\n- Deterministic, remote, unauthenticated denial-of-service of any node. A single attacker-controlled sync-response page crashes the whole process (consensus participation, lease settling, RPC all stop) until a manual restart.\n- Network-scale amplification: because every node auto-syncs every peer it sees, one malicious peer can crash every node that dials it, and can re-crash them on every reconnect.\n\n## Suggested fix\n- Add a nil guard in the `requestSync` iteration at net/sync.go:589-594 (skip or reject `b == nil`), matching `blockValidator`'s nil rejection at net/gossip_validate.go:70. Ideally reject the whole page (`return fmt.Errorf(\"sync: nil block in response\")`) so a malformed peer is dropped rather than silently tolerated.\n- Defense-in-depth: recover() around the `requestSync` goroutines (net/sync.go:320-326, 345-384) so a decode/parse panic degrades to dropping that peer instead of killing the process.\n\n## Verification notes\n- I confirmed the mechanism by building and running the decode→iterate path against the exact wire payload `{\"blocks\":[null],\"has_more\":false}`: it decodes to one nil `*core.Block` with no error, and the reproduce-loop panics with `runtime error: invalid memory address or nil pointer dereference`.\n- I confirmed `net/sync.go` contains no `recover()`, and that `requestSync` is spawned on a bare goroutine from `ConnectedF`.\n- I did not run a live two-node sync to observe the process exit; the PoC exercises the exact code path and reproduces the panic message. Reaching it over the wire requires the victim to dial the attacker (which it does automatically for every connected/known peer).","patch_refs":[],"thread":[{"id":13268,"source":"desk","source_ref":"reply:11290","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-11679 and says what differs; it is read like any other.","created_at":"2026-11-20T00:33:21.596304+00:00"}]}