Root Cause: Requiring the caller to be owner when the withdrawal always sends to owner -> Impact: Unnecessary access check, extra gas cost, and prevents anyone else from simply triggering the payout.
The withdrawPlatformFees()
function enforces an onlyOwner
check even though its logic always sends the entire balance to the owner()
.
Since the recipient is fixed as the owner, requiring that the caller also be the owner adds no extra security but does incur a small gas overhead on each call. Furthermore, it prevents any benign helper contract or script from triggering the withdrawal on the owner’s behalf, forcing the owner’s own account to originate the transaction every time.
Likelihood: High
onlyOwner
check ensures msg.sender == owner()
.
Recipient is owner()
regardless of who calls.
Issue: Caller restriction duplicates the recipient check and adds ~100–200 gas for the modifier’s storage read and comparison.
Impact: Gas
Minor Gas Overhead: Extra storage read and comparison per call (~100–200 gas).
Rigid UX: Only the owner’s own account can trigger withdrawal, preventing simple helpers or scripts from automating payouts.
No Security Gain: Caller restriction duplicates the transfer-to-owner guarantee already in the code.
Tools Used:
Foundry Test Suite
Chat-GPT AI Assistance (Report Grammar Check & Improvements)
Manual Review
Add to test/Game.t.sol
:
Run:
If you remove onlyOwner
, step (1) succeeds (any caller can trigger), step (2) still sends to owner, demonstrating identical security with greater flexibility.
Scenario:
A simple helper script or automated tool wants to trigger the owner’s fee withdrawal. Because onlyOwner
is required, that script must use the owner’s private key rather than a simpler relay or proxy. Removing onlyOwner
would allow any address to call the function, but funds still go only to owner()
.
Remove onlyOwner
Modifier
Any caller can now trigger the withdrawal, but funds still go only to owner()
.
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.