Skip to content

fix(core): key CX-receipt spent-marker off the signed header, not MerkleProof - #9

Open
Frozen wants to merge 1 commit into
mainfrom
fix/cx-receipt-replay-spent-key-main
Open

fix(core): key CX-receipt spent-marker off the signed header, not MerkleProof#9
Frozen wants to merge 1 commit into
mainfrom
fix/cx-receipt-replay-spent-key-main

Conversation

@Frozen

@Frozen Frozen commented Aug 12, 2026

Copy link
Copy Markdown
Owner

fix(core): key CX-receipt spent-marker off the signed header, not MerkleProof- #9

…kleProof

IsSpent and WriteCXReceiptsProofSpent only derived the spent-marker key from
the signed block.Header (ShardID/Number) from IsCXMerkleProofReplayFixEpoch
onward. For any proof whose Header.Epoch() precedes that fork epoch, the key
fell back to CXMerkleProof.ShardID/BlockNum -- fields that ValidateCXReceiptsProof
never binds to the Header for those epochs. Since the Header (and therefore its
signature) can't be altered without invalidating VerifyHeaderSignature, but
MerkleProof.ShardID/BlockNum are otherwise unauthenticated, a genuine,
already-applied CXReceiptsProof could be resubmitted with a mutated
MerkleProof identity: each resubmission hashed to a different, "unspent"
key, letting ApplyIncomingReceipt credit the destination again with no
corresponding source debit.

Always derive the spent-marker key from the Header. This doesn't change what
ValidateCXReceiptsProof accepts, and is a no-op for honestly generated
proofs -- MerkleProof.ShardID/BlockNum are naturally populated from the same
source block as the Header, so the on-disk key is unchanged for real
historical data; only a proof with a deliberately mismatched MerkleProof
identity resolves to a different (correct) key than before.

Add TestIsSpentIgnoresMutatedMerkleProofIdentity covering the replay case.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant