TwentyOne

First Flight #29
Beginner FriendlyGameFiFoundrySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Ether Accumulates and Becomes Permanently Stuck in the Contract

Summary

The contract does not include a mechanism for the owner to withdraw Ether that accumulates in the contract. Over time, forfeited wagers and unused deposits remain permanently locked, rendering the funds inaccessible. Without a withdrawal function, the Ether in the contract is effectively unusable, leading to inefficiencies and financial loss for the contract owner.

Vulnerability Details

  • Root Cause:

    • The contract does not implement a withdrawal function for the owner to retrieve the accumulated Ether.

    • Any forfeited player wagers or unclaimed Ether from game activities are locked indefinitely in the contract balance.

  • Symptoms:

    • The contract accumulates funds over time from:

      • Wagers lost by players.

      • Unused or excess Ether deposited for the prize pool.

    • These funds remain stuck in the contract, with no mechanism for the owner to reclaim or reallocate them.

  • Code Affected:

    • No withdraw or similar function exists in the contract, preventing the owner from accessing the accumulated funds.

  • Behavior Details:

    • Ether in the contract balance cannot be withdrawn by any actor, including the owner, resulting in permanent inaccessibility.

Impact

  • Locked Funds:

    • Any Ether that accumulates in the contract cannot be accessed, leading to potential financial loss for the owner.

  • Operational Inefficiency:

    • The inability to withdraw funds restricts the owner from reallocating the accumulated Ether for operational or strategic purposes.

  • Protocol Shutdown Challenges:

    • If the game is discontinued or migrated to a new contract, the locked funds cannot be transferred, resulting in a complete loss of the accumulated balance.

Tools Used

Manual code review.

Recommendations

Add a Secure Withdrawal Function:

  • Introduce a withdrawal function that allows the contract owner to retrieve Ether from the contract balance:

    function withdraw(uint256 amount) public onlyOwner {
    require(amount <= address(this).balance, "Insufficient contract balance");
    payable(owner).transfer(amount);
    }
Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Owner has no method to withdraw

Support

FAQs

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