Skip to content
Crypto.world

Research

When HTTP 402 Meets the Blockchain: Risks on Emerging x402 Payments

x402 is an emerging protocol that extends the HTTP 402 "Payment Required" status code so that software clients, including LLM-based AI agents, can pay for web API access automatically using…

When HTTP 402 Meets the Blockchain: Risks on Emerging x402 Payments
arXiv
2607.19545
Published
2026-07-21
Authors
Qinying Wang, Yong Yang, Yuan Chen, Shouling Ji, Mathias Payer

AI summary

Overview

Research area: Computer security (cs.CR), specifically the security of blockchain-backed payment protocols for Web APIs and autonomous AI agents.

Technical level: Advanced. The paper assumes familiarity with HTTP semantics, Ethereum/EVM token standards (ERC-3009, ERC-1271, ERC-6492), Solana SPL Token mechanics, and smart-contract gas/fee economics.

Scope: A systematic, black-box security analysis of facilitator-mediated x402 payment deployments in the wild, distilled into eight security rules, four attack classes, a testing tool called x402scope, and a large-scale on-chain measurement.

What This Paper Is About

x402 is an emerging protocol that extends the HTTP 402 "Payment Required" status code so that software clients, including LLM-based AI agents, can pay for web API access automatically using blockchain transactions. Because x402 delegates payment verification and on-chain settlement to third-party intermediaries called facilitators, a single flawed facilitator becomes shared infrastructure for many independent merchants, concentrating trust and risk. This paper asks how facilitators can fail, what concrete attacks those failures enable, and how widespread the problems are in real deployments.

Key Contributions

  1. Eight unified security rules (SR1–SR8). The authors derive a checklist of invariants for facilitators by walking through the full x402 workflow and its supported payment-proof formats. SR1–SR4 govern authorization correctness (proofs must match server-declared requirements, payer authorization must be authentic and unexpired, and success may only be reported when settlement actually succeeds on chain). SR5–SR8 govern execution safety (reject economically meaningless or non-settleable proofs, bound sponsor-paid fees/gas, re-verify before settlement, and restrict execution to an explicit allow-listed template).

  2. Four new attack classes derived from rule violations. Free Shopping (obtaining resources without paying, exploiting settlement-order flaws, timing windows, or false settlement success), Asset Theft (diverting facilitator-held assets to attacker-controlled accounts), Service Denial (exhausting facilitator resources via failing or expensive submissions), and Gas Abuse (forcing the facilitator to pay for attacker-chosen expensive execution).

  3. x402scope, a semi-automated black-box testing tool. It performs capability discovery to infer each facilitator's supported networks and proof types, instantiates protocol-compliant payment-proof templates, mutates them according to the rule under test, and uses HTTP responses plus on-chain transaction receipts as oracles. It requires no source code, private keys, or internal state of the facilitator.

  4. A large-scale evaluation plus on-chain measurement. The tool is applied to 15 major facilitators collectively used by over 60K sellers and 360K buyers and accounting for 99% of x402 transactions, and the results are complemented by an empirical measurement of over 119 million recent Base and Solana transactions.

Main Findings

  • Every tested facilitator violated at least one rule. Across 15 major facilitators, the authors report 49 security rule violations translating into 31 previously unknown vulnerabilities. They also state that every one of the eight rules was violated by at least one platform — systematic non-compliance rather than isolated bugs.

  • Risk profile differs by attack class. The dominant practical risks in the wild are sponsor-paid cost amplification and Free Shopping. Asset Theft is less frequent but has the highest impact, and it appears in some of the top-volume facilitators.

  • Server-side integration is itself a root cause of Free Shopping. All seven official Coinbase reference server SDKs lack rollback for post-verification side effects, and the official Flask SDK (v0.2.1) releases the protected resource after verification regardless of whether settlement later fails. The authors therefore add two server-side rules: release resources only after settlement succeeds, and roll back business logic if settlement fails.

  • Facilitators routinely mis-handle chain-specific proof semantics. On EVM, ERC-1271 and ERC-6492 signature paths allow verification and settlement to diverge — for example, an attacker-controlled validator contract can require block.basefee == 0 so that an off-chain check succeeds while on-chain settlement fails. On Solana, attacker-controlled account lists and injected ATA-creation steps can redirect value or force the facilitator to fund attacker-owned accounts.

  • On-chain costs are already material. In the measured transaction set, x402-related settlement attempts have burned over $202K in gas and fees, including $5.8K from reverting submissions alone. Over 22.9K transactions show ATA-creation patterns costing more than $5.7K, indicating ecosystem-level exposure of facilitator-held assets.

  • Adoption is real and highly concentrated. x402scan data cited by the authors reports over 150M on-chain transactions, over $40M in cumulative volume, over 400K buyers and over 80K sellers. Base and Solana account for 97.13% of observed transactions, and the 15 studied facilitators cover 99% of x402 transactions — meaning facilitator centralization is itself a systemic risk.

  • Disclosures were acknowledged and mitigated. The authors responsibly disclosed findings to affected parties, who acknowledged the issues and adopted mitigations, including changes by Coinbase. The paper states that the measurement is treated as risk evidence rather than attack attribution, because historical attacks lack ground truth.

  • Not reported in the available content: a per-facilitator breakdown of which of the 49 violations map to which vendor, the exact split of the 31 vulnerabilities by attack class, and the settlement failure rate as a percentage.

Methodology in Plain English

The authors start by reading the x402 specification and mapping out every step a payment goes through: a client requests a paid resource, the server replies with payment terms, the client submits a signed proof, the server asks a facilitator to verify that proof, the server does the work, and only then does the facilitator submit the actual blockchain transaction and pay the gas. At each step they ask what must be true for the payment to be safe, and turn those truths into eight checkable rules.

Because real facilitators are mostly closed-source remote APIs, they cannot read the code. Instead they build x402scope, which behaves like a well-behaved but adversarial customer. It first probes each facilitator to learn what it supports (which blockchains, which proof formats), then generates only the tests that apply. It starts from valid payment proofs and deliberately corrupts one field at a time — for instance, changing the recipient, changing the amount, using an expired authorization, reusing a transaction nonce, or wrapping a signature in an ERC-6492 envelope that deploys an attacker-controlled contract. It then checks what the facilitator answered on its /verify and /settle endpoints and, crucially, what actually happened on chain, using transaction receipts as ground truth.

To stay efficient and ethical, they test on testnets wherever possible (testnet and mainnet deployments are configured identically, so results carry over), keep the required manual work limited to one-time template derivation and occasional inspection of facilitator-specific JSON fields, and hold only about 1 USDC in the client wallet per network. Finally, they complement the controlled tests with a passive scan of over 119 million Base and Solana transactions to see how the protocol is actually being used and where money is being burned.

Why This Matters

Impact on research: This is the first systematic study of authorization correctness and execution safety in real-world x402 facilitators, and it reframes payment intermediaries — not just clients and agents — as the critical trust boundary. The eight rules give other researchers a reusable specification-level yardstick, and the finding that server SDKs themselves introduce vulnerabilities shifts attention from protocol design to integration practice.

Real-world applications:

  • Merchants running paid APIs can use the server-side rules (release only after settlement; roll back on settlement failure) to avoid giving away services for free.
  • Facilitator operators can use SR1–SR8 as a pre-deployment audit checklist, particularly around fee caps, idempotency, and settlement-time re-validation.
  • Wallet and agent developers building autonomous purchasing agents benefit from understanding which counterparties may report false settlement success.
  • Standards bodies and auditors gain a concrete list of chain-specific failure modes (ERC-1271/ERC-6492 wrapping, Solana ATA creation, compute-unit bounds) to codify in the specification.

Industry relevance: With x402 already deployed by Coinbase, Cloudflare, AWS, Circle, and Google, and with over $202K in observed gas and fees burned — including $5.8K from reverting submissions — the cost-amplification issues are direct, recurring financial losses rather than theoretical bugs. The fact that all 15 studied facilitators, covering 99% of transactions, had violations means the risk is systemic across the ecosystem, not confined to a fringe deployment.

Future Directions

  • Continuous, automated conformance testing. The authors designed x402scope to be extensible — adding a new network or proof format typically requires only new rule-specific test cases — which invites a standing public conformance suite that facilitators must pass.
  • Server-side hardening and SDK remediation. The two server-side rules (release after settlement, roll back after verification) need to be implemented across reference SDKs; measuring how quickly the ecosystem adopts rollback semantics is an open question.
  • Attribution and telemetry. Because historical attacks lack ground truth, the on-chain measurement could only serve as risk evidence. Building instrumentation that distinguishes genuine payments from exploitation attempts would let researchers quantify real losses.
  • Reducing facilitator centralization. With 15 facilitators covering 99% of transactions, the blast radius of any single flaw is ecosystem-wide; designs that distribute or diversify verification trust remain unexplored in this study.

Target Audience

Security researchers working on payment protocols, Web3 infrastructure, and autonomous-agent safety; engineers implementing x402 servers, facilitators, or client wallets; and technical auditors at organizations deploying pay-per-request APIs. Readers need working knowledge of EVM token standards and Solana transaction mechanics to follow the attack details, though the eight security rules and the four attack classes are readable at a conceptual level by product and risk managers.

Authors’ abstract

x402 is an emerging payment protocol for Web APIs and autonomous AI agents. x402 extends HTTP 402 with a payment negotiation flow and delegates payment proof verification and on-chain settlement to third-party facilitators. As a result, facilitators serve as a shared payment infrastructure for many independent merchants. This centralizes trust and validation in one component, so a single flaw can affect many services. Despite rapid adoption by major vendors and economically…

The full abstract on arXiv
Read the original paper