RustFund

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

Zero Deadline Enables Immediate Refund Regardless of Timing

Summary

If deadline = 0 (never set), the logic in contribute and refund incorrectly bypasses normal checks. It effectively allows sponsors to deposit and immediately get a refund.

Vulnerability Details

if ctx.accounts.fund.deadline != 0 && ctx.accounts.fund.deadline > Clock::get().unwrap().unix_timestamp.try_into().unwrap() {
return Err(ErrorCode::DeadlineNotReached.into());
}

When fund.deadline = 0, the check is skipped, enabling immediate refund calls without waiting for any actual time-based condition.

Impact

  • No Real Commitment: Sponsors can trivially deposit and then withdraw.

  • Unstable Funding: The campaign can never hold onto funds if deadline = 0, undermining the entire crowdfunding model.

Tools Used

  • Analysis of logical conditions in the contribute and refund functions.

  • Comparison with the protocol's business logic described in the documentation.

Recommendations

  • Define explicit behavior for companies with deadline = 0: either ban such campaigns, or treat them as indefinite, but without the possibility of refund.

  • Add a check so that when deadline = 0, the rand function returns an error, or change the condition to check that deadline must be a positive value.

Updates

Appeal created

bube Lead Judge 6 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.