Block fields outside the canonical hash are neither hashed nor validated, so a relay can rewrite stored block data after signing
Report
Suggested severity tier: Minor
Summary: The canonical hash of a block covers only a subset of its fields, and the signature and the proof of work bind only that hash. For several block types, fields outside the subset are also never read by the ledger validators, so anyone relaying a block can change those fields in transit and the changed copy is the one a node stores. The fields are the amount and destination of a receive block, the source of a send block, the source of a lease block, and the amount of a lease_cancel and lease_force_settle block. Balances are not affected, because every validator recomputes amounts from hashed state and pending records. The stored record is affected.
Evidence:
- core/encoding.go, MarshalBlockCanonical: the receive case writes only the source into the canonical form. The send and lease cases leave out source. The lease_cancel and lease_force_settle cases write only source.
- core/crypto.go, line 107: HashBlock hashes the network ID, the canonical form, and the aux form. Lines 134 and 169 sign and verify over the hash bytes only.
- core/ledger.go, line 1081: validateAndAddReceive derives everything from the pending send and never reads the amount or destination fields of the block.
- core/ledger.go, line 972: validateAndAddSend never checks the source field. Line 1506: validateAndAddLease never checks it either.
- core/ledger.go, lines 1792 and 1879: the cancel and force settle validators compute the refund from the lease block and the pending record, never from the amount field of the incoming block.
- core/ledger.go, line 795: addBlock deduplicates by hash and returns early when a block with that hash is already stored, so the first copy a node sees is the copy it keeps.
- The same codebase rejects stray fields elsewhere. core/ledger.go, line 1030, rejects a burn block with a source or destination, and core/mint.go, line 36, does the same for mint.
- A proof of concept program and its output are available on request. A signed receive block still verifies after its amount is set to 999999999999 and its destination is replaced. The hash is unchanged and verification returns no error. Setting a junk source on a send block and changing a lease_cancel amount from 100 to 777777777 also leave the hash unchanged.
Impact: Two nodes can hold different block bodies under one hash and one valid signature, and the difference is permanent for a node that stored the changed copy first, because the genuine body is later ignored as a duplicate. API responses and explorer or indexer views that read the generic block fields can show a receive amount, a cancel amount, or a send source that the signer never signed. No balance changes result from this, and this report claims nothing about balances.
Suggested fix: Include these fields in the canonical hash, or reject stray values in the validators for these block types, in the same way the burn and mint validators already reject them.
Thread
Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0060.