RustFund

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

Potential integer overflow in the contribution function.

Summary

If the current amount_raised is close to max(u64) and the contribution amount makes this number over u64, it will overflow.

Vulnerability Details

This function https://github.com/CodeHawks-Contests/2025-03-rustfund/blob/main/programs/rustfund/src/lib.rs#L50 does not check for overflow. Moreover, the max goal is limited by max(u64)

Impact

Prevent campaigns from having a goal over max(u64) and prevents the amount_raised to be over max(u64)

Tools Used

Manual review

Recommendations

  • Use a bigger type for goaland/or amount_raised

  • Check for overflow and return correct error in case of overflow (ErrorCode::CalculationOverflow)

Updates

Appeal created

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

[Invalid] Arithmetic overflow in `contribute` function

The max value of u64 is: 18,446,744,073,709,551,615 or around 18.4 billion SOL, given that the total supply of SOL on Solana is 512.50M, the scenario when the `contribute` function will revert due to overflow is very very unlikely to happen. Therefore, this is informational finding.

Support

FAQs

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