RustFund

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

Creator can withdraw funds if goal is not met

Summary

The creator is able to withdraw funds despite the goal not been met within the specified deadline

Vulnerability Details

This allows the creator to withdraw funds after the deadline has reached and the goals were not met and subsequently allows the creator to frontrun contributors from asking for a refund

Impact

Contributors are unable to get refunds after the deadline has reached

POC

Add this line in rustfund.ts#L95 before the refund

try{
await program.methods
.withdraw()
.accounts({
fund: fundPDA,
creator: creator.publicKey,
systemProgram: anchor.web3.SystemProgram.programId,
})
.rpc();
console.log("Successful Withdrawal when goal is not met"); // Transaction reaches here hence successful
}catch(e){
console.log(e);
}

Tools Used

Manual

Recommendations

Ensure the withdraw can only be called after the goal has been met
Add this check in withdraw

require!(ctx.accounts.fund.amount_raised >= ctx.accounts.fund.goal, ErrorCode::InsufficientFunds);
Updates

Appeal created

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

No goal achievement check in `withdraw` function

Support

FAQs

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