The emergencyWithdrawERC20
function allows the contract owner to withdraw any ERC20 token held by the contract, excluding the four specified core trading tokens. This creates a significant centralization risk, enabling a malicious or compromised owner to drain non-core funds.
Root Cause: The emergencyWithdrawERC20
function, accessible only by the owner, directly transfers arbitrary ERC20 tokens.
Solidity
Likelihood: High. The function is an explicit capability of the owner. Its existence is the risk.
Impact: High.
Loss of Funds: Users' accidentally sent tokens (non-core) can be permanently lost if the owner withdraws them.
Rug Pull Vector: While core tokens are protected, other potentially valuable assets could be drained, leading to a trust breakdown and financial loss for users.
Centralization: Contradicts decentralized principles by giving a single entity arbitrary withdrawal power.
The owner simply calls the function to withdraw unintended or accidentally sent tokens.
Scenario:
A user accidentally sends 1000 DAI (a non-core ERC20) to the OrderBook
contract.
The OrderBook
contract now holds 1000 DAI.
The contract owner calls emergencyWithdrawERC20(address(DAI), 1000, owner_address)
.
The 1000 DAI are transferred from the OrderBook
to the owner, without user consent or possibility of recovery.
Option 1 (Strongest): Remove the Function: Eliminate this function to remove the rug-pull vector and uphold decentralization. Accidental token transfers would be permanently locked unless future upgrades (with robust governance) allow recovery.
Diff
Option 2 (Alternative): Implement Decentralized Control: If emergency withdrawal is deemed essential, transfer control to a multi-signature wallet or DAO governance. Additionally, implement a time-lock (e.g., 7 days) on withdrawals to allow community reaction.
Reference Files:
src/OrderBook.sol
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.