The OrderBook
contract utilizes the Ownable
pattern, granting a single external address (owner
) exclusive control over several critical functions. If this single owner's private key is compromised, an attacker would gain full administrative control over the protocol's configuration and treasury management functions, leading to severe consequences.
Root Cause: The Ownable
pattern centralizes administrative control to a single address, creating a single point of failure.
Solidity
Likelihood: Medium. While direct smart contract vulnerabilities are not the cause, private key compromises (e.g., phishing, weak security practices, insider threat) are a common attack vector in the blockchain space. The likelihood increases with the value controlled by the key.
Impact: High.
Loss of Protocol Fees: A compromised owner can call withdrawFees
to drain all accumulated protocol fees.
Arbitrary Token Withdrawal (Rug Pull Vector): The emergencyWithdrawERC20
function (as previously discussed in a dedicated finding) allows the owner to withdraw any non-core ERC20 tokens accidentally or intentionally sent to the contract. A compromised owner could use this to drain such funds.
Market Manipulation/Disruption: The owner can call setAllowedSellToken
to disable legitimate trading tokens or enable malicious ones, disrupting the order book's intended functionality.
Reputational Damage: A successful attack due to a compromised admin key severely damages user trust and the protocol's reputation.
This is a direct consequence of a compromised private key; no complex exploit code is needed within the smart contract itself.
Scenario:
The private key associated with the OrderBook
contract's owner
address is compromised (e.g., via a phishing attack, malware, or insider collusion).
The attacker gains control of the owner
address.
The attacker then calls withdrawFees(attacker_address)
to steal all accumulated protocol fees.
The attacker could also monitor for any accidental ERC20 deposits (non-core tokens) and use emergencyWithdrawERC20(accidental_token_address, amount, attacker_address)
to drain those funds.
The attacker could call setAllowedSellToken(iWETH, false)
to disable trading of WETH, severely impacting the protocol's functionality and user experience.
To significantly reduce the risk associated with a single point of failure, implement operational security best practices for the owner's address.
Multi-Signature Wallet:
Transfer ownership of the OrderBook
contract to a multi-signature wallet (e.g., Gnosis Safe, Safe). This requires a predefined number of trusted signers (e.g., 3 out of 5) to approve any administrative action, making it much harder for a single compromised key to cause damage.
Pro: Greatly enhances security and decentralizes control.
Con: Adds overhead to administrative operations.
Time-Locked Admin Actions:
Implement a time-lock mechanism for critical owner-only functions. This means that after an owner initiates a sensitive action (e.g., withdrawing fees, changing allowed tokens), there's a mandatory delay (e.g., 24-72 hours) before the action can be executed.
Pro: Provides a window for the community or other guardians to detect and react to malicious or unauthorized actions.
Con: Delays legitimate administrative actions.
Proposed Change (Conceptual - requires external setup or a dedicated Timelock
contract): The contract code itself would ideally remain onlyOwner
, but the owner
address would point to a multi-sig wallet or a Timelock
contract. No direct Solidity code change is presented here, as this is an architectural/operational change.
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.