RustFund

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

Missing Input Validation for Fund Creation

Summary

The fund_create function in the RustFund program does not perform validation on the goal parameter, allowing the creation of fundraising campaigns with invalid or unrealistic goals, such as 0 or extremely large values. This lack of input validation can lead to misleading campaigns or unintended program behavior.

Vulnerability Details

In the fund_create function:

pub fn fund_create(ctx: Context<FundCreate>, name: String, description: String, goal: u64) -> Result<()> {
let fund = &mut ctx.accounts.fund;
fund.name = name;
fund.description = description;
fund.goal = goal;
fund.deadline = 0;
fund.creator = ctx.accounts.creator.key();
fund.amount_raised = 0;
fund.dealine_set = false;
Ok(())
}
  • The goal parameter (type u64) is directly assigned to fund.goal without any checks.

  • No minimum value check exists to prevent a goal of 0.

  • No maximum value check exists to ensure the goal is reasonable or within practical limits (e.g., less than u64::MAX).

  • Other parameters like name and description have length constraints via #[max_len], but goal lacks similar validation.

This allows:

  • Creation of a fund with goal = 0, which could be instantly "met" despite no contributions.

  • Creation with goal = u64::MAX (18,446,744,073,709,551,615 lamports), an impractical amount that could cause confusion or overflow issues in related logic.

Impact

  • Misleading Campaigns: A goal of 0 could deceive contributors into thinking a campaign is successful immediately, undermining trust.

  • Usability Issues: Unrealistic goals (e.g., excessively large values) might confuse users or lead to campaigns that can never be completed.

  • Potential Exploitation: While not directly exploitable for financial gain, invalid goals could be used to spam the platform or create dysfunctional campaigns.

  • Program Integrity: Lack of validation weakens the robustness of the crowdfunding system, potentially leading to edge cases in other functions (e.g., overflow risks if not mitigated elsewhere).

Tools Used

Manual review

Recommendations

Add input validation to the fund_create function to enforce reasonable constraints on the goal parameter:

  • Minimum Check: Prevent goal = 0 to ensure campaigns have a meaningful target.

  • Maximum Check: Cap the goal at a practical limit (e.g., 1 million SOL) to maintain realism and prevent edge cases.

Updates

Appeal created

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

No minimal amount for the `goal` in `fund_create` is greater than 0

If the `goal` is 0, the campaign goal is achieved immediately and the creator can withdraw the contributors funds. The contributors select themself which campaign to support, therefore I think Low severity is appropriate here.

Support

FAQs

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