caelum0x 7ea2dd5ccd fix(context-passport): bind settlement attestation to receipt claims, not just receipt_hash
ReceiptVerifier::verify() only checked the Ed25519 signature over
receipt_hash -- it never bound that hash to the amount_micros/operation/
operation_hash/sequence fields traveling unsigned alongside it in
PaymentEvidence. check_settlement_evidence only cross-checks those fields
against each other and the passport owner, never against independent
ground truth. Since POST /v1/passports/:id/attest lets any passport owner
submit evidence for a generation executed outside Identity Lock, and
check_settlement_evidence trivially passes when payer_account == owner,
an owner could take ANY genuine (receipt_hash, signature) pair from their
own real, unrelated, arbitrarily small Mint settlement and replay it
verbatim alongside a forged amount_micros describing a much larger
payment -- written permanently into a GenerationRecord exposed via the
"C2PA-aligned" public manifest endpoints.

Same vulnerability class independently found and fixed in Ledgerline
(531fabbc) the same day, but that fix's "redefine what the signature
covers" approach does not apply here: Ledgerline had zero live producers
signing its old contract, so redefining it was safe; Mint's receipt
signature here is genuinely live (Ed25519 over the bare chain hash,
mint-receipts::ReceiptBody::compute_hash), so redefining it would reject
every real Mint receipt. Full ReceiptBody recompute is also not possible
from PaymentEvidence's narrower wire fields (missing account_id/from/to/
balance_after_held_micros/ts/signer).

Fixed by requiring and verifying Mint's own TransferAttestation/
HoldSettlementAttestation (mint-server::attestation) -- built exactly for
this purpose, already returned in the JSON body of POST /v1/transfers and
POST /v1/holds/:id/capture (data.attestation), so any legitimate external
caller who settled payment directly against Mint already has it. Its
signature binds amount_micros/operation/operation_hash/sequence/
receipt_hash together under one digest, so a genuine attestation for one
claim can never be replayed onto a different one. Added
SettlementAttestationProof to PaymentEvidence (passport-core) and
ReceiptVerifier::verify_bound (passport-server/receipts.rs), which
reimplements Mint's exact digest/domain-separation bytes with no
mint-server dependency (mirrors how ledgerline::receipt_verify stays
dependency-free too), then cross-checks the attested claims equal the
submitted receipt. attest() now calls verify_bound instead of the unbound
verify. generate() keeps calling plain verify unchanged: Relay's
/v1/passport/generate transports only the legacy AITP-Receipt header
today, not an attestation, and that path stays lower-risk while its
evidence originates from the in-process RelayConditioningSink seam rather
than an external caller.

Added 6 unit tests (receipts.rs) and 1 integration test (tests/api.rs)
proving a genuine receipt_hash+signature+attestation replayed onto a
forged amount_micros is now rejected, plus updated 3 existing attest
fixtures to include a valid attestation. cargo test --workspace: 65/65
passing (was 59/59 before these additions), including the live-Postgres
integration test. cargo clippy --all-targets: zero new warnings in any
changed file (one pre-existing too_many_arguments on attest() predates
this change, confirmed via git stash on clean main).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-07 04:13:47 +03:00
..