OrderBook

First Flight #43
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Incomplete Token Restrictions in `OrderBook::emergencyWithdrawERC20`

Description

The `emergencyWithdrawERC20` function restricts withdrawal of core tokens by hardcoding checks for `iWETH, iWBTC, iWSOL, and iUSDC,` but it doesn’t check whether the token is listed in allowedSellToken.

// Root cause in the codebase with @> marks to highlight the relevant section

Impact:

If a new token is added to `allowedSellToken` via `setAllowedSellToken()`, the owner could withdraw user-deposited tokens via the emergency function—even if actively being used in orders.

Proof of Concept

Only checks hardcoded tokens

if (_tokenAddress == address(iWETH) || ...) revert;
allowedSellToken[_tokenAddress] not checked

Recommended Mitigation

Also check allowedSellToken`[_tokenAddress] == true` to block withdrawals of any currently accepted sell token:

function emergencyWithdrawERC20(address _tokenAddress, uint256 _amount, address _to) external onlyOwner {
if (
_tokenAddress == address(iWETH) || _tokenAddress == address(iWBTC) || _tokenAddress == address(iWSOL)
|| _tokenAddress == address(iUSDC)
) {
revert("Cannot withdraw core order book tokens via emergency function");
}
if (_to == address(0)) {
revert InvalidAddress();
}
+ require(!allowedSellToken[_tokenAddress], "Cannot withdraw active sell token");
IERC20 token = IERC20(_tokenAddress);
token.safeTransfer(_to, _amount);
emit EmergencyWithdrawal(_tokenAddress, _amount, _to);
}
Updates

Lead Judging Commences

yeahchibyke Lead Judge
about 1 month ago
yeahchibyke Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.