RustFund

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

Missing Contribution Amount Update Breaks Refund Functionality

Summary

The contribute function in the rustfund program suffers from a critical accounting flaw where user contribution amounts are not properly tracked. The individual contribution is never incremented in the Contribution Account, resulting in broken refund functionality and potential fund loss.

Vulnerability Details

In the contribute function , a user can send SOL to the fund by calling this function with an amount parameter. The function correctly:

  • Checks if the deadline has been reached

  • Initializes a new contribution record if needed

  • Transfers SOL from the contributor to the fund via system program

  • Updates the total fund.amount_raised value

However, critically, it fails to update the individual contribution record. i.e user contribution amounts are not properly tracked. The individual contribution is never incremented in the Contribution Account

Impact

  1. Contributors cannot receive proper refunds since their contribution amounts are never recorded. The refund function will always return 0 SOL (which is the initialization value).

  2. All contributed funds become effectively locked or only withdrawable by the fund creator, violating the refund guarantees of the crowdfunding mechanism.

  3. The total amount_raised will not match the sum of individual contributions, creating an inconsistent financial state.

Tools Used

Manual Review

Recommendations

Update Contribution Records: Modify the contribute function to properly update individual contribution records:

+ contribution.amount += amount;
Updates

Appeal created

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

Contribution amount is not updated

Support

FAQs

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