RustFund

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

Lamport Transfer Uses Direct Borrowing Instead of CPI Transfer

Summary

The function directly modifies lamports using:

**ctx.accounts.fund.to_account_info().try_borrow_mut_lamports()? = ...

While this works, CPI transfers are preferred for security and maintainability.

Impact

If there are other constraints or checks (e.g., rent exemption), directly modifying lamports can cause unintended behavior.

Recommendations

Use the invoke method to perform the SOL transfer securely:

invoke(
&system_instruction::transfer(
ctx.accounts.fund.to_account_info().key,
ctx.accounts.contributor.to_account_info().key,
amount,
),
&[
ctx.accounts.fund.to_account_info(),
ctx.accounts.contributor.to_account_info(),
ctx.accounts.system_program.to_account_info(),
],
)?;
Updates

Appeal created

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

Unsafe direct lamport manipulation

Support

FAQs

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