The README defines exactly one circumstance in which a refund is due: "Contributors can get refunds if deadlines are reached and goals aren't met", restated in the Actors section as "Can request refunds under if the campaign fails to meet the goal and the deadline is reached". Two conditions, both required.
refund implements a single condition and gets it backwards for the default case. Its guard rejects only when a deadline exists and lies in the future. Every fund is created with deadline = 0 and there is no way to create one with a deadline, so until the creator separately calls set_deadline the left conjunct is false, the guard short-circuits, and the refund is allowed — including in the same block as the contribution it is refunding.
The deadline == 0 state is not an edge case; it is the state every fund starts in and the only state a fund can be created in:
0 is being used as a sentinel for "no deadline configured", but the guard reads it as "the deadline has passed". Those are opposite meanings, and the second one is the permissive one.
The second half of the condition is missing outright. fund.goal is stored at line 16 and declared at line 186, and no instruction ever reads it, so refund has no way to distinguish a campaign that failed from one that succeeded. A contributor to a campaign that comfortably exceeded its target is as eligible as one whose campaign raised nothing.
Both halves live on the same line and are repaired by the same rewritten condition, which is why I am reporting them together rather than as two findings.
Likelihood:
The permissive window is not narrow. It runs from fund_create until the creator happens to call set_deadline, and lasts forever for any campaign where the creator never calls it — nothing in the program requires them to.
The window is also reopenable. set_deadline can write 0 back, and its one-shot guard is inoperative (dealine_set is never assigned true), so a creator can return the fund to the fully permissive state at any time.
No precondition, no race, no privileged position: any contributor calls one instruction.
The goal half fails on 100% of calls, unconditionally, since the field is never read anywhere in the program.
Impact:
The commitment a contributor makes to a campaign is not binding. Contributions are supposed to be locked until the campaign resolves; here they are withdrawable at the contributor's discretion for as long as the fund sits at deadline == 0.
A campaign's reported amount_raised becomes an unreliable signal, since any part of it may be reclaimed at will by the contributors who provided it. Other contributors deciding whether to join are reading a number that is not committed.
On the goal side, the intended asymmetry — creator collects on success, contributors reclaim on failure — collapses into both parties holding a claim on the same lamports at the same time, resolved by whoever transacts first.
Stated plainly, because the severity turns on it and a judge will find it anyway: no lamports move today. A separate defect means contribution.amount is only ever assigned the literal 0 (lines 37 and 85) and is never incremented, so refund executes checked_sub(0) / checked_add(0) and transfers nothing. The gate examined here is therefore a wrong gate in front of a payout that currently pays zero.
That is why I have set Impact to Low rather than Medium, and it is the honest reading of the code as written. Likelihood is High because the condition itself is wrong on every single call, unconditionally, without any precondition.
The reason it is still worth reporting at this tier rather than as informational: the one-line fix to the amount-recording defect is the obvious fix, and the moment it lands this gate is what stands between a live campaign and its contributors walking their money back out — including on a campaign that succeeded, where the creator's withdraw and the contributors' refund become two claims on the same lamports with no ordering guarantee. The defect should be repaired in the same change, not discovered afterwards.
Two scenarios: a refund accepted seconds after the contribution on a fund with no deadline, and a refund accepted on a campaign that raised double its goal.
Output:
Neither call should have been admitted: (a) is a running campaign at 10% of its target with no deadline yet announced, and (b) is a campaign that raised double its goal.
Rewrite the condition so that both of the README's requirements must hold, and treat 0 as "not configured" rather than as "expired".
The sentinel is the deeper problem: deadline: u64 cannot distinguish "unset" from "epoch zero". Modelling it as Option<u64>, or taking the deadline as a required parameter of fund_create, removes the ambiguous state entirely.
## Description the refund mechanism only verifies that the current time has passed the campaign deadline, without checking whether the campaign has failed to meet its funding goal.This oversight may result in refunds being issued even if the campaign was, in principle, successful, potentially undermining the trust and financial integrity of the platform.   ## Vulnerability Details The refund function in the contract is designed to return funds to contributors if a campaign fails. However, it only checks whether the campaign deadline has been reached (or passed) before allowing a refund, without verifying if the campaign's funding goal was met. In other words, the function solely relies on a time-based condition and does not incorporate the additional logic required to determine if a campaign has been unsuccessful. **Code Analysis:**\ The refund function contains the following check: ```Rust if ctx.accounts.fund.deadline != 0 && ctx.accounts.fund.deadline > Clock::get().unwrap().unix_timestamp.try_into().unwrap() { return Err(ErrorCode::DeadlineNotReached.into()); } ``` This condition ensures that refunds are only triggered after the deadline has passed. However, there is no subsequent verification that compares `fund.amount_raised` to the `fund.goal` to determine whether the campaign failed to meet its funding target. As a result, even if the campaign has met or exceeded its goal, contributors could potentially request refunds simply because the deadline has passed. ## proof Of Concept ```typescript it("Allows refund on a successful campaign due to missing goal check", async () => { // Define campaign parameters with a near-future deadline (5 seconds from now) const fundName = "refund flaw"; const description = "Test for refund vulnerability on a successful campaign"; const goal = new anchor.BN(1000000000); // 1 SOL goal // Set deadline to 5 seconds from now const deadline = new anchor.BN(Math.floor(Date.now() / 1000) + 5); // Generate PDA for the fund using the campaign name and creator's public key let [fundPDA, fundBump] = await PublicKey.findProgramAddress( [Buffer.from(fundName), creator.publicKey.toBuffer()], program.programId ); // Create the fund campaign await program.methods .fundCreate(fundName, description, goal) .accounts({ fund: fundPDA, creator: creator.publicKey, systemProgram: anchor.web3.SystemProgram.programId, }) .rpc(); // Set the campaign deadline await program.methods .setDeadline(deadline) .accounts({ fund: fundPDA, creator: creator.publicKey, }) .rpc(); // Airdrop lamports to otherUser so they can contribute const airdropSig = await provider.connection.requestAirdrop( otherUser.publicKey, 2 * anchor.web3.LAMPORTS_PER_SOL // e.g., 2 SOL ); await provider.connection.confirmTransaction(airdropSig); // Generate PDA for the contribution account using fund's PDA and otherUser's public key let [contributionPDA, contributionBump] = await PublicKey.findProgramAddress( [fundPDA.toBuffer(), otherUser.publicKey.toBuffer()], program.programId ); // otherUser contributes 1 SOL, meeting the campaign goal const contributionAmount = new anchor.BN(1000000000); // 1 SOL await program.methods .contribute(contributionAmount) .accounts({ fund: fundPDA, contributor: otherUser.publicKey, contribution: contributionPDA, systemProgram: anchor.web3.SystemProgram.programId, }) .signers([otherUser]) .rpc(); // Verify the campaign is successful by checking that amountRaised >= goal let fundBeforeDeadline = await program.account.fund.fetch(fundPDA); expect(fundBeforeDeadline.amountRaised.gte(goal)).to.be.true; // Wait until after the deadline has passed await new Promise((resolve) => setTimeout(resolve, 6000)); // otherUser calls refund despite the campaign being successful // (a correct implementation should disallow this refund) let refundTxSucceeded = true; try { await program.methods .refund() .accounts({ fund: fundPDA, contribution: contributionPDA, contributor: otherUser.publicKey, systemProgram: anchor.web3.SystemProgram.programId, }) .signers([otherUser]) .rpc(); } catch (err) { refundTxSucceeded = false; } // The vulnerability: refund call is erroneously allowed even though the campaign met its goal. expect(refundTxSucceeded).to.be.true; // check the contributor's balance change to further demonstrate the refund was processed. const balanceAfterRefund = await provider.connection.getBalance( otherUser.publicKey ); console.log("Contributor balance after refund:", balanceAfterRefund); }); ``` ## Impact - **Financial Discrepancies:**\ The improper refund mechanism result in successful campaigns losing funds that were meant to be retained by the campaign creator, leading to financial imbalances within the contract. - **Erosion of Trust:**\ Contributors and creators rely on the refund logic to be fair and accurate. The absence of a funding goal check in the refund function erode trust in the platform, as users could experience unexpected fund reversals or disputes over campaign success. - **Operational Risks:**\ Campaigns that meet their funding goals still be subject to refund requests, creating operational inefficiencies and potential disputes between creators and contributors. This undermines the intended crowdfunding model and could deter future participation.   ## Recommendations Update the refund function to include a check that verifies whether the campaign's funding goal has been met. Refunds should only be processed if both the deadline has passed and the `amount_raised` is below the `goal`.    ```Solidity if ctx.accounts.fund.deadline != 0 && ctx.accounts.fund.deadline > Clock::get().unwrap().unix_timestamp.try_into().unwrap() { return Err(ErrorCode::DeadlineNotReached.into()); } if ctx.accounts.fund.amount_raised >= ctx.accounts.fund.goal { return Err(ErrorCode::CampaignSuccessful.into()); } ```
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.