MinPoolLiquidity bypass in withdraw_asset_amount makes stableswap vulnerable to sole-depositor manipulation attack #42
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
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-154
🤖_42_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2024-02-hydradx/blob/603187123a20e0cb8a7ea85c6a6d718429caad8d/HydraDX-node/pallets/stableswap/src/lib.rs#L677-L681
Vulnerability details
The Omnipool has a
MinPoolLiquidity
integrity check against thetotal_issuance
of pool shares, to prevent price manipulations:This check is however relaxed in the
withdraw_asset_amount
function, with no check on pool shares issuance, to always allow a given user to redeem the entirety of their shares:This relaxed check can be exploited to bring the
total_issuance
of pool shares belowMinPoolLiquidity
, potentially down to single digits where the value of shares can can be further inflated with token donations to the pool account, which, unlike omnipools, are not filtered by the application runtime.Impact
The value of shares of a pool with a single liquidity provider can be manipulated. This will prevent other liquidity providers from entering the pool and allow the single liquidity provider to arbitrarily change the prices of the pool's swaps without risking assets.
Proof of Concept
The following PoC shows how exploiting the
withdraw_asset_amount
relaxed check and donating tokens to the pool allows extreme share value inflation and arbitrary pool price manipulation, and how entering this situation allows an attacker to keep other liquidity providers out of the pool:Tools Used
Code review, unit tests
Recommended Mitigation Steps
MinPoolLiquidity
ontotal_issuance
also onwithdraw_asset_amount
REMOVE_LIQUIDITY
flag set, so trading won't happen on manipulated poolsAssessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: