I can take a flashloan and deposit the loaned funds plus the fee instead of repaying the loan and the flashloan will be successful. I can then redeem the LP tokens I received during the deposit step thereby sealing the liquidity provided by the LPs.
in src/upgradedProtocol/ThunderLoanUpgraded::flashloan
and src/protocol/ThunderLoan::flashloan
, we verify if the flashloan has been repaid by verifying if the endingBalance >= startingBalance + fee
if (endingBalance < startingBalance + fee) {
Neither do we verify how the loaned funds + the fees gets back into the contract now do we verify if there's an ongoing flashloan when we try to deposit funds and therein likes the vulnerability.
Notice that, even the fee was deposited and thus can be redeemed as well.
in the terminal run forge test --mt testFlashLoanVulnerability -vvv
A malicious user can steal all of the liquidity provided by other LPs.
Manual review
Prevent deposits during flashloans.
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.