Closed c4-bot-2 closed 8 months ago
0xEVom marked the issue as insufficient quality report
0xEVom marked the issue as duplicate of #10
Fails to articulate the root cause.
jhsagd76 marked the issue as partial-50
jhsagd76 changed the severity to 2 (Med Risk)
Lines of code
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Oracle.sol#L272-L326
Vulnerability details
Impact
priceX96
andverifyPriceX96
variables are used wrongV3Oracle::_getReferenceTokenPriceX96
The issue occurs when both
usesChainlink
andusesTWAP
are true. In this case, thepriceX96
variable is set to the value ofchainlinkPriceX96
, andverifyPriceX96
is set to the value oftwapPriceX96
or vice versa, depending on the oracle mode. However, when the function checks the difference betweenpriceX96
andverifyPriceX96
, it does not take into account which variable was set to the chainlink price and which was set to the TWAP price.This can result in a significant price difference between the two oracle sources, which can cause the function to revert or return incorrect price data.
For example, if the chainlink price is much higher than the TWAP price, and
priceX96
is set to the chainlink price andverifyPriceX96
is set to the TWAP price, the function will revert because the difference between the two prices is too high. However, if the opposite is true andpriceX96
is set to the TWAP price andverifyPriceX96
is set to the chainlink price, the function will not revert and will return incorrect price data.Proof of Concept
Tools Used
Manual Review
Recommended Mitigation Steps
The function should check which oracle source is being used for
priceX96
andverifyPriceX96
and adjust the difference calculation accordingly. For example:This ensures that the difference calculation is always correct, regardless of which oracle source is being used for
priceX96
andverifyPriceX96
.Assessed type
Math