Bounty
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

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 Denneteam2026-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.