Bounty
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

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