The withdraw function (lines 90-105) allows the campaign creator to withdraw all raised funds at any time. There are no checks for:
Whether the deadline has passed
Whether the funding goal was reached
The only validation is that the caller is the creator (has_one = creator on line 163).
A malicious creator can:
Create a campaign with an attractive goal and description
Wait for contributions to accumulate
Call withdraw immediately, taking all funds before the deadline
Contributors have no protection and lose their SOL
This completely undermines the trustless crowdfunding model. The "deadline" and "goal" features are meaningless if the creator can withdraw at any time.
Creator creates a fund with goal = 100 SOL, deadline = 30 days from now
Contributors contribute 50 SOL total over 5 days
Creator calls withdraw on day 6 — succeeds with no checks
Creator receives 50 SOL
Contributors cannot get refunds (even if the contribute bug were fixed, the funds are already gone)
Add deadline and goal checks to withdraw:
pub fn withdraw(ctx: Context
let fund = &ctx.accounts.fund;
// Require deadline to have passed
require!(fund.deadline != 0 && fund.deadline = fund.goal, ErrorCode::GoalNotReached);
let amount = fund.amount_raised;
// ... rest of withdrawal logic
}
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.