Steal an assetTokens underlying tokens
Address.functionCall will execute target.call{value: value}(data) using its context; implying it's executed directly by the Thunderloan in its context, which is dangerous for any access-controlled functions requiring onlyThunderLender
. Thunderloan is manipulated to call any contract address, to execute any arbitrary function on that contract, with the permissions of Thunderloan.
Attacker can simply call flashloan
borrowing 0 tokens;
pass in receiverAddress as Asset Token address for token they want to steal e.g USDC;
pass in IERC20 token as address(0) for token input
pass in bytes calldata params that ensures its a payload that executes AssetToken.transferUnderlyingTo(address,amount)
to transfer an amount of asset token from their preferred address e.g
The following is how the attack will be allowed to happen as it succeeds in many code aspects in ThunderLoan.sol
By passing in token input = address(0), receiverAddress as assetToken contract, bytes data as function call to transferUnderlyingTo and borrowing amount = 0; attacker can steal and or drain underlying tokens held within an assetToken contract.
Attacker can use flashloan to transfer underlying token from asset token to their own account therefore stealing or draining asset Token contracts token balances.
Manual Analysis
Damn Vulnerable DeFi Challenge Truster Solution => https://stermi.medium.com/damn-vulnerable-defi-challenge-3-solution-truster-7a4e00233ecd
Enforce zero address checks for token input
Enforce amount borrowed is greater than zero
Enforce that receiverAddress implements IFlashLoanReceiver to reduce attack surfaces on arbitrary contract
Recommended to call executeOperation directly and drop receiverAddress.functionCall(), just like how Aave does it e.g
Extreme measure is to avoid passing in bytes calldata params which hinders the flexibility of flashloan to receiver but may be safer as its not rare to see flash loans implementing such simple formats
Or any other such suitable measures to prevent this attack vector
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.