RustFund

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

Missing Refund Deadline Edge Case in RustFund Contract

Summary

The refund function doesn’t handle deadline = 0, potentially allowing refunds before a deadline is set.

Vulnerability Details:
The vulnerable code is in the refund function:

rust

if ctx.accounts.fund.deadline != 0 && ctx.accounts.fund.deadline > Clock::get().unwrap().unix_timestamp.try_into().unwrap() {
return Err(ErrorCode::DeadlineNotReached.into());
}
  • No Check: deadline = 0 skips the condition, proceeding to refund.

Impact:

  • Funds Misallocation: Unintended refunds in uninitialized campaigns.

Tools Used: Manual Review

Recommendations:
Add check:

rust

if fund.deadline == 0 {
return Err(ErrorCode::DeadlineNotSet.into());
}

Add new error code:

rust

#[error_code]
pub enum ErrorCode {
// ... existing errors ...
#[msg("Deadline not set")]
DeadlineNotSet,
}

Updates

Appeal created

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

Possible refund before the deadline is initialized

Support

FAQs

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