Bounty
XE-13354 · Bounty

Report bug

Triaging xe#499 filed 2026-11-12 03:50 UTC by Gib230223

Report

XE Bounty — Laporan siap file (temuan pass 4 #4)

File issue baru di: https://github.com/xeprotocol/xe/issues/new Paste judul + isi di bawah. Akun GitHub: Gib230223.


Judul

[Low] ChatStore panics when constructed with maxPerAccount <= 0

Isi

Summary

chat.NewChatStore(maxPerAccount) takes the bound with no validation, and storeFor indexes newMsgs[s.maxPerAccount-1] whenever len(msgs) >= s.maxPerAccount. With maxPerAccount == 0, len(msgs) >= 0 is always true, so the first Store panics; with a negative value, make panics. An exported constructor that panics on a plausible misconfiguration.

Evidence

// chat/chat.go:21 — no validation of the bound:
func NewChatStore(maxPerAccount int) *ChatStore {
    return &ChatStore{
        messages:      make(map[string][]*Envelope),
        seen:          make(map[string]int64),
        maxPerAccount: maxPerAccount,
        listeners:     make([]chan *Envelope, 0),
    }
}

// chat/chat.go:72-83 — storeFor panics on maxPerAccount <= 0:
func (s *ChatStore) storeFor(account string, env *Envelope) {
    msgs := s.messages[account]
    if len(msgs) >= s.maxPerAccount {
        newMsgs := make([]*Envelope, s.maxPerAccount)
        copy(newMsgs, msgs[1:])
        newMsgs[s.maxPerAccount-1] = env
        s.messages[account] = newMsgs
    } else {
        s.messages[account] = append(msgs, env)
    }
}

Impact (Low, latent)

The only production caller passes 1000 (node/node.go:314: chat.NewChatStore(1000)), so there is no live production path today. Robustness / defense-in-depth: an exported constructor that panics on a plausible misconfiguration; one-line fix (clamp maxPerAccount to >= 1 in NewChatStore).

Reproduction (PoC)

TestPoc4ChatStoreZeroMaxPanics (package chat):

maxPerAccount=0: Store panicked as expected: runtime error: slice bounds out of range [1:0]
maxPerAccount=-1: Store panicked as expected: runtime error: makeslice: len out of range

Novelty note

No ticket covers the zero/negative-bound panic. Board greps for maxPerAccount, ChatStore panic return only XE-7038 (ChatStore dedup-set saturation halts all chat ingestion — a different mechanism, about the dedup set filling up, not the bound). GitHub search_issues for "ChatStore maxPerAccount panic" returns 0 results; the closest are #269 (flooding eviction — the rotation itself) and #256 (ANSI escapes) — neither is the zero/negative-bound panic. Checked the live bounty board (High+Medium and Minor views) and the GitHub repo issues, 2026-11-12.

Repo: github.com/xeprotocol/xe, HEAD 89a542e, testnet-0005.

Thread

Joseph Denneteam2026-11-20 00:34 UTCgithub

Thanks for the report. We have read it against the current tree and it is being handled. The assessment and any award follow the fix.

Tsaqifalk2026-11-21 13:26 UTCgithub

Omaga

rhnhabibi2026-11-21 13:43 UTCgithub

jangan asal timpa mas reportnya dibaca dulu xixixi

ddettaa2026-11-21 13:46 UTCgithub

😹😹

rhnhabibi2026-11-21 13:47 UTCgithub

lucu bgt loh rek lupa masih bahasa indo

Creepzone112026-11-21 13:53 UTCgithub

Thanks for the report. We have read it against the current tree and it is being handled. The assessment and any award follow the fix.

XE-13354 · https://bounty.xe.network/XE-13354

Njing

Gib2302232026-11-21 13:59 UTCgithub

Wey ko pada ngumpul disini cok

supercherki2026-11-21 14:00 UTCgithub

muse saya setara nasa, kamu tidak bisa mengelak

Gib2302232026-11-21 14:01 UTCgithub

Heleh Muse plenger

arashel6662026-11-21 14:12 UTCgithub

kalo nimpa dipikir mas

Gib2302232026-11-21 14:13 UTCgithub

Loh gua nimpa punya siapa gua ajh nuyuruh Muse malah d bilang nimpa kocak

erisaerisul2026-11-21 14:19 UTCgithub

saya adalah muse spark sahabat pemerintah

mmasyoga02026-11-21 17:28 UTCgithub

Ngerii