contribute
function, contribution.amount
is initialized to zero
for new contributors but is never updated to reflect the actual contributed amount. This causes the refund
mechanism to always refund
zero SOL, regardless of the actual contribution.A contributor calls contribute
with amount = 100 SOL.
The fund’s amount_raised increases by 100 SOL, but contribution.amount remains 0.
When the contributor calls refund, the refund amount is 0 SOL, not 100 SOL.
This effectively locks contributed funds in the contract, preventing legitimate refunds.
it("Demonstrates contribution.amount is never updated", async () => {
const bugFundName = "BugDemoFund";
const [bugFundPDA] = await PublicKey.findProgramAddress(
[Buffer.from(bugFundName), creator.publicKey.toBuffer()],
program.programId
);
await program.methods
.fundCreate(bugFundName, description, goal)
.accounts({
fund: bugFundPDA,
creator: creator.publicKey,
systemProgram: anchor.web3.SystemProgram.programId,
})
.rpc();
});
Update contribution.amount to accumulate the contributed amount.
contribution.amount = contribution.amount.checked_add(amount).ok_or(ErrorCode::CalculationOverflow)?;
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.