Bounty
XE-11679 · Bounty

[node,net] Remote unauthenticated node-crash: sync client dereferences a JSON null block with no nil check and no recover

Closed · duplicate —claimed High web filed 2026-11-13 07:28 UTC by bobskey

Report

Remote unauthenticated node-crash: sync client dereferences a JSON null block with no nil check and no recover.

Summary

Every 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:

allBlocks = append(allBlocks, resp.Blocks...)   // net/sync.go:571
...
filtered := allBlocks[:0]
for _, b := range allBlocks {
    if quarantine.contains(b.Hash) {            // net/sync.go:592 — b is *core.Block, nil-able
        skipped++
    } else {

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.

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.

Remote reachability

  • 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).
  • 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).

Affected code

  • net/sync.go:589-594 — the unguarded for _, b := range allBlocks { ... b.Hash ... } loop
  • net/sync.go:571 — allBlocks = append(allBlocks, resp.Blocks...)
  • net/messages.go:22 — Blocks []*core.Block \json:"blocks"``
  • net/sync.go:320-326 — ConnectedF spawning requestSync on a bare goroutine (no recover)

Reproduction

PoC of the exact decode→iterate path (runnable):

// net/poc_sync_nullblock_test.go
func Test_PoC_SyncNullBlockNilDeref(t *testing.T) {
    defer func() {
        if r := recover(); r != nil { t.Logf("PANIC CONFIRMED (node crash): %v", r); return }
        t.Error("no panic - guard exists; inspect")
    }()
    page := []byte(`{"blocks":[null],"has_more":false}`)
    var resp net.SyncResponse
    if err := json.NewDecoder(bytes.NewReader(page)).Decode(&resp); err != nil {
        t.Fatalf("decode: %v (json null should decode with no error)", err)
    }
    var allBlocks []*core.Block
    allBlocks = append(allBlocks, resp.Blocks...)
    filtered := allBlocks[:0]
    for _, b := range allBlocks {
        if b.Hash == "" { continue }   // b is nil here -> nil-pointer dereference
        filtered = append(filtered, b)
    }
}

go test ./net/ -run Test_PoC_SyncNullBlockNilDeref -v output:

poc_sync_nullblock_test.go:46: decoded 1 blocks; blocks[0]==nil? true
poc_sync_nullblock_test.go:34: PANIC CONFIRMED (node crash): runtime error: invalid memory address or nil pointer dereference

Impact

  • 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.
  • 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.

Suggested fix

  • 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.
  • 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.

Verification notes

  • 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.
  • I confirmed net/sync.go contains no recover(), and that requestSync is spawned on a bare goroutine from ConnectedF.
  • 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).

Thread

Joseph Denneteam2026-11-20 00:33 UTCdesk

Thanks. This is the same finding as https://bounty.xe.network/XE-0002, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-11679 and says what differs; it is read like any other.