The RustFund crowdfunding contract contains a vulnerability where the campaign creator can withdraw contributed funds prematurely, even if the campaign deadline has not passed and the funding goal has not been met. This behavior contradicts the project’s intended design, which states that withdrawals should only occur after a campaign succeeds.
The flaw arises from the implementation of the withdraw
function. The function transfers the entire raised amount from the campaign’s account to the creator’s account without checking whether the campaign has reached its deadline or met its funding goal. Specifically:
Lack of Deadline and Goal Checks:
The withdraw
function lacks conditional logic to verify that the campaign's deadline has passed and that the funding goal is achieved before allowing withdrawals.
Current Implementation:
The function simply deducts the total raised funds from the fund account and credits the creator's account:
Erosion of Trust:
Contributors expect that their funds are secured until the campaign’s success conditions are met. Early withdrawal by the creator undermines this trust and may dissuade future contributions.
Financial Risk for Contributors:
If funds are withdrawn prematurely, contributors may be left without recourse if the campaign does not meet its goals, potentially resulting in financial losses.
Regulatory and Reputation Concerns:
The lack of proper fund-locking mechanisms can expose the platform to regulatory scrutiny and damage the project’s reputation within the decentralized ecosystem.
Manual Review
Enforce Withdrawal Conditions:
Modify the withdraw
function to include checks that ensure:
The campaign deadline has passed.
The funding goal has been met before allowing the creator to withdraw funds.
Implement State Flags:
Introduce a state flag or additional logic to mark a campaign as "successful" only when all conditions (e.g., deadline, funding goal) are satisfied.
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.