net/sync: a nil block element in a SyncResponse panics the node; no recover() on the sync path (High)
Report
Nil block element in a sync response panics the node; no recover() on the sync path
Summary
Any peer that connects to a node can kill it with a 22-byte payload. The sync client
decodes a SyncResponse whose Blocks field is []*core.Block, so a JSON null
element becomes a nil pointer, and net/sync.go:592 dereferences it before any
signature, PoW or account check runs. The panic escapes the goroutine because the
sync stream handler and spawnGate.spawn have no recover(), so the process dies
with SIGSEGV. I reproduced this three times against a node running the pinned
revision, with a control test showing that a well-formed response leaves the node
alive.
Details
- Type: nil pointer dereference, uncaught exception (CWE-248, CWE-476)
- Asset:
test.network, P2P port 9000, protocol/xe/sync/1.0.0 - Endpoint:
net/sync.go:592inrequestSync - Auth required: none. No account, signature, lease, balance or PoW.
- Source revision:
xeprotocol/xe@978785929bc17a2f4ab30c383e5fc9cf4d634512 - Severity claimed: High. The programme's High tier covers "Targeted DoS ... sustained degradation a single client can cause". I am not claiming Severe: what I proved is a single-node crash with a crash-loop path, not a network-wide finality stall.
Root cause
net/messages.go:21-26 declares the response type with a pointer slice:
type SyncResponse struct {
Blocks []*core.Block `json:"blocks"`
HasMore bool `json:"has_more"`
Cursor string `json:"cursor"`
Rejected []string `json:"rejected,omitempty"`
}
A JSON element of null decodes to a nil pointer. Three sinks dereference it with no
guard:
| Location | Code |
|---|---|
net/sync.go:592 |
if quarantine.contains(b.Hash) |
net/sync.go:604 |
ledger.AddSyncedBlock(b), which reaches core/ledger.go:740 (bc := *b) |
statechain/sync.go:178 |
chain.AddBlock(b), which reaches HashBlock(nil) |
Five of the seven wire-block consumers in the codebase already guard against nil. The two sync sinks do not:
| Site | Nil guard |
|---|---|
net/gossip_validate.go:70 (blockValidator) |
yes |
net/gossip_validate.go:107 (voteValidator) |
yes |
net/gossip_validate.go:131 (stateChainValidator) |
yes |
net/gossip_validate.go:186 (marketplaceValidator) |
yes |
net/blocksync.go:80 |
yes, if b == nil || !want[b.Hash] |
net/sync.go:592 |
no |
statechain/sync.go:178 |
no |
The message handler has a recover() at net/msg.go:69-73. The sync stream handler
(net/sync.go:311-318) and spawnGate.spawn (net/sync.go:403-406) do not, so a
panic on that path terminates the process instead of one stream.
Steps to reproduce
Environment: 29 October 2026, Go 1.25.0 linux/arm64, node built from the pinned
revision with go build -ldflags "-X main.version=1.0.0" -o xe-node ./cmd/xe.
The PoC runs two libp2p hosts. The victim uses the production xenet.SetupSync. The
attacker answers any sync request with a nil block element.
- Start the victim node with the production sync setup.
- Connect the attacker peer to the victim.
- The victim's
ConnectedFnotification fires and dials the attacker back, which starts a sync round. - The attacker replies with
{"blocks":[null],"has_more":false,"cursor":""}. - The victim panics.
Observed output, identical across three consecutive runs:
victim node id=12*7zgQ1T
attacker peer id=12*gbh77t
attacker connected to victim, waiting for ConnectedF dial-back
attacker: replying with nil block element
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x138 pc=0x9c384c]
github.com/xeprotocol/xe/net.requestSync(...)
net/sync.go:592 +0x71c
github.com/xeprotocol/xe/net.SetupSync.func2.1()
net/sync.go:326 +0x8c
github.com/xeprotocol/xe/net.(*spawnGate).spawn.func1()
net/sync.go:405 +0x50
created by github.com/xeprotocol/xe/net.(*spawnGate).spawn
net/sync.go:403 +0x174
Exit code 2, SIGSEGV address 0x138, same stack frames, same line numbers, all three
runs.
Control test: the same PoC with the attacker replying {"blocks":[],"has_more":false}
leaves the node running with no errors. The nil element is the specific cause.
Reachability
The server-side handler handleSyncStream never parses a SyncResponse; it only emits
blocks from its own ledger, so it cannot be the entry point. The vulnerable parse is in
requestSync, the client side, which runs from ConnectedF. Any peer that merely
connects to a node makes that node dial it back and start a sync round, so the victim
never chooses the peer it syncs against. This makes the bug easier to reach than a
server-side handler would be.
Impact
Shown:
- One 22-byte payload from any peer terminates the node process. No account, signature, lease, balance or PoW is needed.
deploy/xe-node.service:24setsRestart=alwayswithRestartSec=5s, andnet/sync.go:27setssyncCooldown = 5 * time.Second. A peer that reconnects every 5 seconds restarts the node as fast as the supervisor restarts it, so the node never reaches the point of serving sync.deploy/monitoring/alerts.yml:97notes that a restart rebuilds the weights, so the node loses accumulated state on each cycle.
Not shown:
- No network-wide finality stall was demonstrated. I am not claiming the Severe tier.
- No funds, keys or ledger state were affected. The panic happens before any signature is persisted.
Remediation
Guard every wire-sourced block pointer, matching the sibling handler:
for _, b := range resp.Blocks {
if b == nil {
continue
}
...
}
Apply at net/sync.go:592, net/sync.go:604 (or inside AddSyncedBlock), and
statechain/sync.go:178. Adding a recover() to the sync stream handler, as
net/msg.go:69 does for the message handler, would contain any future panic on that
path, but the nil guard is the fix.
Notes
- Tested on testnet only. No funds were moved and no other node was attacked; the node that crashed was my own, and the crash path is the production sync code.
- The PoC is deterministic: one run succeeds, three consecutive runs produce identical exit codes and stack traces, and the control survives.
Thread
Submitted architectural fix and comprehensive regression test suite in #182.
Resolves the unauthenticated DoS crash by introducing zero-allocation in-place nil block filtering (dropNilBlocks) with aggregated warning rate-limits, defensive applySyncedBlocks checks, and panic recovery guards across spawnGate.spawn, libp2p stream handlers, and sync worker goroutines. Verified on native Linux Go 1.27.3 with full test suite passing in 0.067s.
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-0107 and says what differs; it is read like any other.