Bypassing Minimum Pool Liquidity Limit via Liquidity Removal Could Lead To DoS #118
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
insufficient quality report
This report is not of sufficient quality
primary issue
Highest quality submission among a set of duplicates
🤖_17_group
AI based duplicate group recommendation
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2024-02-hydradx/blob/603187123a20e0cb8a7ea85c6a6d718429caad8d/HydraDX-node/pallets/omnipool/src/lib.rs#L820-L843
Vulnerability details
Impact
A user is able to bypass the minimum pool liquidity limit by first depositing liquidity to the pool using
add_liquidity()
and then removing liquidity using theremove_liquidity()
function to remove shares, which results in the pool ending up with dust shares.Other possible impacts:
Proof of Concept
The issue can be observed in the
remove_liquidity()
function in thepallets/omnipool/src/lib.rs
file. Specifically, the function does not ensure that the left amount after withdrawal of the token is at least equal to the minimum pool liquidity limit.remove_liquidity()
solely checks if the amount of shares to be withdrawn is non zero or the amount of shares left in the position position after after withdrawal is either zero or non-zerohttps://github.com/code-423n4/2024-02-hydradx/blob/603187123a20e0cb8a7ea85c6a6d718429caad8d/HydraDX-node/pallets/omnipool/src/lib.rs#L820C4-L843C5
To run the Proof of concept, add the following test to
pallets/omnipool/src/tests/add_liquidity.rs
Result:
Tools Used
Manual Review, Substrate
Recommended Mitigation Steps
To mitigate this issue, it is recommended to enforce a check during the withdrawal process to ensure that the remaining amount of the token after withdrawal is at least equal to the minimum pool liquidity limit.
The easiest hot-fix, to implement to mitigate this would be to ensure that the remaining position shares are bigger than the minimum liquidity limit
To correctly mitigate this, it is necessary to implement the math to calculate the balance of Tokens left and to compare it to the minimum liquidity limit.
Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: