Skip to content

Fix x402 payment data leak: settle before handler execution - #39

Open
shafu0x wants to merge 1 commit into
mainfrom
shafu/settle-before-execute
Open

Fix x402 payment data leak: settle before handler execution#39
shafu0x wants to merge 1 commit into
mainfrom
shafu/settle-before-execute

Conversation

@shafu0x

@shafu0x shafu0x commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Moves x402 settlement before handler invocation in the orchestration flow
  • Previously: verify → execute handler → settle. This allowed concurrent requests with the same payment nonce to both pass verification, both get data, but only one actually settles on-chain. The second request gets free data.
  • Now: verify → settle → execute handler. If settlement fails (duplicate nonce, insufficient funds), the handler never runs and no data is returned.
  • Changes settlement failure status from 500 to 402 (the payment didn't go through, so it's a payment error)
  • Updates tests to reflect the new correct behavior: settlement happens regardless of handler outcome

Fixes Merit-Systems/enrichx402#97

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