Open code423n4 opened 1 year ago
Effectively same as #515
But I think for now High Severity is more appropriate
GalloDaSballo marked the issue as primary issue
Because of open fees, close fees and spread, that wouldn't be profitable. We also have a cooldown after a trade is opened so there will be enough time for price to move freely past the sl.
TriHaz marked the issue as sponsor disputed
The warden has shown a flaw in how the protocol offers Stop Losses.
By using the originally stored value for Stop Loss, instead of just using it as a trigger, an attacker can perform a highly profitable strategy on the system as they know that their max risk is capped by the value of the Stop Loss, instead of the current asset price.
This will happen at the detriment of LPs
Because the attack breaks an important invariant, causing a loss to other users, I agree with High Severity
GalloDaSballo marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2022-12-tigris/blob/588c84b7bb354d20cbca6034544c4faa46e6a80e/contracts/TradingExtension.sol#L88-L120
Vulnerability details
Impact
User can abuse how stop losses are priced to open high leverage trades with huge upside and very little downside
Proof of Concept
When closing a position with a stop loss the user is closed at their SL price rather than the current price of the asset. A user could abuse this in directional markets with high leverage to make nearly risk free trades. A user could open a long with a stop loss that in $0.01 below the current price. If the price tanks immediately on the next update then they will be closed out at their entrance price, only out the fees to open and close their position. If the price goes up then they can make a large gain.
Tools Used
Manual Review
Recommended Mitigation Steps
Take profit and stop loss trades should be executed at the current price rather than the price specified by the user: