Summary
This report highlights a vulnerability in the withdraw
function that allows campaign creators to withdraw funds multiple times without updating the contract’s state. This flaw enables infinite withdrawals, potentially draining all funds from the contract and causing state inconsistencies that could affect refunds and accounting.
Vulnerability Details
withdraw
Code Snippet:
Issue:
The function does not reset amount_raised
or mark the campaign as closed.
Since the same amount remains recorded in amount_raised
The creator can call withdraw
multiple times, continuously draining funds.
The function does not verify the actual SOL balance of the campaign account, leading to potential over-withdrawals if SOL is sent directly to the fund.
Impact:
Infinite Withdrawals:
The contract does not track whether funds have already been withdrawn.
The creator can repeatedly withdraw the same amount, exceeding the campaign’s actual balance.
Overdrawn Campaign Funds:
If external SOL transfers increase the campaign’s balance, withdrawals may exceed the intended limit.
Example Exploit: A donor sends SOL directly to the contract account → withdraw
allows the creator to drain this extra SOL as well.
Incorrect Refunds:
Since amount_raised
is never updated, contributors may attempt to claim refunds for non-existent funds, leading to errors or failed transactions.
Tools Used
Manual Code Review: Identified the missing state updates and incorrect fund tracking.
Recommendations
Ensure that withdrawals do not** exceed** the fund’s actual SOL balance.
Fixed Code:
Introduce a closed
flag to prevent multiple withdrawals.
Updated Struct:
Updated Function:
AlreadyClosed
Error CodeConclusion
The current implementation fails to update the state after withdrawal, allowing creators to drain funds repeatedly. By incorporating state tracking (via closed
flag) and ensuring withdrawals do not exceed actual balances, this vulnerability can be effectively mitigated.
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.