User can avoid bankrupting by calling PositionManager.moveLiquidity where to index is bankrupted index #179
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
H-09
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-core/src/PositionManager.sol#L262-L333
Vulnerability details
Impact
User can avoid bankrupting by calling PositionManager.moveLiquidity where to index is bankrupted index
Proof of Concept
Bucket could become insolvent and in that case all LP within the bucket are zeroed out (lenders lose all their LP). Because of that,
PositionManager.reedemPositions
will not allow to redeem index that is bankrupted.When user wants to move his LPs from one bucket to another he can call
PositionManager.moveLiquidity
where he will provide from and to indexes.https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-core/src/PositionManager.sol#L262-L333
As you can see
from
bucket is checked to be not bankrupted before the moving.And after the move, LPs of
from
andto
buckets are updated.Also
depositTime
ofto
bucket is updated tofrom.depositTime
.The problem here is that
to
bucket was never checked to be not bankrupted.Because of that it's possible that bankrupted
to
bucket now becomes not bankrupted as their depositTime is updated now.This is how this can be used by attacker.
1.Attacker has lp shares in the bucket, linked to token and this bucket became bankrupt.
2.Then attacker mints small amount of LP in the Pool and then memorizes this index to the token.
3.Attacker calls
moveLiquidity
withfrom
: new bucket andto
: bankrupt bucket.4.Now attacker can redeem his lp shares from bankrupt bucket as depositedTime is updated now.
As result, attacker was able to steal LPs of another people from
PositionManager
contract.Tools Used
VsCode
Recommended Mitigation Steps
In case if
to
bucket is bankrupt, then clear LP for it before adding moved lp shares.Assessed type
Error
The text was updated successfully, but these errors were encountered: