Increasing/opening an order in case of a disabled market or settlement.
When filling an order it checks that in case of an increasing/opening order, both the market and settlement are enabled.
https://github.com/Cyfrin/2024-07-zaros/blob/main/src/perpetuals/branches/SettlementBranch.sol#L376
This is verified by calling the internal function isIncreasing.
https://github.com/Cyfrin/2024-07-zaros/blob/main/src/perpetuals/leaves/Position.sol#L155
This can be bypassed by the following scenario.
The attacker opens a short position, and later it becomes filled.
Then, the owner disables the market or settlement.
Then the attacker creates a long position where the size is larger than the previous short position. In other words, the attacker flips its direction from short to long.
By doing so, the protocol considers it non-increasing order because of size < 0 and sizeDelta > 0, thust it allows the order to be filled even though the market or the settlement is disabled.
In the following test, the user creates a short order with size 10 and later it becomes filled. Then, the owner disables the ETH market. Then the user creates a long order with size 15 so that the short position will be closed and a long position with size 5 would be opened even though the market is disabled.
Increasing/opening an order in case of a disabled market or settlement.
The following code is recommended:
https://github.com/Cyfrin/2024-07-zaros/blob/main/src/perpetuals/leaves/Position.sol#L155
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.