The OrderBranch::createMarketOrder function does not allow users to specify a maximum acceptable slippage or a minimum fill price. This vulnerability exposes users to asset price variations and sandwich attacks, where an attacker can manipulate the market price to their advantage, resulting in the user's order being filled at a significantly worse price than expected.
This issue is not limited to malicious actors; even large legitimate orders can adversely impact the market price and lead to unfavorable fills for other users.
The victim creates a market order to buy 1,000 units of an asset perpetual contract.
The attacker observes the victim's pending market order in the mempool.
The attacker submits a large buy order for 10,000 units of the asset, front-running the victim's order.
The attacker's large buy order causes the market price to spike
The keeper then fills the victim's market order at the new, higher price, which is significantly worse than the price the victim expected.
The attacker then creates a sell order to close their position, profiting from the price manipulation.
The victim is left with a position that is immediately underwater due to the unfavorable fill price.
Use the following file to test the scenario described above:
Potential for Significant User Losses:
The absence of slippage protection can expose users to substantial losses if their orders are filled at unfavorable prices. This risk is particularly severe for large positions, potentially compromising users' financial well-being and trading strategies.. Such experiences can erode trust in the protocol and deter user engagement..
Erosion of User Trust and Decreased Adoption:
Repeated negative experiences with order executions can damage the protocol's reputation, leading to decreased user engagement and adoption due to fear of unexpected losses. This, in turn, can reduce liquidity and overall participation.
Increased Costs for the Protocol:
Decreased adoption and liquidity can lead to reduced revenue and profitability for the protocol
Manual Testing
Enhance the OrderBranch::createMarketOrder function by allowing users to specify maximum acceptable slippage or a maximum fill price. This can be done by adding additional parameters to the calldata:
Then implement a check in the SettlementBranch::fillMarketOrder function to verify that the fill price falls within the user's specified range.. If the fill price exceeds the user's acceptable range, the order should be reverted.
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.