Zeros make use of fillOffchainOrders
to support limit order, take profit, stop loss order. But the targetPrice
's check is improper for some scenarios.
From the previous cyfrin audit report, the sponsors mentions that we have implemented a new "Off-Chain" order feature which allows users to specify a targetPrice. This feature is flexible enough to implement limit, stop, tp/sl and other types of trigger-based orders using some additional off-chain code.
The vulnerability is that the targetPrice
's meaning is a little difference for limit order, tp or sl. We should check the targetPrice correctly.
For example:
The market's current market price is 120.
Alice submits one limit order to buy some token with target price 100.
Keepers can trigger fillOffchainOrders
successfully with current market price 120. Because we match the check logic ctx.isBuyOrder && ctx.offchainOrder.targetPrice <= ctx.fillPriceX18.intoUint256()
.
Although the keeper is trusted, the keeper will trigger the fillOffchainOrders
when the keeper find that we match the traders' requirement. However, considering the possible reorg, or the suddenly price jump, it's also possible that traders will take some unexpected loss because the non-functional target price protection.
Traders may take some unexpected fund loss because of the non-functional target-price.
Manual
Add one new parameter to mark the order type, limit order, stop loss, take profit and check the target price according to the different order type.
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.