Traders can use TradingAccountBranch::withdrawMargin to have risk-free trades and bypass the MarketOrder::marketOrderMinLifetime check by cancelling them before being settled if the price is going in the other direction :
The easiest way this to be achieved is the traders to have account without any other positions in it. That way they will always be able to withdraw their entire collateral since TradingAccountBranch::withdrawMargin does not perform check whether it has pending order, which is the core of the issue. For example user wants to open long position in ETH/USD market and in time of creation price is $1000, there is some time that OrderKeeper doesn’t pick this order and price increases to $1200, this situation eats from the PnL of the user, or more critically the collateral type (which is any of the assets here) is volatile and it’s price falls which will decrease the margin of the trader. Seeing that the owner can call TradingAccountBranch::withdrawMargin taking his entire collateral balance and then in SettlementBranch::_fillPrice transaction will revert and the Keeper will not execute it again:
Another impact is that marketOrderMinLifetime which is parameter used in OrderBranch::cancelMarketOrder to prevent trader from cancelling order before some time passes is bypassed.
Traders can maliciously cancel their orders when unfavorable conditions happen after order is announced and bypass the marketOrderMinLifetime by simply withdrawing their collateral.
Manual Review
In TradingAccountBranch::withdrawMargin call MarketOrder::checkPendingOrder as well.
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.