refund()
function allows contributors to execute multiple refund transactions in parallel before the state updates, resulting in double or multiple withdrawals of the same funds.Manual Review
Anchor Testing Framework
User A contributes 5 SOL to a crowdfunding campaign.
User A rapidly submits multiple refund()
transactions in parallel before the contract state updates.
Since state updates happen after the fund transfer, multiple refund transactions pass, allowing the contributor to withdraw more than their original contribution.
Result:
Expected refund: 5 SOL
Actual refund due to race condition: 15 SOL (3x 5 SOL in parallel transactions)
The contract fund is drained unexpectedly.
Code issue in refund()
:
Recommendation:
Perform state Update before transferring SOL to prevent multiple refund transaction scenarios.
Like here:
The reentrancy risk on Solana is highly eliminated. The `try_borrow_mut_lamports` ensures that only one reference to an account exists at a time. Also, once the fund’s lamports are borrowed mutably, no other transaction can modify them until the borrow is released. This means the function will reset the `amount` before the next call.
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.