The swap
function in the ParaSwapUtils
library is vulnerable to malicious callData
. The function does not fully validate the callData
passed to it, which could allow an attacker to craft malicious callData
to manipulate the swap operation or drain funds.
proof of concept
Deploy the ParaSwapUtils
library.
Deploy a malicious contract that crafts malicious callData
.
Call the swap
function with the malicious callData
.
ParaSwapUtils Library (Vulnerable)
The malicious contract crafts callData
to manipulate the receiver
address and steal funds.
Deploy the ParaSwapUtils
library to a testnet or local blockchain.
Deploy the MaliciousCaller
contract, which will be used to demonstrate the exploit.
Approve a legitimate ERC20 token (e.g., tokenAddress
) for the ParaSwapUtils
contract with a sufficient allowance.
Call the exploitMaliciousCallData
function in the MaliciousCaller
contract, passing the address of the ParaSwapUtils
library, the legitimate token address, and the amount to steal.
The swap
function will execute the malicious callData
, approving the approvalAddress
for the specified amount.
The attacker can then call the stealTokens
function to transfer the approved tokens to their address.
The swap
function will approve the approvalAddress
for the specified amount of tokens.
The attacker will successfully steal the approved tokens by calling the stealTokens
function.
An attacker could craft callData
to manipulate the fromToken
, fromAmount
, or receiver
address, potentially draining funds from the contract or redirecting tokens to an unauthorized address.
Malicious callData
could cause the function to behave unexpectedly, such as swapping the wrong tokens or amounts.
If the callData
includes a call to a malicious contract, it could exploit reentrancy vulnerabilities in the swap
function.
Manual Code Review
Thoroughly validate the callData
parameters before using them. validate the callData
and ensure the receiver
address is not manipulated.
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.