Skip to content

fix(tempo): align push payment verification with the charge spec (mppx#1372, mppx#1374) - #774

Merged
brendanjryan merged 5 commits into
mainfrom
agricola/mppx-1372-push-verification
Dec 1, 2026
Merged

brendanjryan merged 5 commits into
mainfrom
agricola/mppx-1372-push-verification

Conversation

@brendanjryan

Copy link
Copy Markdown
Collaborator

Source: wevm/mppx#1372 (merge commit 1708661) and wevm/mppx#1374 (merge commit 955c4c1)

Motivation

mppx 0.22.2 and 0.22.3 aligned Tempo charge push payments (hash Credentials) with the charge spec. The Rust server accepted push payments that mppx now refuses, and refused batched push payments that mppx now accepts:

  • A Challenge whose request sets methodDetails.memo took a hash Credential whenever a split carried this Challenge's attribution memo.
  • The attribution memo could sit on any matched transfer, so a plain primary transfer with the memo only on a split was accepted.
  • A batched transaction paying several Challenges was rejected when the primary matched another Challenge's transfer first.

Summary

Server-side hash Credential verification only:

  • Reject a hash Credential with a verification failure when the request, or the signed Challenge's request, sets methodDetails.memo, whatever supportedModes says.
  • Require this Challenge's attribution memo on the primary transfer itself.
  • In a batched transaction, skip transfers carrying another Challenge's attribution memo, in any order and from any realm. A split prefers a transfer carrying this Challenge's memo, never counts another Challenge's, and otherwise takes the first transfer that fits, checking only that transfer's sender.
  • A matched transfer without this Challenge's attribution memo (a plain split) counts only when the transaction pays no other Challenge.
  • Hash the Challenge binding (realm and Challenge ID fingerprints) once per verification instead of once per matched memo (ChallengeBinding); assert_challenge_bound_memos also hashes it once, on the first attribution memo.

Tests in tests/hash_credential.rs mirror the mppx tests: server memo rejection (from the request and from the signed Challenge), memo only on a split, other Challenges' transfers first, last and from another realm, a plain split shared with another Challenge, splits matched to their own Challenge, the sender check of only the split used, and the binding matching exactly what is_challenge_bound_memo accepts.

Key design considerations

  • Matching for hash Credentials is a separate function (match_bound_transfers), so transaction Credentials and the call matcher keep their current behavior.
  • A memo that isn't bound to this Challenge on a settled receipt still fails as a replayed Credential, as verify_hash did before.
  • Not ported: mppx keeps accepting push payments on sponsored (fee payer) Challenges, so neither does this; the client offer-selection changes were dropped from mppx#1374 and are client-only.
  • Conformance (tempoxyz/mpp-tools at 422863d, Rust adapter pointed at this branch): tempo-receipt-verification.json passes 42/42, including explicit_memo_hash_credential_with_attribution_memo_rejected, attribution_memo_only_on_split_rejected, batched_transfer_for_other_challenge_first_ignored and batched_transfer_for_other_challenge_last_ignored. tempo-accepted-transfers.json passes 4/5: split_transfer_counted_once expects the first of two Challenges sharing one plain split to be accepted, which mppx 0.22.2 rejects as well under the rule this ports (a plain split counts only when the transaction pays no other Challenge). fix(conformance): restore the harness fixes for the mppx 0.22 pins mpp-tools#422 lists it as a known failure of the reference awaiting a decision on the vector.
  • Review gate: both source PRs' server changes were reviewed with no open findings in this scope.

Verified: cargo fmt --all -- --check, cargo clippy --workspace --all-targets --all-features -- -D warnings, cargo test --features tempo,stripe,ws,server,client,axum,middleware,tower,utils,integration-stripe,integration-ws (2,120 passed).

Propagated from wevm/mppx#1372 (17086611a7f66fedf8c403f0977164c3559b5e24) and wevm/mppx#1374 (955c4c136dcde86a7c283f434bdad1c50c725a37) by Agricola.

@tempoxyz-bot

tempoxyz-bot commented Nov 30, 2026 •

Copy link
Copy Markdown

👁️ Cyclops Security Review

✅ Reviewed 2118f1a (latest) · Coverage: partial · ⚠️ 6 open findings · report
⚠️ Not checked: Previously reported settled-withdrawal recovery error being swallowed by Zone preflight: ruled out without reading the cited code at this commit
ℹ️ Not verifiable from the source alone (needs running code or deployed state): No runner-recorded execution reproduces the ranked malformed-offer case or the callback-only Zone Credential case. No deployment evidence quantifies how often clients receive either offer shape. To ve

# Severity Finding Introduced Status
1 🟢 Low Push receipt matcher asks validate_sender about a split transfer it discards 1fe1928 🟠 Open
2 🟡 Medium Tempo push-only Challenge with a memo debits payer, then is refused 1fe1928 ✅ Fixed in fc0dc2d
3 🟢 Low Zero-value foreign-tagged transfer makes hash verification reject a paid split charge 1fe1928 🟠 Open
4 🟡 Medium Push matcher lets the primary consume an exact-memo split's only transfer 1fe1928 ✅ Fixed in fc0dc2d
5 🟢 Low Tempo push matcher reports sender-ineligible transfers as replayed Credentials 1fe1928 🟠 Open
6 ⚪ Informational Hash memo regression test never isolates the explicit-request memo check 1fe1928 🟠 Open
7 🟡 Medium Memo-bearing Tempo charge Challenges silently drop Zone payment support fc0dc2d ✅ Fixed in 9f41cdc
8 🟡 Medium Tempo Challenge selection discards memo push-only offers the Zone path can pay fc0dc2d ✅ Fixed in 9f41cdc
9 🟡 Medium Tempo push verification redeems only one Challenge per batched transaction fc0dc2d 🟠 Open
10 🟡 Medium Zone prefilter selects memo push-only offer that execution then rejects 9f41cdc 🟠 Open
11 🟡 Medium Tempo Zone charges with a memo still offer push that legacy clients pay 9f41cdc ✅ Fixed in acb37f0
12 🟡 Medium Memo-bearing split charges can advertise no redeemable payment mode 9f41cdc ✅ Fixed in acb37f0
13 🟡 Medium Zone offer selection can pay again after a withdrawal settled acb37f0 ✅ Fixed in 2118f1a

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T23:46:46.716509Z 1fe1928 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Changelog found on PR.

Edit changelog

@claude claude 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.

Beyond the inline findings, I checked whether the slice == in ChallengeBinding::is_bound (memo.rs) breaks the AGENTS.md rule that HMACs and Challenge IDs must be compared in constant time. It doesn't. The bytes it compares are public fingerprints read from the on-chain memo, not an HMAC. verify_server and verify_challenge_binding in src/tempo/attribution.rs already compare these bytes the same way.

Extended reasoning...

Beyond the inline findings, I examined the slice equality in ChallengeBinding::is_bound. It matches the existing comparisons in src/tempo/attribution.rs, and the values it compares are public memo fingerprints rather than HMACs.

Findings marked 🟡 are optional suggestions and need no follow-up push.

Comment thread .changelog/tempo-push-spec-alignment.md Resolved
Comment on lines +195 to +209
let is_fallback = !primary && expected.memo.is_none() && !bound;
if is_fallback && fallback.is_some() {
continue;
}
// Last, so that `validate_sender` only sees transfers that
// could be used.
if !transfer.from.is_some_and(|from| policy.allows(from)) {
continue;
}
if is_fallback {
fallback = Some(index);
continue;
}
found = Some(index);
break;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low: Push receipt matcher asks validate_sender about a split transfer it discards

For a split without a memo, match_bound_transfers checks the sender of a plain transfer before it reaches a later transfer carrying this Challenge's attribution memo. The bound transfer is used, yet the with_validate_sender callback has been asked about a transfer the payment never counts. The base matcher searched memo transfers first and made no such call.

Valid? React with 👍 / 👎.

Comment on lines +156 to +163
let pays_other_challenge = effects.iter().any(|effect| {
effect.token == currency
&& effect
.memo
.is_some_and(|memo| attribution::is_mpp_memo(&memo) && !binding.is_bound(&memo))
});
if unbound_match && pays_other_challenge {
return Err(replayed(challenge_bound_memo_error()));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low (trigger unconfirmed): Zero-value foreign-tagged transfer makes hash verification reject a paid split charge

match_push_receipt_transfers treats any same-currency transfer effect carrying another Challenge's attribution memo as a competing payment, without checking its amount. A zero-value tagged transfer in the payer's transaction therefore makes a fully paid charge with a plain split fail as a replayed Credential. The base accepted the same receipt.

Valid? React with 👍 / 👎.

Comment on lines +186 to +194
if !memo_matches {
unbound |= primary || expected.memo.is_none();
continue;
}
// A Zone portal's payout settles a Zone withdrawal, which pays
// only through its `zone` Credential.
if transfer.from.is_some_and(zone::is_portal_address) {
continue;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low: Tempo push matcher reports sender-ineligible transfers as replayed Credentials

match_bound_transfers flags a memo mismatch before checking that the transfer could count for the Credential payer. A hash Credential whose only fitting transfer came from an unauthorized sender, with no bound memo, now fails as CredentialReplayed instead of the missing-transfer verification failure the base returned.

Valid? React with 👍 / 👎.

Comment on lines +718 to +724
let plain_request = push_request(serde_json::json!({}));
let challenge = push_challenge("challenge-memo", &memo_request);
let bound = push_receipt(&[(push_merchant(), 1000, Some(memo_for(&challenge.id)))]);

// Read from the request being verified and from the signed Challenge.
for (name, request) in [("request", &memo_request), ("signed", &plain_request)] {
let error = verify_push(&challenge, request, &bound)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational: Hash memo regression test never isolates the explicit-request memo check

test_verify_hash_rejects_challenge_with_server_memo builds the echoed Challenge from the memo-bearing request in both of its cases, so the signed-Challenge predicate of ensure_no_server_memo is true each time. The predicate on the request being verified is never the deciding input, and removing it leaves the test green.

Valid? React with 👍 / 👎.

A challenge whose request sets methodDetails.memo now advertises
supportedModes without push, as the charge spec requires, and the client
pays it by pull. A memo challenge that only takes push fails before
anything is broadcast, and providers skip it for another offer.

Push matching assigns splits with a memo before the primary, so the
primary can't take the only transfer carrying a split's memo.
Comment thread src/protocol/methods/tempo/mod.rs Resolved
Comment thread src/client/tempo/provider.rs Resolved
Comment on lines +160 to 162
let binding = ChallengeBinding::new(&challenge.id, &challenge.realm);
let matched = match_push_receipt_transfers(
receipt.logs(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium: Tempo push verification redeems only one Challenge per batched transaction

verify_hash now matches each Challenge in a batched push transaction to its own memo-bound transfers. It then reserves one replay key for the whole transaction hash. After the first Challenge redeems, every other Challenge fully paid in the same transaction is refused as CredentialReplayed.

Valid? React with 👍 / 👎.

Comment thread src/client/tempo/charge/mod.rs Resolved
A memo rules out hash Credentials, not Zone withdrawals. Issuance keeps
push on a memo charge that accepts Zones, and a provider with a Zone that
accepts a push-only memo offer still selects it and pays from the Zone.

@claude claude 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.

1 optional suggestion (a nit or a note on pre-existing code) was found and not posted.

The last 3 reviews of this pull request each found new blocking issues. Where they share a root cause, one fix may close them together.

Comment thread src/protocol/methods/tempo/mod.rs Resolved
Comment thread src/client/tempo/zone.rs Outdated
Comment on lines +374 to +380
let Ok(request) = challenge.request.decode::<ChargeRequest>() else {
return false;
};
request.amount_u256().is_ok_and(|amount| !amount.is_zero())
&& request.tempo_method_details().is_ok_and(|details| {
details.splits.is_none() && zone::is_accepted(details.zones.as_ref(), zone_id)
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium: Zone prefilter selects memo push-only offer that execution then rejects

select_challenge accepts a memo-bearing push-only Tempo offer whenever the configured Zone's may_pay passes. may_pay skips the expiry-versus-settlement-time and parent-chain checks that pays applies. When pays declines, the direct path rejects the memo push-only offer and the exchange fails, even though a payable pull offer was ranked after it.

Valid? React with 👍 / 👎.

Comment thread src/protocol/methods/tempo/mod.rs Resolved
Comment thread src/protocol/methods/tempo/mod.rs Resolved
A memo charge that accepts Zones keeps push for Zone withdrawals but must
also offer pull, so payers without the Zone and split charges stay
payable. Challenge selection keeps a push-only memo offer only when the
configured Zone would pay it, using the same check as payment.

@claude claude 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.

Besides the inline finding, I checked whether the == slice comparisons in ChallengeBinding::is_bound (memo.rs:29) break the constant-time comparison rule. They don't. They compare public on-chain memo fingerprints, not HMACs or Challenge IDs, and they work the same way as the existing attribution::verify_server and verify_challenge_binding.

Extended reasoning...

The change touches Tempo hash-Credential verification on the server, push-mode exclusion at Challenge issuance, and client offer selection with Zone fallback. The memo comparison checked here is against SHA-derived fingerprints of the realm and Challenge ID, which are already visible on-chain. The existing attribution helpers compare them the same way.

The last 4 reviews of this pull request each found new blocking issues. Where they share a root cause, one fix may close them together.

Comment thread src/client/tempo/zone.rs Resolved
Comment thread src/client/tempo/zone.rs Resolved
Challenge selection keeps a push-only memo offer when deciding whether the
Zone pays it fails, such as for an outstanding withdrawal, so paying it
reports the failure instead of paying another offer.

@claude claude 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.

I reviewed the latest push and didn't find any new bugs. The change rewrites how hash Credential payments are verified on the server, so a human look would still be worthwhile.

What was reviewed:

  • TempoZone::may_pay (zone.rs) now keeps an offer when pays errors (unwrap_or(true)). A pending Zone settlement now reaches pay_from and is reported there, so selection no longer falls through to a second offer.
  • exclude_push_for_server_memo in tempo/mod.rs: memo charges that accept Zones must also offer pull, and a missing list becomes ["pull"].
  • can_pay_offer filtering in both providers, and the bound-memo matching in matching.rs, receipt_logs.rs and memo.rs.
Extended reasoning...

The change spans 13 files. It covers server verification of Tempo push receipts (memo binding, batched-transfer skipping, plain-split counting) and Challenge issuance of supportedModes, as well as client offer selection for providers and Zones. This is payment-acceptance logic: if it is wrong, a server could take a replayed or misattributed payment or turn down a valid one after the funds have moved. The latest commit addresses the Zone selection concern from the previous review. The bug hunt ran until it stopped finding anything and reported nothing new. I deferred because the change is large and touches security-sensitive verification, which calls for a human reviewer.

@brendanjryan
brendanjryan merged commit fecebe5 into main Dec 1, 2026
19 checks passed
@brendanjryan
brendanjryan deleted the agricola/mppx-1372-push-verification branch December 1, 2026 04:27
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.

2 participants