The LibUsdOracle.getUsdPrice()
returns the price of a given token in USD
with the option of using a lookback
. (Usd:token Price) lookback
should be 0
if the instantaneous price is desired. Otherwise, it should be the TWAP
lookback in seconds.
According to this function's comments:
However, the function doesn't implement the recommendation specified in the comment regarding the use of a non-zero lookback.
https://github.com/Cyfrin/2024-04-beanstalk-2/blob/27ff8c87c9164c1fbff054be5f22e56f86cdf127/protocol/contracts/libraries/Oracle/LibUsdOracle.sol#L34-L46
After retrieving the USD price from the respective oracle function, the function checks if the returned price is zero
. If it's zero
, it returns zero as the USD price of the token.
If the price is not zero, it calculates the USD price of the token by dividing 1e24
by the retrieved price.
However, the USD price returned may be a manipulated figure.
Malicious actors can exploit the absence of the minimum lookback period
to manipulate recent price data, influencing the calculated USD prices of tokens
. This manipulation can lead to inaccurate representations of token values or calculations within the protocol.
Manual Review
Adjust the function to accept a substantially large lookback parameter and pass it to the oracle functions.
With this modification, the function now checks if the lookback parameter is greater than 900 seconds
before proceeding to retrieve the USD price from the respective oracles. This ensures that a substantially large lookback
is used to protect against manipulation, as recommended in the comment.
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.