{"id":"XE-16737","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"655","source_url":"https://github.com/xeprotocol/xe/issues/655","reporter_id":2920,"title":"[Minor] Binary codecs accept non-canonical encodings: UnmarshalBlock ignores trailing garbage, DecodeVote accepts any nonzero final byte","area":"consensus","claimed_tier":"minor","assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0945","tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-17T05:39:00.483464+00:00","updated_at":"2026-11-22T23:26:16.743788+00:00","source_created_at":"2026-11-17T05:38:21+00:00","told_at":"2026-11-22T23:26:16.757136+00:00","status_changed_at":"2026-11-22T23:26:16.748848+00:00","url":"https://bounty.xe.network/XE-16737","body":"## Summary\nNeither binary decoder enforces canonical form: `UnmarshalBlock` never rejects trailing bytes, and `DecodeVote` accepts 255 distinct \"final\" byte values. Multiple distinct byte strings therefore decode to the same block/vote, breaking byte-level identity for any future binary consumer, debug tool, or port that assumes decode->encode round-trip parity.\n\n## Root Cause\n- `unmarshalBlock` (`core/encoding.go:545-549`): after the memo/timing tail, the nonce is read only `if len(data) == tailOffset+8`; any other trailing length is silently ignored -- no length check rejects trailing garbage.\n- `DecodeVote` (`core/encoding.go:719`): `final := data[137] != 0` -- any nonzero byte decodes as `Final=true`, while `EncodeVote` writes `0x01`.\n\n## Impact\nLatent at HEAD: the binary codec has no callers outside `core/encoding.go` (JSON is the wire/store format), so there is no attacker-reachable trigger today. It breaks byte-level identity for any future binary consumer -- the same reasoning #100/#563 were accepted under.\n\n## Verification (executed, deterministic)\nDirected tests against a valid canonical send block with 2, 7, 9, and 100 trailing bytes appended: all decode successfully to the identical block (\"trailing N bytes silently ignored\"). A vote with final byte `0x02` decodes to `Final=true` and re-encodes to the same bytes as the `0x01` original. The fuzzer independently found the same defect (`FuzzDecodeVote` failed in 12s on an input with final byte `0x30`). Audited at HEAD `8cc209d` (testnet-0006).\n\n## Note on related reports\nDistinct from #563 (DecodeVote *panic* via uint16 wraparound -- different defect, same function), #100 (PoWNonce drop on round-trip -- different defect, same file), and #8 (vote *hex* malleability -- JSON hex case, different mechanism).\n\n## Suggested fix\nIn `unmarshalBlock`, reject `len(data)` that is neither `tailOffset` nor `tailOffset+8`. In `DecodeVote`, reject `data[137]` values other than `0x00`/`0x01`.","patch_refs":[],"thread":[{"id":18871,"source":"desk","source_ref":"reply:16548","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0945, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-16737 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:16.743788+00:00"}]}