The withdraw
function in the rustfund
program allows the fund creator to withdraw funds at any time without checking if the fundraising deadline has been reached. This behavior may be unintended and could lead to premature withdrawal before contributors expect funds to be locked or the goal to be met.
The withdraw
function does not verify whether the fundraising deadline has passed before allowing the fund creator to withdraw funds. In the current implementation:
There is no condition ensuring that the deadline
has been reached before allowing withdrawals. As a result, the fund creator can withdraw the funds at any time, even before contributors expect the fundraising process to be completed.
The fund creator can withdraw the funds before the deadline, potentially breaking trust with contributors.
If the purpose of the contract is to enforce a crowdfunding model where funds should only be accessed after a campaign deadline, this vulnerability defeats that purpose.
Contributors may expect funds to be locked until the deadline, but they can be withdrawn at any time, which could lead to potential misuse.
Manual code review
To mitigate this issue, modify the withdraw
function to include a deadline check:
By adding this verification, the contract ensures that withdrawals can only occur after the deadline has passed, preventing premature fund access by the creator.
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.