T09 · Insecure Skill Coding Practices
- Location
runtime/src/tools/core.ts:353- Finding
Unlimited ERC-20 Allowance Is Granted by Default
- Content
View full analysis
{ const record = toRecord(args); const token = requiredAddress(record, "token"); const { config, publicClient, walletClient, account } = await getWriteRuntime(); const spender = optionalAddress(record, "spender") ?? DEFAULT_VAULT_ADDRESS; const decimals = await readTokenDecimals(publicClient, token); const amountInput = optionalString(record, "amount"); const amount = amountInput ? parseValue(amountInput, decimals) : maxUint256; const hash = await walletClient.writeContract({ address: token, abi: erc20Abi, functionName: "approve", args: [spender, amount], account, chain: undefined, }); ``` ### Technical Analysis The `approve_token` tool treats both `spender` and `amount` as optional. If `amount` is omitted, the tool grants `maxUint256`, effectively creating an unlimited ERC-20 allowance. It also permits the caller to supply an arbitrary spender address. This exceeds the minimum privilege necessary to fund a specific bounty or deposit. An exact allowance equal to the required transaction amount would normally be sufficient. The command reference lists `approve_token({ token, spender?, amount? })` but does not warn that omitting `amount` grants an unlimited allowance. ERC-20 approval does not itself transfer tokens, but it authorizes the approved spender to call `transferFrom` without another signature until the allowance is revoked or exhausted. The authorization also applies to future token deposits. ### Attack Path 1. A user or agent invokes `approve_token` without an `amount`, believing the omitted parameter has a safe default. 2. Alternatively, malicious task content or unsafe agent reasoning causes an attacker-controlled addr ...[truncated 843 chars]- Remediation
View remediation
