{"id":"XE-13286","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"431","source_url":"https://github.com/xeprotocol/xe/issues/431","reporter_id":2483,"title":"[net/netcheck.go] L15: handleNetcheckInbound() tidak handle concurrent requests — potensi race","area":"p2p-sync","claimed_tier":null,"assessed_tier":null,"verdict":"invalid","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"invalid","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:07.331196+00:00","updated_at":"2026-11-20T00:51:11.233959+00:00","source_created_at":"2026-11-12T02:50:21+00:00","told_at":"2026-11-20T00:49:21+00:00","status_changed_at":"2026-11-20T00:33:25.753744+00:00","url":"https://bounty.xe.network/XE-13286","body":"## Ringkasan\nStream handler di-register tanpa mutex protection. Kalau multiple stream datang bersamaan, handler dijalankan secara concurrent. Tidak ada issue yang ditemukan, tapi worth noting.\n\n## Lokasi\n- File: `net/netcheck.go`\n- Lines: 391-416\n\n## Kode\n```go\nfunc (g *NetworkGater) SetupNetcheckHandler(h host.Host, gater *NetworkGater) {\n    h.SetStreamHandler(NetcheckProtocolID, func(s network.Stream) {\n        defer func() { _ = s.Close() }()\n        g.handleNetcheckInbound(s)\n    })\n}\n\nfunc (g *NetworkGater) handleNetcheckInbound(s network.Stream) {\n    ...\n    // handler dijalankan tanpa mutex protection\n}\n```\n\n## Impact\nKalau multiple stream datang bersamaan, handler dijalankan secara concurrent. Meskipun saat ini tidak ada issue yang ditemukan, handler harus thread-safe.\n\n## Suggested Fix\nDocument bahwa handler harus thread-safe, atau tambah mutex protection:\n```go\nfunc (g *NetworkGater) handleNetcheckInbound(s network.Stream) {\n    g.mu.Lock()\n    defer g.mu.Unlock()\n    ...\n}\n```\n\nAtau lebih baik: gunakan goroutine per stream dan jangan pakai shared state tanpa synchronization.\n```go\nfunc (g *NetworkGater) SetupNetcheckHandler(h host.Host, gater *NetworkGater) {\n    h.SetStreamHandler(NetcheckProtocolID, func(s network.Stream) {\n        defer func() { _ = s.Close() }()\n        go g.handleNetcheckInbound(s)  // setiap stream di-handle di goroutine terpisah\n    })\n}\n```","patch_refs":[],"thread":[{"id":13354,"source":"github","source_ref":"7026789755","author":"XE desk","team":true,"body":"Thanks for the report. We read it against the code and could not confirm a bug in what it describes.\n\nThis report is closed as invalid. If we have missed something, file a new report that links\nhttps://bounty.xe.network/XE-13286 and says what; it is read like any other.","created_at":"2026-11-20T00:49:21+00:00"}]}