← Back to Blog
AI Cybersecurity · 5 min read · November 6, 2026

Is x402 Secure? Five Attacks on AI Agent Payments in 2026

An AI agent can now buy an API call the way a browser loads a page: the server replies 402, the agent pays a fraction of a cent in stablecoin, and the data arrives. Coinbase’s x402 protocol moved more than 100 million payments on Base in about three quarters. In May 2026, researchers published five attacks that work against live endpoints, and the SDKs they audited are missing the checks that would stop them.

What x402 is, and why agents needed it

x402 revives HTTP status code 402 Payment Required as a per-request payment handshake. Coinbase released it in May 2025, and it now ships SDKs in TypeScript, Python, Go and .NET alongside a discovery layer called Bazaar that indexes more than 13,000 resource servers. The pitch is blunt: kill the API key.

The flow is one round trip longer than a normal fetch. The agent requests a resource, the server answers 402 with a price, the agent signs a payment payload and retries with an X-PAYMENT header, an off-chain facilitator verifies and settles on-chain, and only then does the server release the resource. No account, no signup, no billing relationship.

Adoption is no longer theoretical. Chainalysis counted more than 100 million x402 payments on Base in roughly three quarters, and transactions above $1 grew from 49% of volume in early 2025 to 95% by early 2026. Gartner expects 40% of enterprise applications to embed task-specific agents by the end of 2026, up from under 5% in 2025.

The design flaw: HTTP is synchronous, settlement is not

An HTTP response is final in milliseconds. A blockchain transaction is not. It can be reorganised out of the canonical chain up to depth k, and x402 sits exactly on that seam. The off-chain facilitator that bridges the two layers is neither enforced by the protocol nor verifiable by the client.

That gap is the attack surface. In May 2026, researchers at Ohio State University, CSIRO and the University of Manchester published Five Attacks on x402 Agentic Payment Protocol (arXiv:2605.11781), validated on local chains, Base Sepolia and live endpoints across 25,000+ requests and 48 configurations.

The five attacks

1. Revert-grant: service released before finality

If a server grants on a mempool sighting or a shallow inclusion, a reorg, a replacement transaction or a deliberate delay can erase the payment after the data has already been delivered. Measured revert-grant probability reached 5.18% at 400 milliseconds of latency, and a Byzantine facilitator takes it to 100%. The uncomfortable part is that an honest but latency-optimised deployment produces the same exposure.

2. Settlement preemption: paid, then denied

The Permit2 settle() path did not bind the caller to the payer-endorsed facilitator. Anyone who sees the X-PAYMENT header — a TLS-terminating proxy, logging middleware, an API gateway, or the server itself — can submit the authorization first. The agent pays, the attacker settles, and the resource is refused. Cost: roughly one cent in L2 fees.

3. Replay: one payment, hundreds of grants

Without an atomic pre-grant claim on the payment ID, the same payload is a reusable coupon. In a live test one payment produced 248 grants. A single $0.001 payment produced hundreds.

4. Header and cache confusion

Paid responses that were publicly cacheable leaked their content to unpaid requests. A misconfigured nginx instance leaked 100%; a live CDN endpoint leaked as well. No audited SDK adds Cache-Control: no-store by default.

5. Server selection: the agent picks the attacker

Bazaar listings are metadata, and metadata can be gamed. One crafted listing captured 71.8% of agent traffic; five Sybil listings captured 60.2%. On-chain cost: effectively zero.

What the audit found in real SDKs

The same paper audited three SDK families — Coinbase’s reference TypeScript stack, a third-party Python integration and a third-party Rust middleware — plus four live testnet endpoints, and found 11 vulnerabilities across five classes. Every implementation checked timestamps. Almost none closed the cross-layer gaps.

The security-latency tradeoff

Base produces blocks in about two seconds. The paper’s guidance is k ≥ 3 confirmations for resources under $1 and k ≥ 12 for anything above $10. That safety is not free. Median grant-to-finality delay rises from 6.0 seconds at k = 3 to 25.1 seconds at k = 12; on a 12-second-block chain it reaches 34.3, 71.5 and 144.5 seconds respectively. An agent buying a millisecond arbitrage signal cannot wait two minutes.

Six mitigations that close the gap

  1. Canonical typed payloads. Sign pay_id, resource_id, facilitator, amount, token, chain ID and expiry under one EIP-712-style structure, and reject malformed, expired or duplicate values before settlement.
  2. Facilitator-bound settlement. Enforce msg.sender == witness.facilitator on Permit2, and route EIP-3009 through a wrapper that performs the same check.
  3. Single-use grants. Atomically claim the pay_id–resource_id pair before releasing any protected response, with a bounded TTL.
  4. Two-phase settlement. Use reserve-then-settle, or wait for k confirmations on higher-value resources.
  5. Cache and header hygiene. Set Cache-Control: no-store on paid routes and never let a proxy normalise, merge or duplicate X-PAYMENT.
  6. Discovery defence. Validate listing metadata, reject prompt-injection-style claims, add Sybil resistance and diversify ranking.

What agent operators should do this quarter

Assume the default SDK behaviour is unsafe until you have checked it. Fund agent wallets with a capped balance rather than a treasury key, set per-request and per-day spend ceilings, allowlist resource servers, and log every pay_id so duplicates become visible. Treat a 200 response as a delivery event, not as proof of settlement, and never let an agent read listing metadata as instructions.

Frequently Asked Questions

What is x402 and how does it work?

x402 is an open payment protocol built on the HTTP 402 status code. A server quotes a price in stablecoin, the client signs a payment payload and resends the request with an X-PAYMENT header, and an off-chain facilitator verifies and settles the transfer on-chain before the resource is released. It was released by Coinbase in May 2025.

Can these x402 attacks steal funds from a wallet?

Mostly they break the payment-service contract in one of two directions: unpaid service, where the agent receives data before settlement finalises, or paid-but-denied, where settlement succeeds but the request is refused. The direct capital risk is per-request, but a cache leak on a paid data product is a much larger loss than the fee that opened it.

Is x402 only for AI agents?

No. Any HTTP client can complete the handshake, including a browser paying for a single article. Agents are the driver because they cannot create accounts or manage API keys, and because they need to transact inside the same request that retrieves the data.

Which blockchain should an x402 deployment use?

Base currently hosts the most active deployment, and Solana and Polygon are also supported. Finality matters more than branding: confirmation depth, block time and reorg behaviour determine how long a server must wait before it can safely release a resource. Base blocks land in roughly two seconds.

Is x402 safe to use in production in 2026?

It is usable, but the defaults are not safe. Every attack in the published analysis is practical against live endpoints, and no audited SDK bound a payment to its resource or enabled no-store caching by default. Apply the six mitigations and pick confirmation depth by resource value before routing real money through it.

The agent is only as trustworthy as the surface it runs on

Agentic payment stacks inherit every exposed API, permissive cloud role and stale certificate underneath them. RootCrak’s autonomous scanner maps your domains, DNS and cloud configuration continuously, so a gap is found by you rather than by whoever reads the payment header first.

Get a Free Security Scan