Closed c4-bot-9 closed 6 months ago
raymondfam marked the issue as insufficient quality report
raymondfam marked the issue as primary issue
Check the LibOracle. It already has fallback to a Uniswap TWAP.
hansfriese marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-03-dittoeth/blob/91faf46078bb6fe8ce9f55bcb717e5d2d302d22e/contracts/facets/PrimaryLiquidationFacet.sol#L135 https://github.com/code-423n4/2024-03-dittoeth/blob/91faf46078bb6fe8ce9f55bcb717e5d2d302d22e/contracts/facets/PrimaryLiquidationFacet.sol#L47-L90 https://github.com/code-423n4/2024-03-dittoeth/blob/91faf46078bb6fe8ce9f55bcb717e5d2d302d22e/contracts/facets/PrimaryLiquidationFacet.sol#L47-L90 https://github.com/code-423n4/2024-03-dittoeth/blob/91faf46078bb6fe8ce9f55bcb717e5d2d302d22e/contracts/facets/PrimaryLiquidationFacet.sol#L122-L143
Vulnerability details
Reliance on a single price oracle for critical functions, such as liquidations and redemptions, makes it vulnerable to oracle manipulation or unreliability, potentially leading to financial losses for users.
liquidate
function relies on a single oracle price obtained throughLibOracle.getPrice(asset)
to determine the collateral ratio of the short position.Issue Description
PrimaryLiquidationFacet.sol
contract is responsible for liquidating undercollateralized short positions.LibOracle.getPrice
function to obtain the current price of the asset from the oracle.liquidate, _setLiquidationStruct
The
liquidate
function is expected to accurately determine the collateral ratio of a short position using the current market price provided by a reliable oracle.Impact
Proof of Concept
Let's see a scenario of how reliance on a single oracle in the DittoETH protocol can lead to incorrect liquidations and potential financial losses for users.
PoC Steps:
The attacker manipulates the Oracle price feed, causing it to report an incorrect price of $150 to the protocol.
The
liquidate
function is called for Alice's short position.Inside the
liquidate
function, the_setLiquidationStruct
function is invoked to retrieve the oracle price and calculate the collateral ratio.The
LibOracle.getPrice(asset)
function returns the manipulated price of $150, which is used to calculate the collateral ratio.Due to the manipulated oracle price, the calculated collateral ratio for Alice's position falls below the liquidation threshold of 150%, even though the actual market price hasn't changed.
The
liquidate
function proceeds with the liquidation process, incorrectly liquidating Alice's sufficiently collateralized position.Alice suffers unwarranted financial losses as a result of the incorrect liquidation.
Code Snippet:
Impact:
Tools Used
Manual Audit
Recommended Mitigation Steps
Implement a multi-oracle approach:
Implement a fallback oracle mechanism:
Assessed type
Oracle