In a crowdfunding campaign, the amount_raised field is intended to keep a cumulative total of all contributions. It is critical that this value remains accurate to correctly determine whether the fundraising goal has been met and to enable other accounting logic. The safe way to update a u64 counter is to use checked arithmetic that prevents overflow.
The contribute instruction, however, updates fund.amount_raised using a plain addition without any overflow protection. If amount_raised ever reaches the maximum value u64::MAX and a subsequent contribution would push it beyond this limit, the addition will wrap around to a small number. This corrupts the recorded total and breaks any logic that relies on it.
Likelihood:
Low to Medium – For overflow to occur naturally, the total contributions would need to exceed ~1.84 × 10¹⁹ lamports (approximately 18.4 SOL if we consider 1e9 lamports per SOL). While this is a very large number, it is theoretically possible if the campaign accepts a high volume of micro‑donations or if the token has a low decimal count. An attacker could also deliberately aim to cause overflow by making extremely large contributions just before the limit is reached, though this is constrained by the contributor’s own balance and the campaign’s max contribution limits (if any).
Impact:
High – Once overflow occurs, the recorded amount_raised becomes a small, incorrect number. This leads to:
The contract erroneously reporting that the goal has not been met, even though it actually has, potentially blocking the creator from claiming funds.
Contributors being able to refund even after the goal is reached, because the contract believes the goal is still unmet.
General accounting chaos that undermines trust in the platform.
Assume a campaign where the goal is set to u64::MAX (for illustration). Currently, the amount_raised is u64::MAX - 500.
A user contributes 1000 lamports.
The calculation amount_raised += amount results in:
(u64::MAX - 500) + 1000 = u64::MAX + 500, which wraps to 499 (since u64 wraps modulo 2^64).
After the transaction, amount_raised is 499, while the actual funds held in the fund account have increased by 1000.
Now any logic checking amount_raised >= goal will be severely broken; the goal may be considered unmet, and refunds may be incorrectly allowed.
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.