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.
In the fund_create
function:
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.
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).
Manual review
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.
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.
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.