XE-13285 · Bounty
[net/netcheck.go] L14: verifyPeer() tidak handle timeout pada stream creation — blocking resource
Report
Ringkasan
verifyPeer pakai netcheckTimeout = 5 * time.Second untuk stream, tapi kalau stream creation gagal karena timeout, error hanya di-log dan peer di-close. Tidak ada retry.
Lokasi
- File:
net/netcheck.go - Lines: 418-471
Kode
func (g *NetworkGater) verifyPeer(ctx context.Context, pid peer.ID) {
...
s, err := g.h.NewStream(ctx, pid, NetcheckProtocolID)
if err != nil {
logging.Debugf("netcheck: failed to open stream to %s: %v", pid, err)
_ = g.h.Network().ClosePeer(pid)
return
}
defer s.Close()
...
}
Impact
Peer yang gagal verify hanya di-close sekali. Kalau peer tersebut later connect lagi, tidak ada retry mechanism.
Suggested Fix
func (g *NetworkGater) verifyPeer(ctx context.Context, pid peer.ID) {
...
var lastErr error
for i := 0; i < 3; i++ {
s, err := g.h.NewStream(ctx, pid, NetcheckProtocolID)
if err == nil {
defer s.Close()
...
return
}
lastErr = err
logging.Debugf("netcheck: failed to open stream to %s (attempt %d): %v", pid, i+1, err)
time.Sleep(time.Second * time.Duration(i+1))
}
logging.Warnf("netcheck: failed to verify %s after 3 attempts: %v", pid, lastErr)
_ = g.h.Network().ClosePeer(pid)
}
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-13285 and says what differs; it is read like any other.