XE-13289 · Bounty
[net/host.go] M3: discoveryNotifee tidak rate-limit — resource exhaustion via mDNS flooding
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 Denneteam2026-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.