RustFund

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

A deadline can be set multiple times

Summary

In the set_deadline function, the deadline can be set if fund.deadline_set is false. However, since fund.deadline_set is not updated to true after setting the deadline, the creator can modify it multiple times. If allowing multiple changes is intended, the condition check is unnecessary.

Vulnerability Details

In the set_deadline function, you are checking whether the deadline has already been set or not. If fund.deadline_set is false, then the deadline can be set. However, once the deadline has been set, you are not updating fund.deadline_set to true, which allows the creator to change or extend the deadline multiple times whenever they want. And if you want the creator to be able to change the deadline multiple times, then there is no need to check the condition.

pub fn set_deadline(ctx: Context<FundSetDeadline>, deadline: u64) -> Result<()> {
let fund = &mut ctx.accounts.fund;
if fund.dealine_set {
return Err(ErrorCode::DeadlineAlreadySet.into());
}
fund.deadline = deadline;
Ok(())
}

Impact

The current implementation allows the creator to extend the deadline as many times as they want. This means they can keep delaying the refund process indefinitely, which creates a serious risk for contributors. Since there is no restriction on how often the deadline can be changed, the creator could take advantage of this loophole to avoid refunding money, potentially scamming contributors.

Tools Used

Solana Explorer
Vs Code

Recommendations

Set fund.deadline_set to true Immediately after the deadline is set. This way, once the creator sets the deadline, fund.deadline_set will be true, preventing any further changes to the deadline. This ensures that the creator cannot extend the deadline, effectively preventing potential scams and protecting contributors.

pub fn set_deadline(ctx: Context<FundSetDeadline>, deadline: u64) -> Result<()> {
let fund = &mut ctx.accounts.fund;
if fund.dealine_set {
return Err(ErrorCode::DeadlineAlreadySet.into());
}
fund.deadline = deadline;
fund.dealine_set = true;
Ok(())
}
Updates

Appeal created

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

Deadline set flag is not updated in `set_deadline` function

Support

FAQs

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