The withdraw
function allows the creator of a fund to withdraw all raised funds (amount_raised
) without any checks on whether the campaign was successful (i.e., reached its goal
) or whether the deadline has passed. This allows for premature and potentially malicious withdrawals.
The withdraw
function (programs/rustfund/src/lib.rs
, simply transfers the entire amount_raised
from the fund
account to the creator
account:
There are no checks to ensure that:
fund.amount_raised >= fund.goal
(the campaign was successful)
Clock::get().unwrap().unix_timestamp >= fund.deadline
(the deadline has passed)
Medium: The creator can withdraw funds before the campaign is supposed to end, potentially defrauding contributors who believed their funds would only be used if the goal was reached. This breaks the trust model of the crowdfunding platform.
Manual code review
Add checks to the withdraw
function to ensure that the withdrawal is only allowed if the campaign has met its goal AND the deadline has passed.
You will need to define GoalNotReached
error:
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.