OrderBook

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

High: Unrestricted fee change by owner

Root + Impact

Description

  • Normal behavior: In decentralized trading protocols, the owner typically has the privilege to adjust trading fees to manage platform sustainability, attract liquidity, or respond to market shifts. This adjustment is expected to occur within a reasonable range (like 0.1% - 1%) to balance platform revenue against user incentives.

  • Issue: In this contract, the setFee function has no maximum cap, meaning the owner (or anyone with control of the private key) could maliciously or accidentally set the fee to an extremely high value, such as 1000%. This transforms the protocol into an unfair system where users lose most or all of their trading capital to fees, violating the basic economic trust model required for participation.

function setFee(uint256 _fee) external onlyOwner {
@> fee = _fee; // unrestricted parameter
}

Risk

Likelihood:

  • This risk materializes the moment the owner sets the fee above a competitive market norm, which could happen by mistake or as a deliberate rug pull.

  • Since there's no technical constraint, the only safeguard is human trust in the owner's intentions and operational security against private key compromise.

Impact:

  • Any excessive fee instantly redirects user trade funds to the protocol treasury, potentially wiping out liquidity providers or traders.

  • Trust in the platform collapses, leading to massive liquidity withdrawal, protocol death, and possible reputational damage to the ecosystem.

Proof of Concept

orderBook.setFee(100_000); // sets a 1000% fee
orderBook.placeBuyOrder(...);
// user trade pays out almost entirely to the protocol

This shows how trivially the owner can call setFee with an extreme parameter. Any subsequent trade by users results in nearly their entire transaction value being consumed as fees. The PoC highlights how a single transaction by the owner breaks the economic safety of all future protocol interactions.


Recommended Mitigation

function setFee(uint256 _fee) external onlyOwner {
- fee = _fee;
+ require(_fee <= 1000, "Fee too high"); // enforce <=10%
+ fee = _fee;
}

This mitigation ensures that, regardless of owner intentions or key compromise, the fee cannot exceed 10%. It protects the core economic fairness of the protocol by making abusive fee rates structurally impossible. This also aligns with best practices in DeFi governance, where critical parameters should have safe bounds.


Updates

Lead Judging Commences

yeahchibyke Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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