<!-- XE-10329 · Binary Codec Invariant Violation: UnmarshalBlock drops PoWNonce on BlockMultisigOpen and BlockMultisigUpdate due to static tailOffset calculation · testnet -->
*Markdown view of <https://bounty.xe.network/XE-10329>. The page is the record; this is the same page for reading.*

XE-10329 · Bounty

# Binary Codec Invariant Violation: UnmarshalBlock drops PoWNonce on BlockMultisigOpen and BlockMultisigUpdate due to static tailOffset calculation

Closed · duplicate
—
web
filed 2026-11-12 12:05 UTC
by xe:e4cd6974

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   Leasing / ledger

Duplicate of
:   [XE-0083](https://bounty.xe.network/XE-0083) accepted

Tracked
:   internally

Updated
:   2026-11-20 00:33 UTC

Told
:   2026-11-20 00:33 UTC

### Patches

None linked.

### History

- [552319](https://bounty.xe.network/log/552319) 2026-11-20 00:33 UTC proposal.adopted
- [552318](https://bounty.xe.network/log/552318) 2026-11-20 00:33 UTC reply.sent
- [552317](https://bounty.xe.network/log/552317) 2026-11-20 00:33 UTC ticket.status new → closed
- [551671](https://bounty.xe.network/log/551671) 2026-11-20 00:33 UTC proposal.adopted
- [551670](https://bounty.xe.network/log/551670) 2026-11-20 00:33 UTC ticket.facts area
- [551669](https://bounty.xe.network/log/551669) 2026-11-20 00:33 UTC proposal.adopted
- [551668](https://bounty.xe.network/log/551668) 2026-11-20 00:33 UTC ticket.facts
- [551667](https://bounty.xe.network/log/551667) 2026-11-20 00:33 UTC proposal.adopted
- [551666](https://bounty.xe.network/log/551666) 2026-11-20 00:33 UTC ticket.facts
- [551665](https://bounty.xe.network/log/551665) 2026-11-20 00:33 UTC proposal.adopted
- [551664](https://bounty.xe.network/log/551664) 2026-11-20 00:33 UTC ticket.facts
- [551387](https://bounty.xe.network/log/551387) 2026-11-20 00:32 UTC note.added

[Full history](https://bounty.xe.network/log?ref=XE-10329) · [JSON](https://bounty.xe.network/v1/tickets/XE-10329) · [markdown](https://bounty.xe.network/XE-10329.md)

### Report

## Vulnerability Summary

In `core/encoding.go:377-531`, `unmarshalBlock` decodes binary-encoded blocks from network streams and storage. For `BlockMultisigOpen` and `BlockMultisigUpdate`:

```
	case typeByteMultisigOpen:
		blockType = BlockMultisigOpen
		minLen = fixedHeaderSize + 8 + representativeSize
	case typeByteMultisigUpdate:
		blockType = BlockMultisigUpdate
		minLen = fixedHeaderSize + 8 + representativeSize
...
	case BlockMultisigOpen, BlockMultisigUpdate:
		ks, ksLen, err := unmarshalKeysetCanonical(data[90:])
		if err != nil {
			return nil, fmt.Errorf("UnmarshalBlock: keyset: %w", err)
		}
		b.MSKeyset = ks
		repOffset = 90 + ksLen
		if len(data) < repOffset+representativeSize {
			return nil, fmt.Errorf("UnmarshalBlock: data too short for %s after keyset", blockType)
		}
...
	tailOffset := minLen
...
	if len(data) == tailOffset+8 {
		b.PoWNonce = binary.LittleEndian.Uint64(data[tailOffset:])
	}
```

Critical codec calculation bug:

1. 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`.
2. Static `tailOffset`: Line 499 sets `tailOffset := minLen`, where `minLen` was statically computed with an assumed keyset size of 8 bytes (`fixedHeaderSize + 8 + representativeSize = 130`).
3. PoW Nonce Loss \& Misalignment:
   - 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`.
   - 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.

## Impact \& Severity

1. 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`.
2. Roundtrip Serialization Invariant Broken: `UnmarshalBlock(MarshalBlockCanonical(b))` fails roundtrip equality, corrupting multisig state during peer synchronization.

## Proposed Remediation

In `core/encoding.go`, dynamically update `tailOffset` after unmarshaling the keyset:

```
	case BlockMultisigOpen, BlockMultisigUpdate:
		ks, ksLen, err := unmarshalKeysetCanonical(data[90:])
		if err != nil {
			return nil, fmt.Errorf("UnmarshalBlock: keyset: %w", err)
		}
		b.MSKeyset = ks
		repOffset = 90 + ksLen
		tailOffset = repOffset + representativeSize
```

### Thread

**Joseph Denne**team2026-11-20 00:33 UTCdesk

Thanks. This is the same finding as https://bounty.xe.network/XE-0083, which was filed first; the programme pays the
first verifiable submission, so this one closes as a duplicate. If you believe it is a different
bug, file a new report that links https://bounty.xe.network/XE-10329 and says what differs; it is read like any other.
