The set_deadline()
function in the rustfund
program contains a vulnerability that allows campaign creators to manipulate deadlines indefinitely. While the function correctly checks if fund.dealine_set
is true before allowing the deadline to be changed, it never sets this flag to true after setting the deadline.
The function is missing a crucial line to update the flag: fund.dealine_set = true;
This oversight bypasses a key safeguard intended to prevent creators from manipulating deadlines after they've been set. According to the project documentation, this flag is meant to enforce deadline immutability, which is an essential part of the platform's trust model.
Refund evasion: Creators can prevent users from obtaining refunds by continually extending the deadline whenever it approaches. This directly undermines the project's advertised "Refund Mechanism" which promises that "Contributors can get refunds if deadlines are reached and goals aren't met."
Fund locking: Contributors' funds can be effectively locked indefinitely, as the refund function is contingent upon the deadline being reached:
The following test demonstrates how a creator can set the deadline multiple times, effectively bypassing the intended deadline immutability:
Save the above test as, for example, tests/02.ts in your project's test directory and run the test :
To illustrate the real-world impact of this vulnerability, consider this scenario:
A creator launches a campaign to fund a project with a goal of 100 SOL
The creator sets an initial deadline of 30 days
Contributors collectively deposit 80 SOL (below the goal)
As the deadline approaches, the creator realizes they won't reach the goal
Instead of allowing refunds as promised, the creator extends the deadline by another 30 days
This pattern can repeat indefinitely, effectively locking contributor funds
Even if contributors try to request refunds, they'll be rejected with "DeadlineNotReached" errors
The fix for this vulnerability is straightforward. The set_deadline()
function should be modified to set the dealine_set
flag to true after setting the deadline:
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.