{"id":"XE-0136","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"228","source_url":"https://github.com/xeprotocol/xe/issues/228","reporter_id":44,"title":"[Track 1 Bug Bounty] Directory-gossip panic still reproduces on master 9787859 — #15/#89 fix incomplete: unauthenticated remote node crash, gossip-propagated","area":"p2p-sync","claimed_tier":null,"assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-31T07:48:30.847994+00:00","updated_at":"2026-11-10T00:11:46.746540+00:00","source_created_at":"2026-10-31T07:47:37+00:00","told_at":"2026-11-08T09:36:09+00:00","status_changed_at":"2026-11-08T09:35:47.651171+00:00","url":"https://bounty.xe.network/XE-0136","body":"[Track 1 Bug Bounty] Directory-gossip panic still reproduces on master 9787859 — #15/#89 fix incomplete: unauthenticated remote node crash, gossip-propagated\n\n## Summary\n\nThe 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.\n\n`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.\n\n## Live reproduction on master 9787859\n\nBuilt `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.\n\nCraft a registration with `node_peer = \"a\"`, signed by any fresh keypair (network id adopted from `GET /node`), and POST it to A:\n\n```\nnetwork_id: testnet\naccount=f731da7f… node_peer=\"a\" len=1\nPOST status: 200 OK {\"ok\":true}\n```\n\nBoth nodes die. Node A (the POST target) and node B (the remote peer that received no HTTP request at all):\n\n```\nA: curl -s -m 3 http://127.0.0.1:9301/node  → connection refused (DEAD)\nB: curl -s -m 3 http://127.0.0.1:9401/node  → connection refused (DEAD)\n\nB log:\npanic: runtime error: slice bounds out of range [:12] with length 1\n\ngoroutine 263 [running]:\ngithub.com/xeprotocol/xe/node.(*Node).handleDirectoryGossip(0x121d1dc64a08, 0x121d1ddf5c00)\n\t.../node/node.go:2381 +0x209\ngithub.com/xeprotocol/xe/node.New.func30()\n\t.../node/node.go:575 +0x72\ncreated by github.com/xeprotocol/xe/node.New in goroutine 1\n\t.../node/node.go:575 +0x36ed\n```\n\nAlso reproduced single-node on ports 9101 and 9201 earlier in the session — three independent crashes, identical stack.\n\n## Affected code\n\n`node/node.go:2376-2384` — the panic site (goroutine spawned at `node/node.go:575`, no `recover()` anywhere on it):\n\n```go\nfunc (n *Node) handleDirectoryGossip(regs <-chan *directory.Registration) {\n\tfor reg := range regs {\n\t\tif err := n.Directory.Register(reg); err != nil {\n\t\t\tlogging.Warnf(...)\n\t\t} else {\n\t\t\tlogging.Debugf(\"directory: accepted registration for %s on %s\",\n\t\t\t\tshortAddr(reg.Account), reg.NodePeer[:12])   // <-- panics when len(NodePeer) < 12\n\t\t}\n\t}\n}\n```\n\n`directory/verify.go:36-38` — the only length-adjacent check in the path:\n\n```go\nif reg.NodePeer == \"\" {\n\treturn fmt.Errorf(\"missing node_peer\")\n}\n```\n\n`net/gossip_validate.go:149-151` — the gossip validator, same gap:\n\n```go\nif reg.Account == \"\" || reg.PubKey == \"\" || reg.Signature == \"\" || reg.NodePeer == \"\" {\n\treturn pubsub.ValidationReject\n}\n```\n\n`node/node.go:2429` — `RegisterAccount` republishes every accepted registration to the directory gossip topic, which is what carries the poisoned registration to peers.\n\n## Attack vectors\n\n1. **HTTP**: unauthenticated `POST /directory/register` with a 1-char `node_peer` and a valid self-signature. `RegisterAccount` republishes it to gossip.\n2. **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.\n\nThe 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.\n\n## Why this is not a duplicate of closed #15/#89\n\nBoth 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.\n\n## Impact\n\nUnauthenticated 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.\n\n## Suggested fix\n\nGuard the slice and enforce a minimum peer-id length at validation time so bad registrations never enter the directory:\n\n```go\npeer := reg.NodePeer\nif len(peer) > 12 {\n\tpeer = peer[:12]\n}\nlogging.Debugf(\"directory: accepted registration for %s on %s\", shortAddr(reg.Account), peer)\n```\n\nplus a length check in `VerifyRegistration` / `directoryValidator` (a libp2p peer id is 52+ chars), and a `recover()` on the gossip goroutine as defense in depth.\n\n## Severity\n\nSevere — remote, unauthenticated, network-wide availability loss, matching the original #15 ruling (anchor: #15's Severe, not the #14 panic family's Medium→High).\n\n## Affected version\n\nmaster `9787859` (release: testnet-0005 recovery phrase v2) — the commit the triage doc cites as `master` while marking #15/#89 fixed.\n\nResearcher: oxcode\n","patch_refs":[{"id":231,"repo":"xeprotocol/xe","kind":"pr","ref":"230","title":"fix(directory): prevent unauthenticated remote crash via short NodePeer in handleDirectoryGossip (fixes #228)","url":"https://github.com/xeprotocol/xe/pull/230","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-10-31T08:54:21.056191+00:00"},{"id":235,"repo":"xeprotocol/xe","kind":"pr","ref":"234","title":"","url":"https://github.com/xeprotocol/xe/pull/234","note":"","state":"open","author":"","added_by":"desk","created_at":"2026-10-31T12:34:37.107877+00:00"}],"thread":[{"id":816,"source":"github","source_ref":"6719885329","author":"Joseph Denne","team":true,"body":"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.","created_at":"2026-11-08T09:36:09+00:00"}]}