<!-- XE-13286 · [net/netcheck.go] L15: handleNetcheckInbound() tidak handle concurrent requests — potensi race · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13286>. The page is the record; this is the same page for reading.*

XE-13286 · Bounty

# \[net/netcheck.go\] L15: handleNetcheckInbound() tidak handle concurrent requests — potensi race

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

Verdict
:   Invalid

Tier
:   —

Claimed
:   —

Area
:   P2P / sync

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 00:51 UTC

Told
:   2026-11-20 00:49 UTC

### Patches

None linked.

### History

- [557250](https://bounty.xe.network/log/557250) 2026-11-20 00:49 UTC reply.mirrored
- [557053](https://bounty.xe.network/log/557053) 2026-11-20 00:48 UTC reply.sent
- [554054](https://bounty.xe.network/log/554054) 2026-11-20 00:35 UTC github.state\_pushed
- [554053](https://bounty.xe.network/log/554053) 2026-11-20 00:35 UTC github.labels
- [553326](https://bounty.xe.network/log/553326) 2026-11-20 00:33 UTC proposal.adopted
- [553114](https://bounty.xe.network/log/553114) 2026-11-20 00:33 UTC proposal.adopted
- [553113](https://bounty.xe.network/log/553113) 2026-11-20 00:33 UTC ticket.status new → closed
- [552501](https://bounty.xe.network/log/552501) 2026-11-20 00:33 UTC proposal.adopted
- [552500](https://bounty.xe.network/log/552500) 2026-11-20 00:33 UTC ticket.facts area
- [552496](https://bounty.xe.network/log/552496) 2026-11-20 00:33 UTC proposal.adopted
- [552495](https://bounty.xe.network/log/552495) 2026-11-20 00:33 UTC ticket.facts
- [551144](https://bounty.xe.network/log/551144) 2026-11-20 00:31 UTC note.added

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

### Report

## Ringkasan

Stream handler di-register tanpa mutex protection. Kalau multiple stream datang bersamaan, handler dijalankan secara concurrent. Tidak ada issue yang ditemukan, tapi worth noting.

## Lokasi

- File: `net/netcheck.go`
- Lines: 391-416

## Kode

```
func (g *NetworkGater) SetupNetcheckHandler(h host.Host, gater *NetworkGater) {
    h.SetStreamHandler(NetcheckProtocolID, func(s network.Stream) {
        defer func() { _ = s.Close() }()
        g.handleNetcheckInbound(s)
    })
}

func (g *NetworkGater) handleNetcheckInbound(s network.Stream) {
    ...
    // handler dijalankan tanpa mutex protection
}
```

## Impact

Kalau multiple stream datang bersamaan, handler dijalankan secara concurrent. Meskipun saat ini tidak ada issue yang ditemukan, handler harus thread-safe.

## Suggested Fix

Document bahwa handler harus thread-safe, atau tambah mutex protection:

```
func (g *NetworkGater) handleNetcheckInbound(s network.Stream) {
    g.mu.Lock()
    defer g.mu.Unlock()
    ...
}
```

Atau lebih baik: gunakan goroutine per stream dan jangan pakai shared state tanpa synchronization.

```
func (g *NetworkGater) SetupNetcheckHandler(h host.Host, gater *NetworkGater) {
    h.SetStreamHandler(NetcheckProtocolID, func(s network.Stream) {
        defer func() { _ = s.Close() }()
        go g.handleNetcheckInbound(s)  // setiap stream di-handle di goroutine terpisah
    })
}
```

### Thread

**XE desk**team2026-11-20 00:49 UTCgithub

Thanks for the report. We read it against the code and could not confirm a bug in what it describes.

This report is closed as invalid. If we have missed something, file a new report that links
https://bounty.xe.network/XE-13286 and says what; it is read like any other.
