OrderBook

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

Denial of Service on Fees Withdrawal

Root + Impact -** **The withdrawFees function reverts when totalFees == 0, preventing the owner from calling this function and potentially causing confusion about the contract state.

Description

  • The withdrawFees function is designed to allow the owner to withdraw accumulated protocol fees

  • The function includes a check that reverts if totalFees == 0, which prevents the owner from calling this function when no fees have been collected, even for testing or verification purposes

// Root cause in the codebase
function withdrawFees(address _to) external onlyOwner {
if (totalFees == 0) { // @> This check prevents calling the function when no fees exist
revert InvalidAmount();
}
if (_to == address(0)) {
revert InvalidAddress();
}
iUSDC.safeTransfer(_to, totalFees);
totalFees = 0;
emit FeesWithdrawn(_to);
}

Risk

Likelihood:

  • Owner may want to call this function for testing or verification purposes

  • Function appears broken to users when no fees have been collected

Impact:

  • Owner cannot test fee withdrawal functionality

  • Confusing user experience with unclear error messages

Proof of Concept - The following scenario demonstrates how the withdrawal function becomes unusable during normal operation:

// Scenario:
// 1. Contract is deployed
// 2. No orders have been filled yet, so totalFees = 0
// 3. Owner calls withdrawFees(ownerAddress)
// 4. Transaction reverts with InvalidAmount() error
// 5. Owner cannot verify the withdrawal mechanism works

Recommended Mitigation - Allow the function to execute successfully even when no fees are available, providing clear feedback through events:

function withdrawFees(address _to) external onlyOwner {
- if (totalFees == 0) {
- revert InvalidAmount();
- }
if (_to == address(0)) {
revert InvalidAddress();
}
+ if (totalFees == 0) {
+ emit FeesWithdrawn(_to); // Emit event even when no fees to withdraw
+ return;
+ }
iUSDC.safeTransfer(_to, totalFees);
totalFees = 0;
emit FeesWithdrawn(_to);
}
Updates

Lead Judging Commences

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

Appeal created

khandelwalmoksh787 Submitter
about 1 month ago
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.