The contribute
function updates the fund state after transferring funds, which opens the possibility for a reentrancy attack if Solana adds custom programs that allow indirect reentrancy.
The function first executes the SOL transfer:
Then, it updates the total raised amount:
If a malicious program is attached to the recipient account, it could execute another function call before fund.amount_raised is updated, leading to inconsistencies.
Fund total raised could be manipulated before finalizing contributions.
If Solana allows future program hooks, this can be exploited.
Defensive coding practice suggests always updating state before external calls.
Manual Code Review
Final Comprehensive Secured Version of contribute
Function:
The reentrancy attacks occur when the contract modifies state and makes an external call, allowing the attacker to reenter. The `contribute` function doesn't perform an external call. For the SOL transfer the function uses a system program, not an external call to another smart contract. Therefore, there is no attack vector for reentrancy.
The reentrancy attacks occur when the contract modifies state and makes an external call, allowing the attacker to reenter. The `contribute` function doesn't perform an external call. For the SOL transfer the function uses a system program, not an external call to another smart contract. Therefore, there is no attack vector for reentrancy.
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.