Skip to content

fix(x402): stop prefix bypass in service allowlist matching - #1392

Open
SashaMIT wants to merge 1 commit into
coinbase:mainfrom
SashaMIT:fix/x402-service-allowlist-prefix-bypass
Open

fix(x402): stop prefix bypass in service allowlist matching#1392
SashaMIT wants to merge 1 commit into
coinbase:mainfrom
SashaMIT:fix/x402-service-allowlist-prefix-bypass

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Aug 4, 2026

Copy link
Copy Markdown

Description

isServiceRegistered / is_service_registered previously treated a service as allowed when url.startsWith(registered). That enables classic prefix bypasses, for example registering https://api.example.com and later requesting https://api.example.com.evil.com/....

This changes matching to:

  • bare origin registration → any path on that origin
  • full registered URL → same origin and exact path or segment-boundary path prefix

TypeScript and Python providers are updated together. Adds unit tests for the bypass cases.

AI disclosure

Drafted with AI assistance; reviewed against the allowlist bypass class (hostname-suffix / unsafe prefix matching).

Test plan

  • Unit tests for hostname-suffix rejection and valid origin/path cases
  • CI on this PR
  • Confirm existing registered-origin configs still allow intended paths

@SashaMIT
SashaMIT requested a review from murrlincoln as a code owner August 4, 2026 09:27
@cb-heimdall

cb-heimdall commented Aug 4, 2026

Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

Replace raw URL startsWith checks with same-origin + path-prefix matching
so hostname-suffix registrations cannot authorize attacker hosts.
@SashaMIT
SashaMIT force-pushed the fix/x402-service-allowlist-prefix-bypass branch from 37c812e to 5655cab Compare August 4, 2026 14:38
@SashaMIT

SashaMIT commented Aug 5, 2026

Copy link
Copy Markdown
Author

Friendly bump — these three tips harden agent spend paths (allowlist matching, Jupiter slippage cap, Permit2 amount + EIP-712 bind). Happy to adjust naming/tests if anything conflicts with your roadmap. Tips are SSH-signed under SashaMIT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants