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

72 lines
2.3 KiB
TOML

# Identity Lock — standalone cargo workspace (legacy directory name).
#
# Deliberately NOT a member of the repo-root workspace (the root excludes
# apps/context-passport) so it never enters the desktop GPUI/Metal build graph.
# Build and test only from here: `cd apps/context-passport && cargo test`.
#
# House rules (shared with apps/mint, apps/vend):
# 1. sqlx uses the RUNTIME query API only (`sqlx::query` + `.bind`), never the
# `query!` macros, so every store crate compiles with no `DATABASE_URL`.
# 2. All HTTP to sibling services (Relay, Mint) goes through injectable
# transport TRAITS declared in passport-core, faked in tests.
[workspace]
resolver = "2"
members = ["crates/*"]
[workspace.package]
version = "0.1.0"
edition = "2021"
license = "MIT"
[workspace.dependencies]
# ---- internal crates (path deps declared once, referenced as { workspace = true }) ----
passport-core = { path = "crates/passport-core" }
passport-resolve = { path = "crates/passport-resolve" }
passport-provenance = { path = "crates/passport-provenance" }
passport-store = { path = "crates/passport-store" }
passport-store-postgres = { path = "crates/passport-store-postgres" }
passport-relay-client = { path = "crates/passport-relay-client" }
passport-mint-client = { path = "crates/passport-mint-client" }
passport-testkit = { path = "crates/passport-testkit" }
mint-protocol = { path = "../mint/crates/mint-protocol" }
# ---- serde / domain ----
serde = { version = "1", features = ["derive"] }
serde_json = "1"
chrono = { version = "0.4", features = ["serde", "clock"] }
thiserror = "2"
sha2 = "0.10"
hex = "0.4"
base64 = "0.22"
# ---- async runtime ----
tokio = { version = "1", features = ["full"] }
async-trait = "0.1"
futures = "0.3"
# ---- HTTP server stack ----
axum = "0.7"
tower-http = { version = "0.6", features = ["trace"] }
subtle = "2"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
anyhow = "1"
# ---- HTTP clients (to Relay / Mint) ----
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
# ---- sqlx (runtime API only) ----
sqlx = { version = "0.8", default-features = false, features = [
"runtime-tokio",
"tls-rustls",
"postgres",
"macros",
"migrate",
"chrono",
"json",
] }
# ---- test-only ----
tower = { version = "0.5", features = ["util"] }