<!-- XE-9889 · Unbounded State Inflation & OOM DoS: Directory.Register lacks map capacity limit permitting unauthenticated memory exhaustion · testnet -->
*Markdown view of <https://bounty.xe.network/XE-9889>. The page is the record; this is the same page for reading.*

XE-9889 · Bounty

# Unbounded State Inflation \& OOM DoS: Directory.Register lacks map capacity limit permitting unauthenticated memory exhaustion

Closed · duplicate
—
web
filed 2026-11-12 08:04 UTC
by xe:e4cd6974

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   P2P / sync

Duplicate of
:   [XE-0001](https://bounty.xe.network/XE-0001) accepted

Tracked
:   internally

Updated
:   2026-11-25 17:15 UTC

Told
:   2026-11-20 00:33 UTC

### Patches

None linked.

### History

- [552402](https://bounty.xe.network/log/552402) 2026-11-20 00:33 UTC proposal.adopted
- [552401](https://bounty.xe.network/log/552401) 2026-11-20 00:33 UTC reply.sent
- [552400](https://bounty.xe.network/log/552400) 2026-11-20 00:33 UTC ticket.status new → closed
- [551775](https://bounty.xe.network/log/551775) 2026-11-20 00:33 UTC proposal.adopted
- [551774](https://bounty.xe.network/log/551774) 2026-11-20 00:33 UTC ticket.facts area
- [551773](https://bounty.xe.network/log/551773) 2026-11-20 00:33 UTC proposal.adopted
- [551772](https://bounty.xe.network/log/551772) 2026-11-20 00:33 UTC ticket.facts
- [551771](https://bounty.xe.network/log/551771) 2026-11-20 00:33 UTC proposal.adopted
- [551770](https://bounty.xe.network/log/551770) 2026-11-20 00:33 UTC ticket.facts
- [551769](https://bounty.xe.network/log/551769) 2026-11-20 00:33 UTC proposal.adopted
- [551768](https://bounty.xe.network/log/551768) 2026-11-20 00:33 UTC ticket.facts
- [550803](https://bounty.xe.network/log/550803) 2026-11-20 00:30 UTC note.added

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

### Report

## Vulnerability Summary

In `directory/directory.go:17-50`, `Directory` manages peer routing registrations mapping accounts to libp2p peer addresses:

```
type Directory struct {
	mu            sync.RWMutex
	registrations map[string]*Registration
	ttl           time.Duration
}
```

In `directory/directory.go:35-50`:

```
func (d *Directory) Register(reg *Registration) error {
	if err := VerifyRegistration(reg); err != nil {
		return err
	}

	d.mu.Lock()
	defer d.mu.Unlock()

	existing, ok := d.registrations[reg.Account]
	if ok && existing.Timestamp >= reg.Timestamp {
		return nil
	}

	d.registrations[reg.Account] = reg
	return nil
}
```

Notice that:

1. `Directory.Register` is publicly exposed via the unauthenticated HTTP API endpoint `POST /directory/register` (`api/directory.go:11-23`) and via P2P gossip.
2. Generating a valid `directory.Registration` requires only generating an arbitrary ephemeral Ed25519 keypair in memory and signing `canonicalBytes`. It requires **zero native tokens, zero gas, zero on-chain transactions, and zero PoW**!
3. `d.registrations` has **NO capacity cap (no MaxRegistrations)**, no LRU eviction, and relies solely on passive periodic pruning (`d.Prune()`, which only evicts items older than 30 minutes).

---

## Vulnerable Code Locations

- `directory/directory.go:35-50`:
  `Directory.Register` inserts new registrations directly into `d.registrations[reg.Account]` without checking any maximum map capacity or bounding overall memory usage.
- `directory/verify.go:29-53`:
  `VerifyRegistration` checks only cryptographic Ed25519 signature validity. It does not enforce proof-of-work, account on-chain existence, or rate limiting per IP/subnet.

---

## Attack \& Failure Scenario

1. An unauthenticated attacker runs a simple script that generates ephemeral Ed25519 keypairs in a tight loop (\~5,000 to 10,000 keys per second).
2. For each keypair, the attacker sends a signed `directory.Registration` to `POST /directory/register` or floods the `/xe/dir-gossip/1.0.0` libp2p topic.
3. Every registration passes `VerifyRegistration` because the signature is mathematically valid for the newly generated ephemeral public key.
4. The node stores all incoming registrations into `d.registrations`.
5. In less than 10 minutes, the attacker floods several million unique registration objects into memory (\~1 GB to 4 GB of RAM), driving the node host into kernel Out of Memory (OOM) panic and terminating the node daemon!

---

## Impact

1. **Remote Unauthenticated Node Crash (Denial of Service)**:
   Any external entity can trigger complete OOM node crashes across all network validators and seed nodes without spending gas or solving PoW.
2. **Directory Lookup Degradation**:
   Memory bloat degrades lookup performance and list pagination (`d.List()`).

---

## Remediation

Enforce a strict maximum capacity on `d.registrations` with FIFO / LRU eviction, and require minimum proof-of-work or an active on-chain account balance to register in the directory:

```
const MaxDirectoryEntries = 50000

func (d *Directory) Register(reg *Registration) error {
	if err := VerifyRegistration(reg); err != nil {
		return err
	}

	d.mu.Lock()
	defer d.mu.Unlock()

	if len(d.registrations) >= MaxDirectoryEntries {
		d.pruneLocked()
		if len(d.registrations) >= MaxDirectoryEntries {
			return fmt.Errorf("directory full: maximum capacity reached")
		}
	}

	existing, ok := d.registrations[reg.Account]
	if ok && existing.Timestamp >= reg.Timestamp {
		return nil
	}

	d.registrations[reg.Account] = reg
	return nil
}
```

### Thread

**Joseph Denne**team2026-11-20 00:33 UTCdesk

Thanks. This is the same finding as https://bounty.xe.network/XE-0001, 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-9889 and says what differs; it is read like any other.
