Position.isIncreasing() is used to check whether the user's order is increasing the position or not. However, this function does not take into account the possibility of a user position moving from short to long or long to short, allowing many important security measures to be bypassed.
Consider the following scenario:
Alice have a position with size = 5
Alice Request a order with sizeDelta = -15
Position.isIncreasing() returns false -> Protocol thinks Alice is reducing his position.
Alice now have a position with size = -10
This incorrect `isIncreasing` value can bypass many security measures and lead to many potential problems. For example:
Users can still create positions in disabled markets
As long as the user has a position in that market, then he can open very large positions in the opposite direction.
Users can bypass the InitialMargin and open positions using a margin between InitialMargin and MaintenanceMargin.
Alice wants to open a short position with size = -1000
Alice open a long position with size = 1 (Assuming more than minimum size)
Alice make a short order with sizeDelta = -1001
As a result of this issue, the market believes that Alice is reducing his position and therefore requires Alice to have only the MaintenanceMargin.
Likelihood: High - This vulnerability is not dependent on the market environment.
+
Impact: High - 1. Users can bypass the InitialMargin 2. Users can still create positions in disabled markets, make it impossible for markets to gracefully retire.
=
Severity: High
Manual review
Make additional check in Position.isIncreasing() to address the situation where a new position crosses 0.
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.