{"id":"XE-13282","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"427","source_url":"https://github.com/xeprotocol/xe/issues/427","reporter_id":2483,"title":"[net/msg.go] L11: handleMessage() tidak handle partial message — potensi data loss","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.231739+00:00","updated_at":"2026-11-20T00:51:11.796688+00:00","source_created_at":"2026-11-12T02:49:46+00:00","told_at":"2026-11-20T00:49:23+00:00","status_changed_at":"2026-11-20T00:33:25.814510+00:00","url":"https://bounty.xe.network/XE-13282","body":"## Ringkasan\nKalau message ter-cut (partial), hanya msgType yang dibaca dan payload di-ignore. Tidak ada mechanism untuk handle partial message atau request retransmission.\n\n## Lokasi\n- File: `net/msg.go`\n- Lines: 100-105\n\n## Kode\n```go\nfunc (m *Messenger) handleMessage(raw []byte) {\n    if len(raw) < 1 {\n        return\n    }\n    msgType := string(raw[0])\n    payload := raw[1:]\n    handler, ok := m.getHandler(msgType)\n    if !ok {\n        return\n    }\n    go handler(peer.ID(raw[0:32]), payload)  // payload bisa partial\n}\n```\n\n## Impact\nData loss kalau message ter-cut. Handler menerima payload yang tidak lengkap.\n\n## Suggested Fix\nImplement message framing dengan length-prefix:\n```go\nfunc (m *Messenger) handleMessage(raw []byte) {\n    if len(raw) < 1 {\n        return\n    }\n    msgType := raw[0]\n    \n    // read length dari 4 byte berikutnya\n    if len(raw) < 5 {\n        // partial message, simpan di buffer\n        m.partialBuffer = append(m.partialBuffer, raw...)\n        return\n    }\n    length := binary.BigEndian.Uint32(raw[1:5])\n    if uint32(len(raw)-5) < length {\n        // partial message, simpan di buffer\n        m.partialBuffer = append(m.partialBuffer, raw...)\n        return\n    }\n    payload := raw[5 : 5+length]\n    handler, ok := m.getHandler(string(msgType))\n    if !ok {\n        return\n    }\n    go handler(peer.ID(raw[5+length : 5+length+32]), payload)\n}\n```","patch_refs":[],"thread":[{"id":13357,"source":"github","source_ref":"7026790670","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-13282 and says what; it is read like any other.","created_at":"2026-11-20T00:49:23+00:00"}]}