The verifyOffchainPrice()
function does not currently check whether the price fetched from the PremiumReport
is greater than zero. This omission can lead to the use of invalid price data, resulting in incorrect asset valuations during swaps.
The verifyOffchainPrice()
function decodes a PremiumReport
from verified price data and performs the following checks:
It ensures that the report is not expired by verifying that block.timestamp
is not greater than premiumReport.validFromTimestamp + self.maxVerificationDelay
.
However, it lacks a validation step to ensure that the price
is valid (greater than zero
) before proceeding with further calculations.
Now, notice that in fulfillSwap()
, this function is invoked to get price from report and used as shown here:
If the price used in the swap is bogous, the calculated ctx.amountOutBeforeFeesX18
will be based on an incorrect price. This means that the amount of collateral assets the user receives in exchange for their USD tokens could be significantly different from what they expect.
The slippage check compares the expected output (ctx.amountOut
) against the minimum acceptable amount (request.minAmountOut
). If the price is incorrect and results in a higher ctx.amountOut
, it may pass the slippage check even though the actual market conditions do not support such a price.
Users could end up receiving less collateral than they should have based on the valid market price.
Manual Review
Add a check to ensure that block.timestamp
is not earlier than premiumReport.validFromTimestamp
.
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.