<!-- XE-13289 · [net/host.go] M3: discoveryNotifee tidak rate-limit — resource exhaustion via mDNS flooding · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13289>. The page is the record; this is the same page for reading.*

XE-13289 · Bounty

# \[net/host.go\] M3: discoveryNotifee tidak rate-limit — resource exhaustion via mDNS flooding

Closed · duplicate
—
[xe#434](https://github.com/xeprotocol/xe/issues/434)
filed 2026-11-12 02:51 UTC
by wahyu20260100233-ops

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   P2P / sync

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 00:38 UTC

Told
:   2026-11-20 00:34 UTC

### Patches

None linked.

### History

- [554079](https://bounty.xe.network/log/554079) 2026-11-20 00:35 UTC github.state\_pushed
- [554077](https://bounty.xe.network/log/554077) 2026-11-20 00:35 UTC github.labels
- [554022](https://bounty.xe.network/log/554022) 2026-11-20 00:34 UTC reply.mirrored
- [552700](https://bounty.xe.network/log/552700) 2026-11-20 00:33 UTC proposal.adopted
- [552699](https://bounty.xe.network/log/552699) 2026-11-20 00:33 UTC reply.sent
- [552698](https://bounty.xe.network/log/552698) 2026-11-20 00:33 UTC ticket.status new → closed
- [552129](https://bounty.xe.network/log/552129) 2026-11-20 00:33 UTC proposal.adopted
- [552128](https://bounty.xe.network/log/552128) 2026-11-20 00:33 UTC ticket.facts area
- [552127](https://bounty.xe.network/log/552127) 2026-11-20 00:33 UTC proposal.adopted
- [552126](https://bounty.xe.network/log/552126) 2026-11-20 00:33 UTC ticket.facts
- [552125](https://bounty.xe.network/log/552125) 2026-11-20 00:33 UTC proposal.adopted
- [552124](https://bounty.xe.network/log/552124) 2026-11-20 00:33 UTC ticket.facts

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

### Report

## Ringkasan

Setiap peer yang ditemukan via mDNS langsung di-connect. Tidak ada rate-limit, debounce, atau cek apakah sudah connected. mDNS flooding bisa menyebabkan banyak connect attempt.

## Lokasi

- File: `net/host.go`
- Lines: 196-209

## Kode

```
func (n *discoveryNotifee) HandlePeerFound(pi peer.AddrInfo) {
    if pi.ID == n.h.ID() {
        return
    }
    if err := n.h.Connect(n.ctx, pi); err != nil {
        logging.Warnf("Failed to connect to %s: %v", pi.ID.ShortString(), err)
    }
}
```

## Impact

mDNS flooding bisa menyebabkan banyak connect attempt sekaligus. Resource exhaustion (goroutine, connection).

## Suggested Fix

```
type discoveryNotifee struct {
    h       host.Host
    ctx     context.Context
    mu      sync.Mutex
    lastConnect map[peer.ID]time.Time
    rateLimit  time.Duration
}

func (n *discoveryNotifee) HandlePeerFound(pi peer.AddrInfo) {
    if pi.ID == n.h.ID() {
        return
    }
    n.mu.Lock()
    if last, ok := n.lastConnect[pi.ID]; ok && time.Since(last) < n.rateLimit {
        n.mu.Unlock()
        return
    }
    n.lastConnect[pi.ID] = time.Now()
    n.mu.Unlock()

    if n.h.Network().Connectedness(pi.ID) == network.Connected {
        return
    }
    if err := n.h.Connect(n.ctx, pi); err != nil {
        logging.Warnf("Failed to connect to %s: %v", pi.ID.ShortString(), err)
    }
}
```

### Thread

**Joseph Denne**team2026-11-20 00:34 UTCgithub

Thanks. This is the same finding as an earlier report that is not public, 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-13289 and says what differs; it is read like any other.
