RustFund

First Flight #36
Beginner FriendlyRust
100 EXP
View results
Submission Details
Severity: medium
Invalid

No Minimum Contribution Check in RustFund Contract

Summary

The contribute function accepts amount = 0, which is impractical.

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

rust

pub fn contribute(ctx: Context<FundContribute>, amount: u64) -> Result<()> {
// No minimum check
}
  • No Validation: Zero contributions are processed.

Impact:

  • User Experience: Wastes resources on meaningless transactions.

Tools Used: Manual Review

Recommendations:
Add minimum:

rust

if amount == 0 {
return Err(ErrorCode::InvalidAmount.into());
}

Add new error code:

rust

#[error_code]
pub enum ErrorCode {
// ... existing errors ...
#[msg("Contribution amount must be greater than zero")]
InvalidAmount,
}

Updates

Appeal created

bube Lead Judge 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

[Invalid] Lack of minimal `amount` in `contribute` function

If user contributes 0 SOL, the `contribution.amount` will be updated with 0 value. There is no impact on the protocol. Also, the new contributers should pay for account creation, therefore there is no incentive someone to create a very huge number of accounts to contribute zero amount.

Support

FAQs

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