Bounty
XE-16987 · Bounty

[Low] Binary codec silently drops attestations/signatures — round-tripped attested lease blocks hash differently

Closed · duplicate — xe#698 filed 2026-11-17 08:12 UTC by kecedanzz77-bit

Report

Summary

The binary codec silently drops Attestations, CertificateHash, Signatures, Signature, and Hash on marshal — a binary round-trip of an attested lease block yields a block whose recomputed hash differs from the original, so it can no longer be identified or signature-verified. JSON preserves all of them. Latent (the codec has no callers outside encoding.go + crypto.go), same standing as accepted #100.

Root Cause

  • MarshalBlockCanonical (core/encoding.go:44) never writes Attestations, CertificateHash, Signatures, Signature, or Hash.
  • MarshalBlockAux (:302) encodes attestations/cert-hash for hashing but has no inverse decoder, and MarshalBlock/UnmarshalBlock (:341/:354) never call it.
  • HashBlock (core/crypto.go:85-97) = sha256(networkID + canonical + aux), so attestations are hash inputs — losing them changes the hash.
  • Asymmetry: MarshalBlock loudly errors on a declared PubKey (:342-344) but silently drops these five fields.

Verification

Executed PoC:

in : attestations=2 cert_hash="fake-cert-hash-0123456789abcdef" signatures=2 sig_len=128
out: attestations=0 cert_hash="" signatures=0 sig_len=0 hash=""
HashBlock(in)  = 8431c877058c189e… (64 hex chars)
HashBlock(out) = c5179dff854a4bb7… (64 hex chars)
HASH MATCH: false
JSON control: attestations=2 cert_hash="fake-..." signatures=2 sig_len=128 hash_match=true

Note on related reports

Searched MarshalBlock encoding round-trip, binary codec signatures dropped, MarshalBlockAux aux decode, attestation binary codec MarshalBlock — only #84 (lease_renew decode case, fixed on HEAD) and #100 (multisig PoW nonce only). I read #100's full body: strictly about the decoder dropping the nonce (a field that IS in the bytes; tailOffset mechanism), and its round-trip test compared re-encode==encode, which cannot detect encoder-side field loss — this report's fields are lost on the first encode. Distinct mechanism.

Suggested fix

Encode the attestation/cert-hash/signature fields in the canonical or aux bytes (with a matching decoder), or make MarshalBlock error on blocks carrying fields it cannot round-trip.

Thread

Joseph Denneteam2026-11-22 23:26 UTCdesk

Thanks. This is the same finding as an earlier report that is not public, 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-16987 and says what differs; it is read like any other.