Closed code423n4 closed 1 year ago
That would happen only if a user tried to remove all margin, which would revert anyway here: https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/Trading.sol#L436
No impact so will dispute.
TriHaz marked the issue as sponsor disputed
With the information that I have, in lack of a POC, I believe that rightfully the margin of a position cannot be set to 0 (otherwise you're getting a position with infinite leverage / a position with a payout but no cost)
For this reason, with the sponsor disputing and not much else to use to defend the report, am closing for lack of proof.
I highly recommend adding a coded POC next time to have your report withstand basic scrutiny
GalloDaSballo marked the issue as unsatisfactory: Insufficient proof
Lines of code
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/Trading.sol#L404-L441
Vulnerability details
Margin can't be totally removed in
removeMargin
Impact
Margin can't be removed totally because of revert
Proof of Concept
As we can see in the added tag
@audit line 1
:uint256 _newMargin = _trade.margin - _removeMargin; //@audit line 1
What means that_newMargin
= to actualtrade.margin
-_removeMargin
, that is the amount of margin to remove. This shouldn't be an issue, but the problem is that divisions by 0 revert, if we try to removed all the margin:uint256 _newLeverage = _trade.margin * _trade.leverage / _newMargin;//@audit line 2
We can see that it will divide by_newMargin
that is 0, and therefore, removing all the margin is not possible.Code:
Recommended mitigation steps
Add an if path to handle case where margin is removed to 0 by calling
removeMargin