RustFund

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

Contribution amount not updated in `contribute` function

Summary

The contribute function transfers SOL but doesn't update the contribution amount.

Vulnerability Details

pub fn contribute(ctx: Context<FundContribute>, amount: u64) -> Result<()> {
// Transfer SOL from contributor to fund account
let cpi_context = CpiContext::new(
ctx.accounts.system_program.to_account_info(),
system_program::Transfer {
from: ctx.accounts.contributor.to_account_info(),
to: fund.to_account_info(),
},
);
system_program::transfer(cpi_context, amount)?;
fund.amount_raised += amount;
//@audit Missing: contribution.amount += amount;
Ok(())
}

Impact

  1. Loss of contribution tracking

  2. The contribution.amountremains at 0.

Tools Used

Recommendations

fund.amount_raised += amount;
contribution.amount += amount;
Ok(())
Updates

Appeal created

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

Contribution amount is not updated

Support

FAQs

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