A Liquidity provider can earn risk-free rewards to encounter a DoS on ThunderLoan::redeem due to the incorrect exchange rate being updated in ThunderLoan::deposit.
In ThunderLoan::deposit on line 154, the exchange rate is updated using the amount of tokens the liquidity provider (LP) deposited:
This means that the LP earns a fee based on their deposited amount. If an LP deposits and withdraws in the same block, they can either earn risk-free rewards with prior liquidity or encounter a DoS in 'redeem' due to insufficient liquidity. The intended behavior is for fees to come from a flash loan, where the LP gets a share of the borrower's fee. If no loans were taken, the LP either steals from other LP deposits or faces a DoS due to insufficient funds.
An attacker can front-run an LP when they send a deposit() transaction and send and redeem a large transaction, earning a fee without any loans being taken. The attacker is therefore stealing from the LP's deposit and the LP will encounter a DoS when they attempt to redeem. This means an attacker can recursively deposit and redeem funds, draining the entire contract liquidity.
If an LP deposits funds and then decides to redeem without any loans being taken, if there are not sufficient funds in the contract, the LP will encounter a state of DoS on redeem().
This is a high likelihood and high impact vulnerability so it is therefore a high severity finding.
The following test demonstrates that if an attacker front runs an LP calling deposit() and then redeems immediately, the attacker will be able to redeem more than their initial deposit and the LP will not be able to withdraw to insufficient funds
As observed, the test passed meaning that an attacker can redeem extra tokens even if no loans have been taken, causing other LPs to encounter a DoS when redeeming if no other LPs have deposited.
Remove the exchange rate update from deposit():
Forge
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.