RustFund

First Flight #36
Beginner FriendlyRust
100 EXP
View results
Submission Details
Severity: high
Invalid

Reentrancy attack in refund()

Summary

Refund() is susceptible to a reentrancy attack.

Vulnerability Details

The contribution amount only gets updated after the transfer of funds. This means that if a user calls the refund() function repeatedly, they can transfer all the funds to themselves before the state of the account is updated.

Impact

A malicious user can exploit this vulnerability to drain all the funds from a fund.

Tools Used

Recommendations

Follow the CEI "Checks-Effects-Interactions" pattern by setting ctx.accounts.contribution.amount = 0 before the transfer of funds.

Updates

Appeal created

bube Lead Judge 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

[Invalid] Reentrancy in refund

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.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.