The emergencyWithdrawERC20() function inside OrderBook.sol allows the contract owner to withdraw any non-core token without checking whether theses tokens are from any order
Once any non-core token (e.g. AAVE) is allowed to sell and its order is created, the owner can simply call emergencyWithdrawERC20() and withdraw all tokens
Likelihood: High — The contract owner is directly authorized to perform the exploit, and no time-delay or governance control limits this behavior.
Impact: High — Arbitrary withdrawal of sellable assets will break trust and can lead to rug-pull behavior or theft of user-deposited tokens.
Add the followingMockAAVE.sol to the test/mocks directory
Import MockAAVEinto TestOrderBook.t.sol
Declare aaveand initialize it inside setUp()
Append the following test, then run forge test -vv --match-test test_exploitEmergencyWithdrawERC20
PoC Results:
Inside OrderBook.sol:
Add a mapping of locked token balance:
Update createSellOrder(), amendSellOrder(), cancelSellOrder() and buyOrder() to track lock changes
Modify emergencyWithdrawERC20() to subtract locked balance from actual balance
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.