Bounty
XE-13274 · Bounty

[net/msg.go] L3: Handle() tidak check empty msgType — silent registration of empty key

Closed · invalid — xe#419 filed 2026-11-12 02:48 UTC by wahyu20260100233-ops

Report

Ringkasan

Tidak ada check apakah msgType adalah empty string. Kalau empty, handler di-register dengan key kosong dan tidak bisa dipanggil dari handleMessage (yang cuma baca 1 byte).

Lokasi

  • File: net/msg.go
  • Lines: 147-151

Kode

func (m *Messenger) Handle(msgType string, handler func(peer.ID, json.RawMessage) (json.RawMessage, error)) {
    m.mu.Lock()
    m.handlers[msgType] = handler
    m.mu.Unlock()
}

Impact

Handler dengan key kosong tidak bisa di-invoke. Resource waste.

Suggested Fix

func (m *Messenger) Handle(msgType string, handler func(peer.ID, json.RawMessage) (json.RawMessage, error)) {
    if msgType == "" {
        logging.Warnf("msg: attempt to register handler with empty msgType")
        return
    }
    m.mu.Lock()
    m.handlers[msgType] = handler
    m.mu.Unlock()
}

Thread

XE deskteam2026-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-13274 and says what; it is read like any other.