{"id":"XE-13289","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"434","source_url":"https://github.com/xeprotocol/xe/issues/434","reporter_id":2483,"title":"[net/host.go] M3: discoveryNotifee tidak rate-limit — resource exhaustion via mDNS flooding","area":"p2p-sync","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:07.381720+00:00","updated_at":"2026-11-20T00:38:16.916317+00:00","source_created_at":"2026-11-12T02:51:09+00:00","told_at":"2026-11-20T00:34:56+00:00","status_changed_at":"2026-11-20T00:33:21.263131+00:00","url":"https://bounty.xe.network/XE-13289","body":"## Ringkasan\nSetiap 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.\n\n## Lokasi\n- File: `net/host.go`\n- Lines: 196-209\n\n## Kode\n```go\nfunc (n *discoveryNotifee) HandlePeerFound(pi peer.AddrInfo) {\n    if pi.ID == n.h.ID() {\n        return\n    }\n    if err := n.h.Connect(n.ctx, pi); err != nil {\n        logging.Warnf(\"Failed to connect to %s: %v\", pi.ID.ShortString(), err)\n    }\n}\n```\n\n## Impact\nmDNS flooding bisa menyebabkan banyak connect attempt sekaligus. Resource exhaustion (goroutine, connection).\n\n## Suggested Fix\n```go\ntype discoveryNotifee struct {\n    h       host.Host\n    ctx     context.Context\n    mu      sync.Mutex\n    lastConnect map[peer.ID]time.Time\n    rateLimit  time.Duration\n}\n\nfunc (n *discoveryNotifee) HandlePeerFound(pi peer.AddrInfo) {\n    if pi.ID == n.h.ID() {\n        return\n    }\n    n.mu.Lock()\n    if last, ok := n.lastConnect[pi.ID]; ok && time.Since(last) < n.rateLimit {\n        n.mu.Unlock()\n        return\n    }\n    n.lastConnect[pi.ID] = time.Now()\n    n.mu.Unlock()\n    \n    if n.h.Network().Connectedness(pi.ID) == network.Connected {\n        return\n    }\n    if err := n.h.Connect(n.ctx, pi); err != nil {\n        logging.Warnf(\"Failed to connect to %s: %v\", pi.ID.ShortString(), err)\n    }\n}\n```","patch_refs":[],"thread":[{"id":13261,"source":"github","source_ref":"7026489229","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-13289 and says what differs; it is read like any other.","created_at":"2026-11-20T00:34:56+00:00"}]}