RustFund

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

Unsafe Lamport Manipulation Risks Account Corruption

Summary

Direct lamport adjustments in refund and withdraw bypass Anchor’s safety checks, risking rent exhaustion and account closure.

Vulnerability Details

Manually modifying lamports via try_borrow_mut_lamports() can inadvertently reduce an account’s balance below the rent-exempt threshold, causing Solana runtime to close the account and lose data.

https://github.com/CodeHawks-Contests/2025-03-rustfund/blob/b5dd7b0ec01471667ae3a02520701aae405ac857/programs/rustfund/src/lib.rs#L73

https://github.com/CodeHawks-Contests/2025-03-rustfund/blob/b5dd7b0ec01471667ae3a02520701aae405ac857/programs/rustfund/src/lib.rs#L78

https://github.com/CodeHawks-Contests/2025-03-rustfund/blob/b5dd7b0ec01471667ae3a02520701aae405ac857/programs/rustfund/src/lib.rs#L93-L101

Impact

Fund or contributor accounts may be closed unexpectedly, leading to permanent data loss and failed transactions.

Tools Used

Recommendations

Use CPI to the system program for secure transfers:

system_program::transfer(
CpiContext::new(
ctx.accounts.system_program.to_account_info(),
system_program::Transfer {
from: fund.to_account_info(),
to: creator.to_account_info(),
},
),
amount,
)?;
Updates

Appeal created

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