Skip to main content

DoorNo.402

PyPI npm License: MIT

DoorNo.402 is security middleware for x402 payment requests. It intercepts every 402 response before your agent pays, validates it against known attack patterns, and blocks anything suspicious before a single transaction is signed.

The problem

x402 lets servers charge AI agents for resources over HTTP. The spec has no trust model. Any server can lie about the price, inject instructions into the description field to hijack the agent's LLM, redirect payment to an unknown wallet, or drain the wallet through rapid micro-payments. Without a security layer, your agent pays whatever it is told.

Install

pip install doorno402
npm install doorno402

Quickstart — Python

from doorno402 import protect, PaymentBlockedError
from x402.clients.httpx import x402HttpxClient
from eth_account import Account

account = Account.from_key(private_key)
client = protect(x402HttpxClient(account=account))

resp = await client.get("https://api.example.com/data")
# raises PaymentBlockedError if the 402 payload is malicious

Quickstart — TypeScript

import { protect, PaymentBlockedError } from "doorno402";

const safeFetch = protect(fetch);

const resp = await safeFetch("https://api.example.com/data");
// throws PaymentBlockedError if the 402 payload is malicious

What it catches

# Vulnerability Attack Status
01 Price Inflation Server claims $0.01, charges $5 Covered
02 Unknown Recipient No ENS, zero trust score Covered
03 Redirect Hijack Payment redirected to attacker Covered
04 Prompt Injection LLM override in description Covered
05 Budget Drain Rapid micro-payments Covered
06 TLS Downgrade Payment over HTTP Covered
07 Fake Delivery Empty response after payment Covered

Configuration

protect() accepts three optional parameters:

  • daily_budget (float) — max USD per day, blocks when exceeded
  • mainnet_rpc_url (str) — Ethereum RPC for ENS trust lookups
  • raise_on_block (bool) — raise PaymentBlockedError vs return 403

How it works

DoorNo.402 registers an event hook on your HTTP client. When a server returns a 402 Payment Required response, the hook fires before the payment SDK processes it. The intercepted payload is run through a 7-stage validation pipeline: price inflation check, ENS trust scoring, redirect detection, prompt injection scan, budget enforcement, TLS verification, and delivery validation. If all stages pass, the response is forwarded to the payment SDK for execution. If any stage fails, the response status is mutated to 403 Forbidden and the payment is never signed. When raise_on_block is enabled, a PaymentBlockedError is raised instead.

KeeperHub integration

DoorNo.402 validates. KeeperHub executes. Together they form a complete secure payment pipeline for autonomous agents.

import { interceptAndForward } from "doorno402/mcp";

const safeClient = interceptAndForward(keeperHubClient, {
  dailyBudget: 5.0,
});
await agent.run(safeClient);

When DoorNo.402 approves a payment, forward the validated details to KeeperHub's Direct Execution API for guaranteed on-chain execution with retry logic and audit trail.

Live demo

The repository includes 7 deployed Vercel servers — 6 malicious, 1 honest. Each server targets a different vulnerability from the table above. The CLI runs an autonomous research agent across all 7 servers and produces a results table showing what was blocked and how much was saved.

Site Vulnerability URL
CryptoInsider Price Inflation cryptoinsider-nine.vercel.app
ChainPulse Prompt Injection chainpulse-chi.vercel.app
BlockBrief Budget Drain blockbrief-rho.vercel.app
NodeTimes Unknown Recipient nodetimes.vercel.app
Web3Daily TLS Downgrade web3daily-alpha.vercel.app
ComboAttack All vulnerabilities combo-dusky.vercel.app
ChainWatch Honest server chainwatch-tan.vercel.app

Run the CLI:

cd demo/cli
pip install -r requirements.txt
python run.py

The CLI prompts for a research topic and runs the agent autonomously across all 7 servers.

Project structure

sdk/python/       Python SDK
sdk/ts/           TypeScript SDK
demo/cli/         Interactive CLI with research agent
demo/servers/     6 malicious + 1 honest Express servers
demo/agent/       Standalone agent scripts
demo/landing/     Landing page source
skills/           Agent skill prompt for doorno402

License

MIT

Release files for doorno402 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for doorno402 0.4.0
File Size Uploaded
doorno402-0.4.0.tar.gz 14.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for doorno402 0.4.0
File Interpreter ABI Platform
doorno402-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.2 kB

Release files / doorno402-0.4.0.tar.gz

Download URL doorno402-0.4.0.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8cd9a0ec72db61a7cf57ebaf5de395d1112e1c9916a3b50983596508866b41f4
BLAKE2b-256 checksum
How to use checksums
7b18cd8abbd6f82b2049bdb4209d79611df38585d2c3028a4bddd5cd24eda002
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / doorno402-0.4.0-py3-none-any.whl

Download URL doorno402-0.4.0-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
228536005da8e2bc473ae58400c0b59273d6ce579b8aadcca91c4d68a7739cc4
BLAKE2b-256 checksum
How to use checksums
d080788365f330cd1676f8891b025fe98914b1e9965aae37fe26501e6175566d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page