T09 · Insecure Skill Coding Practices
- Location
scripts/degov-client.ts:9- Finding
Automatic x402 payments can be authorized for an unrestricted API origin without a local spending limit
- Content
View full analysis
{ const { account } = await getAccount(); const publicClient = createPublicClient({ chain: base, transport: http('https://mainnet.base.org'), }); const signer = toClientEvmSigner(account, publicClient); return { accountAddress: account.address, fetchWithPayment: wrapFetchWithPaymentFromConfig(fetch, { schemes: [ { network: 'eip155:8453', client: new ExactEvmScheme(signer), }, ], }), }; } async function apiCall(endpoint: string): Promise { const { accountAddress, fetchWithPayment } = await getPaymentClient(); const url = `${API_BASE_URL}${endpoint}`; console.error(`Using wallet: ${accountAddress}`); console.error(`Calling: ${url}`); const response = await fetchWithPayment(url); const paymentResponse = response.headers.get('PAYMENT-RESPONSE'); const text = await response.text(); ``` ### Technical Analysis The paid API client decrypts the locally stored wallet key, constructs an EVM signer, and gives that signer to the x402-enabled fetch wrapper. The destination is derived from `DEGOV_AGENT_API_BASE_URL`, which can contain an arbitrary origin. The implementation does not locally enforce: - An allowlist of trusted API hosts. - HTTPS for non-local endpoints. - An expected x402 payment recipient. - An expected USDC contract or payment asset. - A maximum amount per request. - A cumulative session or daily budget. - Interactive confirmation of the exact payment terms. Network transmission of signed x402 payment autho ...[truncated 2071 chars]- Remediation
View remediation
