Rust Fund

AI First Flight #9
Beginner FriendlyRust
EXP
View results
Submission Details
Severity: low
Valid

Finished contribution accounts retain contributor rent

Description

  • A contributor pays rent to create a Contribution PDA and should recover that rent when their claim ends.

  • refund clears the amount but leaves the account open. No instruction closes the PDA or sends its rent to the contributor.

#[account(init_if_needed, payer = contributor, ...)]
pub contribution: Account<'info, Contribution>,
// ...
@> ctx.accounts.contribution.amount = 0;
@> // no close = contributor constraint exists

Risk

Likelihood:

  • A contributor creates a contribution account.

  • The contributor's claim ends through refund.

Impact:

  • The contributor cannot recover the account rent.

  • Each completed contribution leaves rent locked in program-owned storage.

Proof of Concept

The PoC creates a contribution account with a 500-lamport rent reserve, completes a refund, and
then checks the account state. The account remains open and still holds its rent because no close
constraint or close instruction runs after the claim becomes zero.

vulnerable_refund(&mut fund, &mut contribution, deadline);
assert!(contribution.open);
assert_eq!(contribution.rent, 500);

Recommended Mitigation

Close a zero-balance contribution account to its contributor when its refund completes, or add a
separate close instruction after campaign settlement. Either path returns the account lamports to
the payer and prevents unused contribution PDAs from accumulating.

#[account(
mut,
+ close = contributor,
seeds = [fund.key().as_ref(), contributor.key().as_ref()],
)]
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 3 hours ago
Submission Judgement Published
Validated
Assigned finding tags:

[L-04] Unclaimed rent from fund and contribution accounts leads to permanent SOL lockup

## Description neither the `withdraw()` nor `refund()` functions properly close their respective accounts after the funds have been transferred. This results in the rent amount (the SOL required to keep the account allocated on the Solana blockchain) remaining locked in these accounts indefinitely. ## Vulnerability Details In Solana, accounts must maintain a minimum balance to remain "rent-exempt", ensuring they aren't purged from the blockchain. When accounts are no longer needed, best practice is to close them and return this rent to the appropriate party (typically the account creator). The RustFund protocol currently lacks this account cleanup mechanism. - The withdrawal process in `withdraw()` transfers the raised funds from the fund account to the creator - Similarly, the refund process in `refund()` transfers the contribution amount back to the contributor and resets the contribution amount In both functions, the account data is updated, but the accounts themselves remain open, with their rent amount locked. After all funds have been withdrawn or refunded, these accounts serve no further purpose but continue to consume blockchain resources and lock up SOL. ### Proof of Concept 1. Alice creates a fund with a goal of 100 SOL, which requires 0.1 SOL as rent for the fund account. 2. The fund successfully raises 100 SOL from various contributors, each of whom also paid rent for their contribution accounts (approximately 0.05 SOL each). 3. Alice calls `withdraw()` to claim the 100 SOL raised funds, but the fund account itself is not closed. 4. The 0.1 SOL rent for the fund account remains locked in the account indefinitely. 5. Similarly, when contributors request refunds through the `refund()` function, their contribution accounts are updated but not closed. 6. The rent for all contribution accounts (e.g., 10 contributors × 0.05 SOL = 0.5 SOL) remains locked indefinitely. 7. Over time, as more funds are created and more contributions are made, the amount of permanently locked SOL grows. ## Impact - Economic Inefficiency, - Blockchain bloat, - Reduced user returns ## Recommendations Implement proper account closure in both the `withdraw()` and `refund()` functions.

Support

FAQs

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

Give us feedback!