In OrderBranch::createMarketOrder
users are only allowed to decrease/close their position when the market or settlement is disabled. But due to a insufficient check inside Position::isIncreasing
a user increase their position in the opposite side (e.g turn a short into a long or a long into a short).
When a user calls OrderBranch::createMarketOrder
the following checks are made:
That is in order to prevent users from increasing their position in a disabled market or when settlement is disabled which can happen for multiple reasons and is always necessary to have. If we take a look in the Position::isIncreasing
function we can see it determines the direction of the change by the signs of the size
and sizeDelta
variables but it ignores their magnitude
That means that if sizeDelta
is big enough it could create a position on the opposite side.
Example:
size = 1BTC
, sizeDelta = -3BTC
After the check self.size == 0
is false (self.size > 0 && sizeDelta > 0)
is also false and (self.size < 0 && sizeDelta < 0)
is false making the entire return value false making the contract believe that the user is reducing/closing their position while they are actually increasing the amount of liquidity they are using in their trade.
Users are allowed to increase their positions despite the fact that they should not be able to which can lead to unexpected behavior and a likely loss of funds as market are usually disabled due to market manipulations and other security concerns.
Manual review
VS Code
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.