RustFund

First Flight #36
Beginner FriendlyRust
100 EXP
View results
Submission Details
Severity: high
Valid

Refunds Do Not Check Goal

Summary

The refund function checks only that the campaign’s deadline has passed. It does not verify whether the goal was met, meaning contributors can get refunds even from successful campaigns.

Vulnerability Details

pub fn refund(ctx: Context<FundRefund>) -> Result<()> {
let amount = ctx.accounts.contribution.amount;
if ctx.accounts.fund.deadline != 0 && ctx.accounts.fund.deadline > Clock::get().unwrap().unix_timestamp.try_into().unwrap() {
return Err(ErrorCode::DeadlineNotReached.into());
}
...
}

Impact

A successful campaign that raised sufficient funds may lose them to refunds, preventing the creator from using the funds as intended.

Tools Used

N/A

Recommendations

Add a check to ensure refunds are only allowed when the campaign fails

require!(fund.amount_raised < fund.goal, ErrorCode::GoalReached);
Updates

Lead Judging Commences

bube Lead Judge
3 months ago

Appeal created

bube Lead Judge 3 months ago
Submission Judgement Published
Validated
Assigned finding tags:

There is no check for goal achievement in `refund` function

Support

FAQs

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