The owner can allow new (non-core) tokens to be sold in the contract via the setAllowedSellToken(...) function.
Users can list non-core tokens (like DAI, UNI, etc.) for sale via the createSellOrder(...) function. These tokens are temporarily stored in the contract until filled or canceled.
However, the owner can arbitrarily drain these tokens at any time using the emergencyWithdrawERC20(...) function — even if they don’t belong to them and while orders are still active
The root issue lies in the fact that:
The contract allows the owner to transfer any non-core token balance even while they are being listed
And it doesn't ensure the tokens were originally deposited by the owner
This opens a backdoor for fund extraction from sellers.
High:
The owner has full control over the system due to onlyOwner modifier.
Any seller listing a non-core token exposes their funds to potential owner withdrawal.
No checks exist to prevent this during active orders.
High:
Users lose tokens locked in the contract
No way to recover stolen funds
Allows centralized manipulation of liquidity
The seller loses their tokens
The owner gets them for free
No transaction reverts — everything looks normal
Allow the owner to recover only tokens that were not part of any active order , and do not belong to the list of tokens allowed be sold— i.e., truly unintended deposits.
i. Add Mapping to Track Token Deposits from Sellers
userTokenDeposits[seller][token]
: How much of a given token was deposited by users.
Helps distinguish between user-owned tokens and owner-owned/orphaned tokens.
ii. Update createSellOrder(...) to Record Deposit
This records how much of each token has been deposited by whom.
iii. Clear Deposit Tracking When Order Is Filled or Canceled
Update both buyOrder(...) and cancelSellOrder(...) to reduce the deposit tracking when orders are closed.
In buyOrder(...)
In cancelSellOrder(...)
This keeps the mapping accurate and prevents false assumptions about ownership.
iv. Restrict emergencyWithdrawERC20(...)
to Non-Allowed & Non-Active Tokens
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.