omnipool: set_asset_tradable_state should ensure slot price if not far from oracle price when set an asset to safe withdraw mode #174
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
duplicate-22
🤖_16_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/main/HydraDX-node/pallets/omnipool/src/lib.rs#L745
Vulnerability details
Impact
Users can lose all the withdrawn assets as fees when the asset is in safe withdraw mode.
Proof of Concept
In
remove_liquidity
, we will skip the spot/oracle price check if it's a safe mode withdraw (i.e. sell and buy are disabled).To prevent liquidity attacks, we apply a fee (max 100%) on the withdrawal action, which depends on the spot/oracle price diff.
It seems we assume if the asset is in safe mode, spot/oracle price diff should be minimal since the trade is disabled and other operations don't change the price.
However, in
set_asset_tradable_state
which can set an asset to the safe mode, we don't check if the spot/oracle diff is big (T::PriceBarrier::ensure_price
), which can lead to:set_asset_tradable_state
.ensure_price
is not triggered this time and Alice will suffer from a big fee.Tools Used
Manual Review.
Recommended Mitigation Steps
Call
ensure_price
inset_asset_tradable_state
when we set an asset to the safe mode.Assessed type
Context
The text was updated successfully, but these errors were encountered: