There is the explicit expectation in the code that, the exchange rate will always go up.
In the codebase, we have the line
if (newExchangeRate <= s_exchangeRate) {
Let's assume 2 instants in time T1 and T2 spread 2 days apart. At T1, we deposit amount A1 of liquidity to the pool and we get a new exchange rate of E1 and at T2, we deposit amount A1 of liquidity again to the same pool of T1 and we get a new exchange rate of E2.
This means that, E2 > E1
this means that, even though in both cases we're minted amount A1 of AssetTokens
, the LP redeems at an exchange rate of E2 will receive more underlying tokens that was supposed to at the expense of the other LPs that haven't yet redeemed even if no flash-loan was taken between T1 and T2.
Let's note that, this is also agravated by the fact that, we fail to adjust the exchange rate to a newer and lower value when LPs withdraw funds in the application in the following methods.
src/protocol/ThunderLoan::redeem
Even though the exchange rate was increased when a deposit was made.
src/protocol/ThunderLoan::repay
Even though the exchange rate was increased when a flash-loan was taken.
run forge test --mt testWrongExchangeRateVulnerability -vvv
Malicious LP can steal the liquidity provided by the other LPs.
Manual review
Review the updateExchangeRate
method and enable the exchange rate to increase/decrease according to the current liquidity in reserve.
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.