RustFund

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

Fund Amount Raised Not Updated After Refund in RustFund Contract

Summary

The refund function does not decrease fund.amount_raised after refunding, leading to an inflated value that misrepresents available funds.

Vulnerability Details

The vulnerable code is in the refund function:

rust

pub fn refund(ctx: Context<FundRefund>) -> Result<()> {
// Refund logic...
ctx.accounts.contribution.amount = 0;
Ok(())
}
  • No Update: fund.amount_raised remains unchanged after transferring funds back.

  • Accounting Error: Subsequent withdrawals use the outdated amount_raised.

Impact

  • Funds Misallocation: Creators can withdraw more than the actual remaining funds.

  • Integrity Violation: Breaks financial transparency.

Tools Used

Manual Review

Recommendations

Update amount_raised:

rust

pub fn refund(ctx: Context<FundRefund>) -> Result<()> {
let fund = &mut ctx.accounts.fund;
let amount = ctx.accounts.contribution.amount;
// Deadline check...
// Refund logic...
fund.amount_raised = fund.amount_raised.checked_sub(amount).ok_or(ErrorCode::CalculationOverflow)?;
ctx.accounts.contribution.amount = 0;
Ok(())
}
Updates

Appeal created

bube Lead Judge 2 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.