The contribute
function does not check if the contribution amount
is greater than zero. This allows users to create "empty" contribution records, wasting storage and potentially causing issues with calculations or logic that relies on contribution amounts.
The contribute
function in programs/rustfund/src/lib.rs
lacks a check to ensure that the amount
parameter is greater than 0. This means a transaction can be successfully processed even if no SOL is actually transferred. The function initializes a Contribution
account even if amount
is 0.
High: Wastes storage space on the blockchain by creating unnecessary Contribution
accounts.
Could lead to unexpected behavior in functions that iterate through or calculate based on contribution records, as they might encounter zero-amount contributions.
It won't directly steal funds, but it degrades the platform's efficiency and can create edge-case bugs.
Manual code review
Solana Explorer (to observe account creation)
Add a check at the beginning of the contribute
function to ensure that amount
is greater than zero. Return an error if it is not.
Add this to the error code:
If user contributes 0 SOL, the `contribution.amount` will be updated with 0 value. There is no impact on the protocol. Also, the new contributers should pay for account creation, therefore there is no incentive someone to create a very huge number of accounts to contribute zero amount.
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.