The OrderBook::setAllowedSellToken
function allows the owner to add a new token to OrderBook::allowedSellToken
mapping variable, enabling it for trading in the order book. Subsequently, the OrderBook::emergencyWithdrawERC20
function permits the owner to withdraw any token except the core tokens (wETH, wBTC, wSOL, USDC). However, a newly allowed token can be withdrawn via OrderBook::emergencyWithdrawERC20
function, potentially allowing the owner to drain user-deposited tokens that were added to the order book.
This vulnerability enables the owner to add a new token, allow users to deposit it for sell orders, and then withdraw those tokens via OrderBook::emergencyWithdrawERC20
, effectively stealing user funds. This undermines the trust and integrity of the order book, as users expect their deposited tokens to be secure unless used in valid trades.
Deploy the OrderBook contract with valid addresses for wETH, wBTC, wSOL, and USDC.
Owner calls setAllowedSellToken(address(newToken), true) to allow a new token (newToken).
Alice creates a sell order for newToken via createSellOrder(address(newToken), 100e18, 1000e6, 1 days), transferring 100 newToken to the contract.
Owner calls emergencyWithdrawERC20(address(newToken), 100e18, owner), transferring Alice’s 100 newToken to themselves.
Alice’s sell order remains active but cannot be fulfilled as the tokens are no longer in the contract, leading to potential loss of funds.
Create a file in test/mocks/
named MockNewToken.sol
for this contract:
Add this to test/TestOrderBook.t.sol
Restrict OrderBook::emergencyWithdrawERC20
function to only allow withdrawal of tokens that are not in OrderBook::allowedSellToken
mapping variable. This ensures that tokens used in active sell orders cannot be withdrawn by the owner, protecting user funds.:
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.