The _doDexSwap function does not properly validate the callData before executing a swap. Since _doDexSwap is responsible for interacting with the Paraswap protocol through the ParaSwapUtils.swap function, unverified callData can lead to incorrect swaps. This vulnerability can result in unintended token swaps, incorrect balance calculations, or failed transactions due to incorrect token approvals.
This function takes in the swap data and decodes it to retrieve:
to: the target contract address (Paraswap in this case)
amount: the amount being swapped
callData: the transaction data for the Paraswap call
However, there is no validation on callData before passing it to ParaSwapUtils.swap(), meaning:
The fromToken in the decoded calldata may not match the expected inputToken.
The calldata structure may be incorrect, leading to failed swaps or unintended approvals.
The swap may execute an unintended token pair if the calldata is tampered with.
_runSwap calls _doDexSwap
_doDexSwap extracts callData and executes ParaSwapUtils.swap
ParaSwapUtils.swap extracts token addresses from callData and executes the swap
No validation ensures that fromToken matches inputToken
Consider a scenario where the keeper provides an incorrect callData where:
The fromToken is not the expected inputToken
The swap is executed for a different token than intended
If the extracted fromToken does not match inputToken, the function may still proceed with execution, leading to an incorrect swap.
Incorrect Swaps: The function may swap the wrong tokens due to manipulated calldata.
Fund Mismanagement: If the wrong token is approved and swapped, user funds could be misallocated.
Failed Transactions: If an invalid callData is provided, transactions may revert, leading to inefficiencies.
Potential Fund Loss: If tokens are swapped incorrectly and sent to an unintended address, funds may become irrecoverable.
Manual Code Review
callData Before ExecutionModify _doDexSwap to extract fromToken from callData and ensure it matches inputToken.
ParaSwapUtils.swapModify ParaSwapUtils.swap() to validate fromToken before executing the swap.
Add an event to log decoded fromToken and expected inputToken before executing swaps.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point. Keepers are added by the admin, there is no "malicious keeper" and if there is a problem in those keepers, that's out of scope. ReadMe and known issues states: " * System relies heavily on keeper for executing trades * Single keeper point of failure if not properly distributed * Malicious keeper could potentially front-run or delay transactions * Assume that Keeper will always have enough gas to execute transactions. There is a pay execution fee function, but the assumption should be that there's more than enough gas to cover transaction failures, retries, etc * There are two spot swap functionalies: (1) using GMX swap and (2) using Paraswap. We can assume that any swap failure will be retried until success. " " * Heavy dependency on GMX protocol functioning correctly * Owner can update GMX-related addresses * Changes in GMX protocol could impact system operations * We can assume that the GMX keeper won't misbehave, delay, or go offline. " "Issues related to GMX Keepers being DOS'd or losing functionality would be considered invalid."
This function call only reached via a function called by the keeper. So no malicious callData will be provided.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.