Insolvent user could avoid liquidation due to logic error #186
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-421
edited-by-warden
grade-a
Q-36
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
🤖_31_group
AI based duplicate group recommendation
Lines of code
https://github.com/code-423n4/2024-04-panoptic/blob/833312ebd600665b577fbd9c03ffa0daf250ed24/contracts/libraries/PanopticMath.sol#L241-L268
https://github.com/code-423n4/2024-04-panoptic/blob/833312ebd600665b577fbd9c03ffa0daf250ed24/contracts/PanopticPool.sol#L1450-L1452
https://github.com/code-423n4/2024-04-panoptic/blob/833312ebd600665b577fbd9c03ffa0daf250ed24/contracts/PanopticPool.sol#L1017-L1171
Vulnerability details
Impact
Available possibility for loss of funds, due to unexpected liquidation DoS
Proof of Concept
At the end of
PanopticMath::twapFilter
, the tick atsortedTicks[10]
is returned, which isn't at the median ofsortedTicks
with 19 length, which leads to permanent returning of higher tick than actual.There are 2 main scenarios which could occur due to bad indexation:
PanopticPool::liquidate
, the function could revert unexpectedly due to(Math.abs(currentTick - twapTick) > MAX_TWAP_DELTA_LIQUIDATION)
won't pass, because ofcurrentTick - twapTick
is going to be higher than it is supposed to be (if actualTwapTick > currentTick).PanopticPool::liquidate
,PanopticPool::_getSolvencyBalances
is called to compute thebalanceCross
andthresholdCross
.The third parameter from the input is the sqrtPrice at the twapTick. Due to the logic error the sqrtPrice is permanently going to be higher than actual, because of this the chases of
(balanceCross >= thresholdCross)
check to revert are permanently increased (if tokenData0.rightSlot() > tokenData0.leftSlot()).Tools Used
Recommended Mitigation Steps
Rewrite the end of the function to get the median value from 9th index instead of 10th
Assessed type
Other
The text was updated successfully, but these errors were encountered: