T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/test_okx.sh:53
- Finding
- Hardcoded Third-Party Wallet Address in Swap Transaction Generation<![CDATA[ ## Vulnerability Details **File Location**: `scripts/test_okx.sh:53-59` **Vulnerability Type**: Unsafe hardcoded financial transaction parameter **Risk Level**: Medium ```bash echo "4) Swap Transaction" call "GET" "/api/v6/dex/aggregator/swap?chainIndex=1&fromTokenAddress=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&toTokenAddress=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&amount=500000000000000000&swapMode=exactIn&slippagePercent=0.01&userWalletAddress=0xaa4e09ab283e207bd7171d924db2dda49315637b" | jq '{ tx: .data[0].tx, router: .data[0].routerResult.router, priceImpactPercent: .data[0].routerResult.priceImpactPercent, dexRouterList: (.data[0].routerResult.dexRouterList // []) }' ``` ### Technical Analysis The executable test script requests swap transaction data using the fixed wallet address `0xaa4e09ab283e207bd7171d924db2dda49315637b` instead of obtaining the executing user's wallet address. A wallet address is a security-sensitive transaction parameter because the API may use it when constructing calldata, determining the sender or recipient context, applying routing behavior, or associating the transaction with a user. The hardcoded address is not required for the skill's declared functionality. The minimum necessary behavior is to accept a wallet address explicitly from the user, validate it, and display it for confirmation before requesting transaction data. The script does not access private keys, sign transactions, or broadcast generated transactions. Therefore, it does not independently transfer funds or obtain wallet privileges. The vulnerability becomes exploitable only if a user treats the output as production-ready, signs it, and broadcasts it without verifying the embedded transaction details. ### Attack Path 1. A user configures valid `OKX_API_KEY`, `OKX_SECRET_KEY`, and `OKX_PASSPHRASE` credentials. 2. The user executes `scripts/test_okx.sh`, expecting swap transaction data relevant to their own wallet. 3. The script sub ...[truncated 1541 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the hardcoded wallet address and require an explicit environment variable: ```bash : "${USER_WALLET_ADDRESS:?USER_WALLET_ADDRESS must be set}" ``` 2. Validate that the supplied value is a correctly formatted EVM address before making the request: ```bash if [[ ! "$USER_WALLET_ADDRESS" =~ ^0x[0-9a-fA-F]{40}$ ]]; then echo "Invalid EVM wallet address" >&2 exit 1 fi ``` 3. URL-encode all user-controlled query parameters rather than interpolating them directly into the request URL. 4. Display the wallet address, token pair, amount, chain, and slippage before requesting or presenting transaction data. 5. Require explicit user confirmation before transaction generation when the script is used interactively. 6. Clearly label `scripts/test_okx.sh` as test-only and warn that returned calldata must be independently decoded and verified before signing. 7. Add an assertion that the wallet represented in the generated transaction context matches the user-provided wallet whenever the API response exposes sufficient information. 8. Ensure `_meta.json` accurately lists all distributed executable files, including `scripts/test_okx.sh`, so reviewers and package users are aware of the script. ]]>
