Closed c4-bot-3 closed 7 months ago
0xRobocop marked the issue as sufficient quality report
0xRobocop marked the issue as primary issue
enthusiastmartin (sponsor) disputed
The calls is not needed in mentioned functions. sacrifice position does not change any liquidity. and remove-token just removes token .
OpenCoreCH marked the issue as unsatisfactory: Invalid
OpenCoreCH changed the severity to 2 (Med Risk)
OpenCoreCH marked the issue as duplicate of #51
OpenCoreCH marked the issue as partial-50
Lines of code
https://github.com/code-423n4/2024-02-hydradx/blob/main/HydraDX-node/pallets/omnipool/src/traits.rs#L49 https://github.com/code-423n4/2024-02-hydradx/blob/main/HydraDX-node/pallets/omnipool/src/lib.rs#L869-L910 https://github.com/code-423n4/2024-02-hydradx/blob/main/HydraDX-node/pallets/omnipool/src/lib.rs#L1527-L1575
Vulnerability details
Impact
As we can read from the protocol documentation, the calling of
on_liquidity_changed
hook after a liquidity change is very important. This is because the hook is used to update the oracle and in the circuit breaker. Systems that rely onon_liquidity_changed
hooks to calculate or report on liquidity metrics may show inaccurate data since not all liquidity changes are being captured. Also hacker can exploit the absence of liquidity change tracking to manipulate market conditions.Proof of Concept
on_liquidity_changed
hook is used in Omnipool and is very important function that is called when liquidity is added or removed from the pool. It is very important to call it in certain operations because update on-chain oracle and the circuit breaker.This hook is missing in the sacrifice_position() and remove_token() functions.
remove_token()
Removes token from Omnipool:sacrifice_position()
destroys a position and position's shares become protocol's shares:It is very important to call
on_liquidity_changed
on these operations because it is used to update the oracle and also in the circuit breaker.Tools Used
Visual Studio Code
Recommended Mitigation Steps
Call the
on_liquidity_changed
hook at the end of these functions.Assessed type
Other