Bypassing OrderBook::emergencyWithdrawERC20 restrictions via OrderBook::setAllowedSellToken allows owner to withdraw open order tokens
The function OrderBook::emergencyWithdrawERC20 is intended to prevent withdrawal of core tokens.
This logic fails to consider tokens dynamically added to the system via OrderBook:setAllowedSellToken function. When the owner sets a new ERC20 token as allowed and a user deposits it by creating a sell order, the owner can withdraw it via OrderBook:emergencyWithdrawERC20, even when the order is still active.
Likelihood:
When the owner sets a new ERC20 token as allowed token and a user deposits it by creating a sell order
Impact:
The owner can withdraw the newly set token via OrderBook:emergencyWithdrawERC20, even when the order is still active.
This test demonstrates how the owner of the contract adds MockWSUI as an allowed sell token.
A user creates a sell order and deposits MockWSUI into the contract.
The owner then calls OrderBook::emergencyWithdrawERC20 and withdraws the token to another address.
The user's open order is now effectively broken, yet the test still passes, highlighting the silent failure.
Add tracking for tokens ever used in orders
Then update the OrderBook::emergencyWithdrawERC20 function:
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.