Users can gain an unfair advantage over other users by manipulating the price of barnRaiseToken
, which is used to mint Fertilizer. This manipulation can be achieved by frontrunning the oracle, inflating the price of barnRaiseToken
, and minting Fertilizer at an advantageous rate over other users.
With the implementation of Uniswap's V3 Pool version, the wstETH:ETH feed is used to determine the amount of Fertilizer
that can be minted.
The price oracle used (LibUniswapOracle) fetches the TWAP (Time Weighted Average Price) from a Uniswap V3 pool.
This oracle uses a modified version of the consult function, which rounds down the arithmeticMeanTick
.
The issue here is, that the price of barnRaiseToken
is determined by the oracle.
A malicious user can frontrun the oracle, using a flash loan to drive up the price of barnRaiseToken, i.e wstETH
. Now that there is a higher price, when the arithmeticMeanTick
is rounded down....................
The difference between the minLPAmountOut
specified by the malicious user and the actual amount of Fertilizer minted will be significant, leading to an unfair advantage over other users.
Because when the flash loan is repaid, the feed price of barnRaiseToken
will return to a lower price.
(Whenever you use a getPrice
in an oracle to fetch the latest price feed, this is susceptible to flash loans).
Any users who call mintFertilizer
after this, may experience receiving a lower amount of Fertilizer or a revert
in the Well due to the rounding down of the arithmeticMeanTick
and the minLPAmountOut
specified.
Because the Oracle rounds down to the nearest tick (not the nearest decimal price), the difference can be quite dramatic
Users can mint Fertilizer at an advantageous rate over other users by manipulating the price of barnRaiseToken,
breaking the fairness of Beantalk's mechanism for minting Fertilizer.
Manual Review/Foundry
Beanstalk could simply implement their own version of the consult, which involves not rounding down the arithmeticMeanTick
. Another option could be strictly for the Twap method, to use a longer look back period to reduce the impact of frontrunning.
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.