Repository navigation
fix(x402): refuse to sign when the 402 resource is unreachable - #396
Open
konstantinbozukov wants to merge 2 commits into
Open
konstantinbozukov wants to merge 2 commits into
konstantinbozukov wants to merge 2 commits into
Conversation
HTTP 402 is not proof the paid host is alive. Probe resource.url before signing and fail closed on timeout, DNS, or connection errors. Co-authored-by: Cursor <cursoragent@cursor.com>
Changelog cites apify#396. Import the fetch-only probe statically in the bridge (no viem). Comment why the probe uses GET instead of HEAD. Co-authored-by: Cursor <cursoragent@cursor.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HTTP 402 is not proof the paid host is alive. Ghost bazaar URLs still return a
PAYMENT-REQUIRED(or a cached one) after the origin is gone, and mcpc signed anyway.This probes
resource.urlbeforesignPayment:resource.url, or the same target we already got the 402 from → skip the extra round-tripSame guard on the tool-result retry path in the bridge.
No new flags. No vendor default. Useful even if you strip the probe later.
The probe uses GET (body cancelled), not HEAD: live hosts that omit HEAD can hang until timeout, which would fail-closed on a reachable resource.
Test plan
vitest run test/unit/lib/x402— 53 passed (probe skip/reachable/unreachable/timeout + middleware refuses to sign on ghost URL, still signs when the probe answers). Re-run locally after the follow-up commit, same 53.pnpm run test:uniton CI (first-time contributor — Actions is waiting for workflow approval)--x402) still settlesresource.urldoes not resolve does not produce a PAYMENT-SIGNATURE