{"id":"XE-10329","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":730,"title":"Binary Codec Invariant Violation: UnmarshalBlock drops PoWNonce on BlockMultisigOpen and BlockMultisigUpdate due to static tailOffset calculation","area":"leasing-ledger","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0083","tracked":true,"internal_ref":"#1103","internal_url":"https://github.com/xeprotocol/core/issues/1103","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-12T12:05:56.605702+00:00","updated_at":"2026-11-20T00:33:17.203175+00:00","source_created_at":null,"told_at":"2026-11-20T00:33:17.223092+00:00","status_changed_at":"2026-11-20T00:33:17.211588+00:00","url":"https://bounty.xe.network/XE-10329","body":"## Vulnerability Summary\n\nIn `core/encoding.go:377-531`, `unmarshalBlock` decodes binary-encoded blocks from network streams and storage. For `BlockMultisigOpen` and `BlockMultisigUpdate`:\n\n```go\n\tcase typeByteMultisigOpen:\n\t\tblockType = BlockMultisigOpen\n\t\tminLen = fixedHeaderSize + 8 + representativeSize\n\tcase typeByteMultisigUpdate:\n\t\tblockType = BlockMultisigUpdate\n\t\tminLen = fixedHeaderSize + 8 + representativeSize\n...\n\tcase BlockMultisigOpen, BlockMultisigUpdate:\n\t\tks, ksLen, err := unmarshalKeysetCanonical(data[90:])\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"UnmarshalBlock: keyset: %w\", err)\n\t\t}\n\t\tb.MSKeyset = ks\n\t\trepOffset = 90 + ksLen\n\t\tif len(data) < repOffset+representativeSize {\n\t\t\treturn nil, fmt.Errorf(\"UnmarshalBlock: data too short for %s after keyset\", blockType)\n\t\t}\n...\n\ttailOffset := minLen\n...\n\tif len(data) == tailOffset+8 {\n\t\tb.PoWNonce = binary.LittleEndian.Uint64(data[tailOffset:])\n\t}\n```\n\nCritical codec calculation bug:\n1. Dynamic Keyset Length Ignored: When a keyset has $K$ keys, its encoded length is `ksLen = 8 + 32*K`. The representative field is placed at `repOffset = 90 + ksLen`, and the 8-byte `PoWNonce` is placed at `repOffset + 32`.\n2. Static `tailOffset`: Line 499 sets `tailOffset := minLen`, where `minLen` was statically computed with an assumed keyset size of 8 bytes (`fixedHeaderSize + 8 + representativeSize = 130`).\n3. PoW Nonce Loss & Misalignment:\n   - For any valid keyset containing at least one key ($K \\ge 1$), `len(data)` equals `130 + 32*K`. Since `130 + 32*K != 138`, the check `if len(data) == tailOffset+8` evaluates to `false`. `b.PoWNonce` is silently dropped and set to `0`.\n   - If a keyset had 0 keys ($K=0$), `tailOffset` equals 130, which points to the `Representative` field, mistakenly interpreting the representative public key bytes as the proof-of-work nonce.\n\n## Impact & Severity\n\n1. Consensus PoW Verification Failure: When binary blocks are transmitted over P2P sync and decoded via `UnmarshalBlock`, the resulting block object has `b.PoWNonce == 0`. Subsequent consensus validation in `ValidatePoW` rejects the block with `failed PoW validation`.\n2. Roundtrip Serialization Invariant Broken: `UnmarshalBlock(MarshalBlockCanonical(b))` fails roundtrip equality, corrupting multisig state during peer synchronization.\n\n## Proposed Remediation\n\nIn `core/encoding.go`, dynamically update `tailOffset` after unmarshaling the keyset:\n```go\n\tcase BlockMultisigOpen, BlockMultisigUpdate:\n\t\tks, ksLen, err := unmarshalKeysetCanonical(data[90:])\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"UnmarshalBlock: keyset: %w\", err)\n\t\t}\n\t\tb.MSKeyset = ks\n\t\trepOffset = 90 + ksLen\n\t\ttailOffset = repOffset + representativeSize\n```","patch_refs":[],"thread":[{"id":13191,"source":"desk","source_ref":"reply:11213","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0083, 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-10329 and says what differs; it is read like any other.","created_at":"2026-11-20T00:33:17.203175+00:00"}]}