In CreditLine#_borrowTokensToLiquidate , oracle is used wrong way
In the liquidation path of the CreditLine contract, the price oracle was queried with the borrow asset and collateral asset in the wrong order, so the ratio returned was inverted relative to what the calculation expected. A liquidator or lender could therefore lose or gain funds during liquidation because of the miscalculated price.
Submitted by 0x0x0x
Current implementation to get the price is as follows:
(uint256 _ratioOfPrices, uint256 _decimals) = IPriceOracle(priceOracle).getLatestPrice(_borrowAsset, _collateralAsset);
But it should not consult borrowToken / collateralToken, rather it should consult the inverse of this result. As a consequence, in liquidate the liquidator/lender can lose/gain funds as a result of this miscalculation.
Mitigation step
Replace it with
(uint256 _ratioOfPrices, uint256 _decimals) = IPriceOracle(priceOracle).getLatestPrice(_collateralAsset, _borrowAsset);
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The oracle call passed the borrow asset and collateral asset in the wrong order, returning an inverted price ratio that the liquidation maths did not account for.
Impact
During liquidation the inverted ratio could cause the liquidator or lender to lose or gain funds, as the text states.
What the attacker needed
A position eligible for liquidation
The fix
The oracle call should be made with the collateral asset first and the borrow asset second, which the project confirmed as the mitigation.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract often asks a price service, called an oracle, how much one token is worth compared with another. Here the contract asked for the price in the wrong direction, like asking how many dollars one euro buys when you actually need how many euros one dollar buys. That flipped number was then used to work out how much a borrower owes during liquidation, so the amounts paid out could be wrong.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.