Protocol loss in case price is far away from stop loss price. #482
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-622
nullified
Issue is high quality, but not accepted
Lines of code
https://github.com/code-423n4/2022-12-tigris/blob/588c84b7bb354d20cbca6034544c4faa46e6a80e/contracts/TradingExtension.sol#L118
Vulnerability details
Impact
Each position when opened on Tigris has an optional stop loss price. Whenever market price drop below stop loss price, the position can be closed automatically by bot. However, there is a flaw in term of what price position should be closed. In the current codebase, even when market price drops below stop loss price, the position is still closed at stop loss price.
If the market price is drop far away from stop loss price, protocol will result in loss.
Proof of Concept
Consider the scenario
slPrice = 100
.90
, her position is still closed at100
when it should be closed at90
. So she got100 - 90
in price diff and this profit is taken from protocol.Tools Used
Manual Review
Recommended Mitigation Steps
Consider closing position at market price when reaching stop loss. In addition to that, adding check to make sure close price is not too far, for example: more than 1%
The text was updated successfully, but these errors were encountered: