In the contribute
function of the Rustfund smart contract, the contribution.amount
variable is never updated with the actual contribution amount. While funds are successfully transferred from the contributor to the fund account, the individual contribution record is not properly tracked. This means that a contributor's personal contribution history is not accurately maintained, resulting in a loss of traceability and potentially resulting in fund loss during refund operations.
Contributors cannot receive proper refunds based on their actual contribution amount
The contract maintains incorrect accounting records of individual contributions
When a refund is requested, a contributor will only be able to withdraw what's stored in their contribution record (which remains at 0)
The vulnerability is demonstrated in the provided test case:
Save the above test as, for example, tests/01.ts in your project's test directory and run the test :
The test verifies that:
The fund's amountRaised is correctly updated to 0.5 SOL
However, the contributor's recorded amount in the contribution account remains at 0
This confirms that while the SOL transfer occurs properly, the individual contribution record is not updated.
To illustrate the real-world impact of this vulnerability, consider this scenario:
A startup launches a campaign with a 1000 SOL goal
The deadline is reached and 4 contributors have sent 200 SOL each to the contract
Contributors ask for a refund, but their contribution amount is still 0, so they are unable to retrieve their funds
Add a line to update the contribution amount after the transfer:
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.