T09 · Insecure Skill Coding Practices
- Location
SKILL.md:438- Finding
EVM Trade Examples Disable Slippage Protection
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 438-469
Vulnerability Type: Unprotected decentralized-exchange swaps caused by a zero minimum-output value
Risk Level: HighVulnerable Code
markdown ### Buy EVM Tokens POST /openclaw/buy { "chainId": "1", "walletId": "abc123", "tokenAddress": "0x...", "ethAmount": "0.01", "amountOutMin": "0" } Works for **both** bonding curve and post-DEX. The API detects the phase automatically. ### Sell EVM Tokens POST /openclaw/sell { "chainId": "1", "walletId": "abc123", "tokenAddress": "0x...", "tokenAmount": "1000", "amountOutMin": "0" } Notes: - Auto-approves ERC-20 allowance if needed (both bonding curve and Aerodrome router) - Don't sell too much at once — can cause revert on small pools - `amountOutMin: "0"` = no slippage protection (use `getQuote` to set a reasonable value for post-DEX) - For post-DEX sells: you're selling the `agentToken`, but pass the original `tokenAddress` — the API resolves itTechnical Analysis
The documented EVM buy and sell requests explicitly set
amountOutMinto"0". This value permits a transaction to execute regardless of how few output assets the user receives. Although the document acknowledges that this means there is no slippage protection, it still presents the unsafe value in the primary trading examples.On automated-market-maker exchanges, transaction prices can change between request preparation and on-chain execution. A zero minimum-output constraint removes the normal safeguard that would revert a transaction when execution differs materially from the quoted price. This exposes trades to ordinary market volatility, low-liquidity price impact, and deliberate miner/maximal extractable value activity such as sandwich attacks.
The instruction to use a quote is limited to post-DEX trading and is phrased as optional guidance. The Skill does not require a fresh quote, calculate a nonzero minimum output, enforce a tran ...[truncated 1470 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove
amountOutMin: "0"from all documented trading examples and prohibit zero minimum-output values at the API-validation layer. -
Obtain a fresh quote immediately before every buy or sell, including both bonding-curve and post-DEX trades.
-
Ask the user to approve a bounded maximum-slippage percentage rather than silently choosing an unlimited value.
-
Calculate the protected minimum output using the quoted output and approved tolerance:
text amountOutMin = quotedAmountOut × (1 - approvedSlippage) -
Require
amountOutMinto be a positive integer in the asset's smallest denomination and reject malformed, zero, or negative values. -
Add a short transaction deadline or quote expiration time so stale transactions cannot execute after market conditions change materially.
-
Before submission, show the expected output, guaranteed minimum output, price impact, fees, and selected slippage tolerance.
-
Require renewed confirmation when price impact or slippage exceeds a conservative threshold.
-
Re-quote and request confirmation rather than automatically retrying a transaction after a slippage-related revert.
-
Apply server-side controls so safety does not depend exclusively on an AI agent correctly interpreting documentation.
-
