RustFund

First Flight #36
Beginner FriendlyRust
100 EXP
View results
Submission Details
Severity: medium
Valid

`fund.amount` is not updated after `refund`

Summary

The refund function fails to update the total fund's amount_raised when processing individual contributor refunds, leading to incorrect accounting. This can cause an issue when withdrawing the funds,

// @audit amount is not subtracted from amount_raised
ctx.accounts.contribution.amount = 0;

Vulnerability Details

When a contributor receives a refund, the amount_raised remains unchanged. This creates a critical discrepancy that could allow withdrawing more funds than actually available.

Impact

The contract may overstate total funds raised and prevent accurate tracking of remaining fund balance.

Tools Used

Manual

Recommendations

Explicitly subtract the refunded amount from the total amount_raised to maintain accurate fund tracking.

+ ctx.accounts.fund.amount_raised -= amount;
ctx.accounts.contribution.amount = 0;
Updates

Appeal created

bube Lead Judge 6 months ago
Submission Judgement Published
Validated
Assigned finding tags:

`amount_raised` not updated in `refund` function

Support

FAQs

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