跳到正文
DEV Community· Paydlux·· 53 分鐘前AI 評分48

Paydlux 核驗 Agent 向陌生 API 付款前的 402 條款

Your agent is about to pay a stranger's API

AI 導讀

paydlux 提供開源 402 付款核驗工具,讓 Agent 付款前查核條款、收款方、資產、網絡及價格。工具會完整解析付款標頭或標示無法讀取,並將互動記錄上鏈以供日後核對;檢查一次端點收費 0.08 XLM。

正文

You built an agent. It found an API that answers 402 Payment Required — the new x402 pattern where the price of a call rides in a response header instead of a billing desk. Your agent is about to send money to an address it has never seen, for terms it parsed with a regex someone else chose.

Pause there. What does your agent actually know at that moment?

1. The payee. A 56-character string. Whose is it? Nobody's. There is no registry mapping "agent payment addresses" to humans. If the endpoint is compromised — or was always malicious — that string is a drain, not a wallet.

2. The terms. The x-payment-required (or x402-version) header is attacker-controlled input wearing a content-type hat. Most client libraries JSON.parse it and read three fields: amount, asset, destination. Notice what's missing: what network that destination lives on, whether the asset is the one you think, whether the header even parses the way the library assumes. We ran live endpoints in the wild for this article's product and found headers our parser could only partially read. A partially-read header is not a safe header — our tool's rule is to refuse to vouch rather than silently drop the field you were relying on.

3. The endpoint behind the endpoint. 402 is an HTTP response like any other. A page that returns 200 OK with a "premium API" promise, then 402s on a button, is a very old con wearing a very new header.

That's the gap we built check.paydlux.com to close. One POST gives your agent — or you, before you wire it in — a verified third-party read of that 402's terms: parsed in full or flagged as unreadable, payee and asset and network stated plainly, price confirmed, and the whole interaction settled on-chain so the receipt is checkable later.

Try it without touching money:

paydlux check https://donate.paydlux.com/donate
→ a check of this endpoint costs 0.08 XLM on stellar:public

Pay it (~$0.01, paid through the same 402 pattern we're auditing — dogfooding means the checker pays its own bill):

$ paydlux check https://demo.paydlux.com/ --pay
paying 0.08 XLM from GCJG…, memo ord_98383e1a8d67

  verdict    NOT_PAYABLE
  reason     answered 200, not 402
  receipt    chk_9fa2bb5831c2
  tx         17a197fa983c88993b844a77d80226e66a791d780b3115c4f78457b95c3a8206
  verify     https://horizon.stellar.org/transactions/17a197fa983c…

That output is the whole product in eight lines. The URL we checked is our own demo page — and the checker did not care, told us truthfully that it isn't a paid endpoint, took the fee anyway, and left a mainnet transaction anyone can open in a block explorer. A security tool that grades its own house with the same severity as strangers is the only kind worth installing.

What we deliberately don't do: we don't "score" endpoints 0–100, we don't certify anyone, and when our parser can't fully read a payment header we say so in the report instead of guessing. Silence is cheaper for us than a wrong vouch — the honest verdict is the product.

The whole thing is open source (github.com/Mesher589/paydlux), the checker runs as an ordinary node process, and settlement rides on the same payment rails as the rest of paydlux — a 2-of-3 multisig vault with a spending mandate, which is the other half of this: not just "is this endpoint safe" but "my agent can't overspend anyway."

If your agent pays 402 APIs, the 30-second version of due diligence is now a CLI command. If it doesn't yet — the header you'll be parsing in three months is the one to think about today.

來源:DEV Community · dev.to