Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 4 min read

Your agent pays whatever address the server says. Here is how to make payTo unswappable.

The weakest field in every crypto payment A crypto address is a long string with no sender attached. Whoever controls that string at the moment you copy it controls where the money goes: a fake or edited invoice, cli

The weakest field in every crypto payment

A crypto address is a long string with no sender attached. Whoever controls that string at the moment you copy it controls where the money goes:

  • a fake or edited invoice,
  • clipboard malware that replaces addresses,
  • address poisoning (a look-alike address in your transaction history),
  • a "support agent" in a chat,
  • and now: an API that answers 402 Payment Required.

With x402 V2 the payTo address can change on every request. If the server is compromised – or someone sits in between – your agent pays the attacker and nothing in the protocol notices. AWS says it plainly in the AgentCore docs: payments do not enforce payTo restrictions server-side, so your application must validate the address before paying.

Validate it against what, though? "The address changed" is not evidence of fraud. Sellers rotate addresses all the time.

What is missing is a statement from the payee that this exact address, for this exact amount, really comes from them.

Signed payment requests

The idea is old (Bitcoin had BIP70), but it never made it to other chains, to stablecoins or to agents. So I built a small, open format for it:

  1. The payee creates an Ed25519 key once and publishes the public key on its own domain.
  2. For every payment the payee signs: address, amount, network, asset, reference and expiry.
  3. The payer (wallet, app or AI agent) checks the signature against the key on that domain before sending.

Change one character of the address, the amount or the expiry and the signature breaks. A new address per invoice is fine – nothing has to be on a list.

No keys or funds ever leave the payee. Nothing on-chain changes.

Payee: two commands

# once
npx debyta keygen

This writes debyta-pay-key.pem (keep it secret) and prints the file you put at
https://your-domain.com/.well-known/debyta-pay.json:

{
  "version": 1,
  "addresses": [],
  "keys": [{"kid": "2026-11", "alg": "Ed25519", "pub": "<your public key>"}]
}

(A DNS TXT record works too: _debyta-pay.your-domain.com "k=ed25519; kid=2026-11; p=<pub>".)

# per invoice / per payment
npx debyta sign --payee your-domain.com --to 0xYourAddress \
  --chain base --asset USDC --amount 49.90 --ref INV-1001

Output:

debyta:pay?r=dpr1.eyJ2IjoxLCJwYXllZSI6InlvdXItZG9tYWluLmNvbSIs…

Put that into the invoice, the QR code, the checkout page – or into your x402 response.

Payer: verify before sending

Free, runs locally, no account:

npx debyta verify "debyta:pay?r=dpr1.…" --send-to 0xAddressYouAreAboutToUse

Or in code:

import {verifyPayRequestOffline} from 'debyta';

const r = await verifyPayRequestOffline(request, {sendTo: addressAboutToBeUsed});
if (!r.ok) throw new Error(`Do not pay: ${r.reason}`); // signature_invalid, address_mismatch, request_expired …

sendTo matters: it catches the case where the request is genuine but the address actually pasted into the wallet was swapped afterwards (clipboard malware).

In x402

Put the signed request into the extra field of the payment option:

{
  "x402Version": 2,
  "resource": {"url": "https://api.your-domain.com/data"},
  "accepts": [{
    "scheme": "exact",
    "network": "eip155:8453",
    "amount": "10000",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "payTo": "0xYourAddress",
    "extra": {"debytaRequest": "dpr1.…"}
  }]
}

Now payTo is cryptographically bound to your domain. A swapped payTo no longer matches the signed one.

Optional: online check

The signature proves who asked for the money. It does not prove that the payee is honest. If you want more, the hosted check adds sanctions screening (OFAC), address checksum validation, known fraud traces of the domain and the address, and returns a second signed verdict (allow / warn / block):

curl -s https://debyta.com/api/intel/v1/pay/verify \
  -H "Content-Type: application/json" \
  -d '{"request":"debyta:pay?r=dpr1.…","sendTo":"0x…"}'

For x402 there is a separate check that takes the raw 402 response and your spending limit:

curl -s https://debyta.com/api/intel/v1/x402/precheck \
  -H "Content-Type: application/json" \
  -d '{"requirements": <the 402 body>, "maxAmount": 1}'

Both are also MCP tools (verify_payment_request, check_x402_payment) on https://debyta.com/mcp, listed in the official MCP Registry as com.debyta/agent-check.

Limits

  • It only works if the payee publishes a key. Until then the online check falls back to address lists on the payee's domain, sanctions and fraud traces.
  • A valid signature means "this really comes from that domain" – not "that domain is trustworthy".
  • Requests expire after at most 31 days.

Format, in short

dpr1.<base64url(JSON)>.<base64url(Ed25519 signature over "dpr1." + base64url(JSON))>
JSON: {v:1, payee, kid, to, chain?, asset?, amount?, ref?, iat, exp, nonce}

The SDK is MIT-licensed and has no dependencies: npm install debyta. Full docs: https://debyta.com/agent-check/integrations#signed

If you run an x402 service or send invoices in stablecoins, I would like to hear whether this fits your flow – and what is missing.

This post was written with the help of AI and reviewed by the author.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.