<!-- XE-0136 · [Track 1 Bug Bounty] Directory-gossip panic still reproduces on master 9787859 — #15/#89 fix incomplete: unauthenticated remote node crash, gossip-propagated · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0136>. The page is the record; this is the same page for reading.*

XE-0136 · Bounty

# \[Track 1 Bug Bounty\] Directory-gossip panic still reproduces on master 9787859 — #15/#89 fix incomplete: unauthenticated remote node crash, gossip-propagated

Triaging
[xe#228](https://github.com/xeprotocol/xe/issues/228)
filed 2026-10-31 07:47 UTC
by ox-code

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   —

Area
:   P2P / sync

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-10 00:11 UTC

Told
:   2026-11-08 09:36 UTC

### Patches

- [xe#230](https://github.com/xeprotocol/xe/pull/230) open by arturbarszcz78
  fix(directory): prevent unauthenticated remote crash via short NodePeer in handleDirectoryGossip (fixes #228)
- [xe#234](https://github.com/xeprotocol/xe/pull/234) open

### History

- [24094](https://bounty.xe.network/log/24094) 2026-11-08 09:36 UTC github.labels
- [24046](https://bounty.xe.network/log/24046) 2026-11-08 09:36 UTC reply.mirrored
- [24005](https://bounty.xe.network/log/24005) 2026-11-08 09:35 UTC reply.sent
- [24004](https://bounty.xe.network/log/24004) 2026-11-08 09:35 UTC proposal.adopted
- [24003](https://bounty.xe.network/log/24003) 2026-11-08 09:35 UTC proposal.adopted
- [24002](https://bounty.xe.network/log/24002) 2026-11-08 09:35 UTC ticket.status new → triaging
- [24001](https://bounty.xe.network/log/24001) 2026-11-08 09:35 UTC proposal.adopted
- [24000](https://bounty.xe.network/log/24000) 2026-11-08 09:35 UTC ticket.award
- [23999](https://bounty.xe.network/log/23999) 2026-11-08 09:35 UTC proposal.adopted
- [23998](https://bounty.xe.network/log/23998) 2026-11-08 09:35 UTC ticket.facts
- [23997](https://bounty.xe.network/log/23997) 2026-11-08 09:35 UTC proposal.adopted
- [23996](https://bounty.xe.network/log/23996) 2026-11-08 09:35 UTC ticket.facts

[Full history](https://bounty.xe.network/log?ref=XE-0136) · [JSON](https://bounty.xe.network/v1/tickets/XE-0136) · [markdown](https://bounty.xe.network/XE-0136.md)

### Report

\[Track 1 Bug Bounty\] Directory-gossip panic still reproduces on master 9787859 — #15/#89 fix incomplete: unauthenticated remote node crash, gossip-propagated

## Summary

The triage doc marks #15 ("POST /directory/register with 1-char node\_peer panics every node (NodePeer\[:12\]). Remote, unauthenticated, propagates over gossip", rated Severe) and its duplicate #89 as Fixed: #1028 → #1029. The fix is incomplete: on the exact master the triage doc references (`9787859`, "release: testnet-0005 recovery phrase v2"), the vulnerable slice is still present and nothing guards it or recovers the goroutine.

`node/node.go:2381` still slices `reg.NodePeer[:12]` unguarded inside `handleDirectoryGossip`, and `directory.VerifyRegistration` (`directory/verify.go:29-53`) plus the gossip topic validator (`net/gossip_validate.go:143-157`) only reject an *empty* `node_peer` — no minimum length exists anywhere in the path. A registration with a 1-character `node_peer` and a valid signature is accepted, published to the gossip topic, and panics every node that receives it — including nodes that never saw the HTTP request.

## Live reproduction on master 9787859

Built `xe` from this commit, ran two nodes peered over libp2p (A: `-port 9300 -api-port 9301`; B dialed A via `-dial`, `peer_count: 1` on both sides), then sent **one** HTTP request to A.

Craft a registration with `node_peer = "a"`, signed by any fresh keypair (network id adopted from `GET /node`), and POST it to A:

```
network_id: testnet
account=f731da7f… node_peer="a" len=1
POST status: 200 OK {"ok":true}
```

Both nodes die. Node A (the POST target) and node B (the remote peer that received no HTTP request at all):

```
A: curl -s -m 3 http://127.0.0.1:9301/node  → connection refused (DEAD)
B: curl -s -m 3 http://127.0.0.1:9401/node  → connection refused (DEAD)

B log:
panic: runtime error: slice bounds out of range [:12] with length 1

goroutine 263 [running]:
github.com/xeprotocol/xe/node.(*Node).handleDirectoryGossip(0x121d1dc64a08, 0x121d1ddf5c00)
	.../node/node.go:2381 +0x209
github.com/xeprotocol/xe/node.New.func30()
	.../node/node.go:575 +0x72
created by github.com/xeprotocol/xe/node.New in goroutine 1
	.../node/node.go:575 +0x36ed
```

Also reproduced single-node on ports 9101 and 9201 earlier in the session — three independent crashes, identical stack.

## Affected code

`node/node.go:2376-2384` — the panic site (goroutine spawned at `node/node.go:575`, no `recover()` anywhere on it):

```
func (n *Node) handleDirectoryGossip(regs <-chan *directory.Registration) {
	for reg := range regs {
		if err := n.Directory.Register(reg); err != nil {
			logging.Warnf(...)
		} else {
			logging.Debugf("directory: accepted registration for %s on %s",
				shortAddr(reg.Account), reg.NodePeer[:12])   // <-- panics when len(NodePeer) < 12
		}
	}
}
```

`directory/verify.go:36-38` — the only length-adjacent check in the path:

```
if reg.NodePeer == "" {
	return fmt.Errorf("missing node_peer")
}
```

`net/gossip_validate.go:149-151` — the gossip validator, same gap:

```
if reg.Account == "" || reg.PubKey == "" || reg.Signature == "" || reg.NodePeer == "" {
	return pubsub.ValidationReject
}
```

`node/node.go:2429` — `RegisterAccount` republishes every accepted registration to the directory gossip topic, which is what carries the poisoned registration to peers.

## Attack vectors

1. **HTTP**: unauthenticated `POST /directory/register` with a 1-char `node_peer` and a valid self-signature. `RegisterAccount` republishes it to gossip.
2. **Gossip-only**: any peer can publish a crafted registration directly to the directory topic — the validator's non-empty checks pass, so no HTTP endpoint is involved at all. A single malicious peer crashes every node it can reach.

The HTTP endpoint's per-IP write-bucket rate limit (`api/handler.go:314-322`, `364-373`) does not blunt either vector: the crash is single-shot, and the gossip-only path never touches the rate-limited endpoint.

## Why this is not a duplicate of closed #15/#89

Both tickets are closed on the claim that #1029 fixed the panic. This report is evidence that the fix did not land on (or did not survive into) the referenced master: on `9787859` the slice at `node/node.go:2381` is unguarded, `VerifyRegistration` and the gossip validator still accept any non-empty `node_peer`, and the goroutine at `node/node.go:575` still has no `recover()`. The published tree is a single-commit snapshot, so #1029's diff cannot be quoted here — the tree itself is the evidence: nothing in it guards the path the closed tickets describe. The same argument covers the #14 missing-recover class: this goroutine is demonstrably not recovered on the referenced master.

## Impact

Unauthenticated remote crash of any node, propagating to all peers over gossip — identical impact to #15 as originally rated (Severe), still present on the master the triage doc references. No fund or state loss (crash-restart only), so not claimed higher.

## Suggested fix

Guard the slice and enforce a minimum peer-id length at validation time so bad registrations never enter the directory:

```
peer := reg.NodePeer
if len(peer) > 12 {
	peer = peer[:12]
}
logging.Debugf("directory: accepted registration for %s on %s", shortAddr(reg.Account), peer)
```

plus a length check in `VerifyRegistration` / `directoryValidator` (a libp2p peer id is 52\+ chars), and a `recover()` on the gossip goroutine as defense in depth.

## Severity

Severe — remote, unauthenticated, network-wide availability loss, matching the original #15 ruling (anchor: #15's Severe, not the #14 panic family's Medium→High).

## Affected version

master `9787859` (release: testnet-0005 recovery phrase v2) — the commit the triage doc cites as `master` while marking #15/#89 fixed.

Researcher: oxcode

### Thread

**Joseph Denne**team2026-11-08 09:36 UTCgithub

Thank you for the follow-up. We have checked the public tree against the earlier ticket and are confirming the state of the fix across our builds; this ticket is being handled and we will update you here.
