A vulnerability was discovered in the contribute function of the rustfund program. Specifically, there is no check to ensure that the total amount raised does not exceed the specified funding goal. This oversight can lead to potential overfunding, mismanagement of funds, and a discrepancy between the intended functionality and actual behavior of the contract.
Location: contribute function within the rustfund program.
Issue: The function does not validate if the new contribution (amount) added to the existing fund.amount_raised exceeds the target fund.goal.
Explanation: If the accumulated contributions surpass the defined funding goal, contributors may continue contributing, resulting in overfunding. The absence of a boundary check before updating fund.amount_raised leads to a overfunding.
Overfunding: Contributors may deposit funds even after reaching the funding goal, leading to unexpected surplus.
Financial Mismanagement: Funds raised beyond the goal may not be tracked or handled appropriately.
Reputation Risk: The integrity of the fundraising platform can be questioned if overfunding occurs, potentially violating trust and expectations.
Potential Overflow: In extreme cases, if contributions continue after the goal is reached, an integer overflow could occur, though this is mitigated by Rust’s overflow checks.
Manual code review.
Analysis through the Anchor framework.
Knowledge of Solana’s system program for secure fund transfers.
Validation Check: Before adding the contribution, ensure that the resulting amount_raised does not exceed the goal. Example fix:
Error Handling: Introduce a new error variant in ErrorCode to handle the overfunding case:
Testing: Implement tests to validate that:
Contributions are rejected once the funding goal is met.
The amount_raised never exceeds the goal.
Documentation: Clearly specify the behavior of the contribute function in the program’s documentation to set accurate expectations.
Typically the crowdfunding campaigns allow contribution after the goal is achieved. This is normal, because the goal is the campaign to raise as much as possible funds. Therefore, this is a design choice.
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.