Integer Overflow in contribute function
The code snippet shows that the amount
is added to fund.amount_raised
directly without checking for overflow. In Rust, when using non-checked arithmetic operations like +=
, if the sum exceeds the maximum value of the integer type, it will silently wrap around in release mode, causing incorrect fund tracking.
if a large enough amount is sent it would potentially overflow the fund.amount_raised.
Manual Review
Use checked arithmetic to prevent overflow. Replace the vulnerable line with:
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.
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.