Hardening x402: PII-Safe Agentic Payments via Pre-Execution Metadata Filtering

Vladimir Stantchev, [email protected] · 2026

Read Hardening x402: PII-Safe Agentic Payments via Pre-Execution Metadata Filtering by Vladimir Stantchev, [email protected] (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2604-11430.txt.

Introduction

Stantchev hardens the x402 payment protocol against data leaks. Payment metadata in x402 requests reaches the payment server and central hub before on-chain settlement. Neither party is typically bound by a data deal. His open-source filter, presidio-hardened-x402, intercepts requests to redact personal data, enforce spending policies, and block replays. On a labeled synthetic set of 2,000 metadata triples, the best setup reaches micro-F1 0.894 with precision 0.972 at 5.73 milliseconds of 99th-percentile delay, within a 50-millisecond budget. The code, corpus, and tests are all public.

Catalog record

CREATORVladimir Stantchev, [email protected]
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE43112
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2604.11430

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Hardening x402: PII-Safe Agentic Payments via Pre-Execution Metadata Filtering Vladimir Stantchev, [email protected] Abstract AI agents that pay for resources via the x402 protocol embed payment metadata — resource URLs, descriptions, and reason strings — in every HTTP payment request. This metadata is transmitted to the payment server and to the centralised facilitator API before any on-chain settlement occurs; neither party is typically bound by a data processing agreement. We present presidio-hardened-x402 , the first open-source middleware that intercepts x402 payment requests before transmission to detect and redact personally identifiable information (PII), enforce declarative spending policies, and block duplicate replay attempts. To evaluate the PII filter, we construct a labeled synthetic corpus of 2,000 x402 metadata triples spanning seven use-case categories, and run a 42-configuration precision/recall sweep across two detection modes (regex, NLP) and five confidence thresholds. The recommended configuration ( mode=nlp , min_score=0.4 , all entity types) achieves micro-F1 = 0.894 with precision 0.972, at a p99 latency of 5.73 ms — well within the 50 ms overhead budget. The middleware, corpus, and all experiment code are publicly available at https://github.com/presidio-v/presidio-hardened-x402 . 1 Introduction A broker who handles your money also handles your metadata. In x402, every payment request carries three strings — a resource URL, a description, a reason — transmitted first to the server that charges the agent, then to the centralised facilitator API that settles the payment. Neither party advertises a data retention policy. Neither party is typically bound by a data processing agreement with the agent’s operator. The strings may contain a name, an email address, a social security number. The infrastructure was designed for financial settlement, not for privacy. The x402 protocol Coinbase 2024 is an HTTP-native micropayment standard in which a server responds to a client request with a 402 Payment Required status, a machine-readable payment specification, and a resource price denominated in stablecoins. The client — typically an autonomous AI agent — constructs an EIP-712 signed payment token containing the resource URL, description, and reason fields, transmits it to the payment server and to a centralised facilitator API, and, once the facilitator has settled the on-chain USDC transfer, retries the original request. The protocol is Coinbase-backed, carries Cloudflare and Stripe support, and processed an estimated $600M in annualised volume as of Q1 2026 Behnke 2026 . It is, in short, the first payment primitive that AI agents can use natively, without human approval, at machine speed. That speed is the point. It is also the problem. Every x402 payment embeds three metadata fields — resource_url , description , and reason — that travel in plaintext to the payment server and to the facilitator API before any on-chain settlement occurs. These fields are not sanitised by the protocol. Behnke 2026 catalogue the resulting vulnerability classes: payment replay, wallet drain via overpayment, prompt injection leading to fraudulent payments, and privacy leakage via transaction-graph linkability. PII scrubbing of metadata before transmission and application-layer spending limits are named as required controls. The analysis names the gap. It delivers no implementation. More broadly, Boschung 2025 argues that the convergence of AI agents with blockchain infrastructure constitutes a qualitatively new security frontier — one where pre-execution controls, not post-hoc monitoring, are the architecturally sound response. presidio-hardened-x402 is an instantiation of that argument at the payment metadata layer. Attack Classes Three distinct risks arise from unsanitised x402 metadata. PII in metadata fields. Resource URLs in x402 traffic regularly encode user identifiers: email addresses as path parameters, names as slugs, session tokens as query strings (Listing 1 ). These strings flow to the payment server and the facilitator API — neither of which is typically bound by a data processing agreement. GDPR Art. 5(1)(c) data minimisation and Art. 28 processor obligations apply from the moment of transmission. Wallet drain. A malicious 402 server can return an inflated price, a falsified facilitator address, or a looping redirect that triggers repeated micropayments. An agent with no spending policy has no circuit breaker. Replay. A signed x402 payment token is a bearer credential. Intercepted tokens can be resubmitted to the facilitator to debit the agent’s wallet a second time. The protocol has no application-layer nonce. Listing 1: A realistic x402 metadata triple containing two PII entity types. Without pre-execution filtering, all three fields are transmitted in plaintext to the payment server and facilitator API. ⬇ resource_url : https :// api . medrecords . io / patient / alice . martin %40 corp . io / export description : Export medical records for Alice Martin reason : user = alice . martin@corp . io ; ref =312-45-6789 Contributions We present presidio-hardened-x402 , the first open-source pre-execution security middleware for x402 payments. The contributions of this paper are: 1. HardenedX402Client : a drop-in Python wrapper for the x402 client that intercepts every payment request before execution and applies four security controls in sequence: PII detection and redaction, spending policy enforcement, replay detection, and tamper-evident audit logging. 2. Synthetic corpus : 2,000 labeled x402 metadata triples spanning seven use-case categories with ground-truth entity labels, publicly released to enable reproducible evaluation of x402 PII filters. 3. Parameter sweep : a 42-configuration evaluation (regex vs. NLP \times six entity subsets \times five confidence thresholds) with per-entity precision, recall, and F1 metrics. Recommendation: mode=nlp , all entities, min_score=0.4 (micro F1 = 0.894, p99 = 5.73 ms). 4. Latency characterisation : regex p99 = 0.02 ms; NLP p99 = 5.73 ms. Both modes satisfy the 50 ms overhead budget. Latency is not the binding constraint in x402 PII filtering; recall is. Section 2 covers the x402 protocol, the Presidio SDK, and the GDPR tension that motivates the work. Section 3 describes the system architecture and threat model. Sections 4 and 5 present the corpus construction and experimental evaluation. Sections 6 – 9 discuss findings, related work, limitations, and conclusions. 2 Background 2.1 The x402 Protocol The x402 protocol Coinbase 2024 extends HTTP with a native payment negotiation layer. When a client requests a resource that requires payment, the server responds with HTTP 402 Payment Required and a JSON body specifying the accepted payment schemes, the price, the network, and the facilitator contract address. The client constructs a payment token — a structured payload typed and signed according to EIP-712 Nair et al. 2017 — and attaches it to a retry of the original request in the X-Payment header. The facilitator, a smart contract deployed on Base L2, validates the token, transfers the stablecoin amount from the agent’s wallet to the server’s address, and returns an on-chain receipt. The server verifies the receipt and serves the resource. Three metadata fields travel in the payment token: resource_url (the URL being paid for), description (a human-readable label for the resource), and reason (a client-supplied annotation, typically a structured key-value string identifying the requesting entity). The token is transmitted in the X-Payment header to the payment server and forwarded to the facilitator API; neither party is constrained by the protocol to redact or discard these fields. The protocol specification places no constraints on the fields’ content. Figure 1 illustrates the full exchange. The interception point — where HardenedX402Client applies its four security controls — falls between the server’s 402 response and the submission of the

Read the complete text