LibFlood.handleRain()
is used to return Bean price to 1 USD in the start of the season in case price is > 1 USD. Here's docs page
It is done by:
Calculate deltaB
of every soppable Well
Reduce positive deltaB
by negative deltaB
to get "clean" Bean shortage
Mint that shortage of Beans
Swap Bean to non-Bean token in Well.
That's how Flood concept reduces Bean price down to 1 USD. Problem is that in step 1 it calculates deltaB
based on current manipulateable reserves.
It creates following attack vector, suppose Well is USDC / Bean:
Attacker inflates Bean price by supplying big amount of USDC.
Attacker calls sunrize()
and Flood is performed.
Calculated deltaB
is very big.
So it mints big amount of Bean. Real value of Bean decreases down to 0.
Attacker successfully decreased Bean price below the peg, breaking main purpose of Beanstalk. He can utilize it on his own purposes, for example liquidate positions on Lending market collateralized by Bean and so on.
There is following chain of calls:
Here you can see it calls LibDeltaB.currentDeltaB()
to calculate deltaB
:
Here you can see it mints that deltaB
amount of Beans:
Attacker can increase the supply of Bean and therefore decrease it's price down to 0 by manipulating reserves in soppable Well.
Manual Review
Use Instantaneous reserves to calculate deltaB
in LibFlood.getWellsByDeltaB()
instead of current.
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.