You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(x402): validate server payment requirements before signing
The amount, recipient, and asset in an x402 402 response are
server-controlled. `paidFetch` validates them before signing
(validatePaymentRequirements: payTo is not a burn address, asset defaults
to the network USDC, optional maxAmount/allowedRecipients), but two other
client paths did not:
- `pay` (runPaymentOnly) passed the server's requirements straight to
signX402Payment with no checks, so a hostile endpoint could have the
caller sign a transfer of an arbitrary asset/amount to an arbitrary
address. It now runs validatePaymentRequirements with a default 1 USDC
cap, overridable via --max-amount (mirroring `smoke`).
- eip3009AuthenticatedFetch is documented as signing a zero-value proof of
wallet control, but it forwarded the server's maxAmountRequired to
signX402Payment, so a value-bearing requirement was signed. It now signs
only when the requirement is zero-value; a value-bearing 402 is returned
as-is.
validatePaymentRequirements is exported so `pay` can reuse it. Adds
regression tests for both paths.
0 commit comments