The contribute
function allows users to contribute to a fund as long as the deadline has not passed. However, it lacks a check to prevent contributions after the fund’s goal is reached. This leads to funds being locked, as the creator can only withdraw the amount_raised
at the time of withdrawal, leaving any subsequent contributions inaccessible.
Users can contribute to a fund using the contribute
function, which only checks if the fund.deadline
has not passed. There is no validation to stop contributions once the fund’s goal
is met. After the goal is reached, the fund creator can withdraw the total amount_raised
at that point.
However, if additional contributions are made afterward, the amount_raised
increases, but the creator cannot withdraw these new funds because the withdrawal logic only transfers the fixed amount_raised
value from the initial withdrawal. This results in the excess funds being permanently locked in the contract.
Additionally, if a large amount of assets is contributed
just before the goal is reached, the total funds raised may exceed the goal. However, since this value is correctly added to ctx.accounts.fund.amount_raised
and the fund creator can withdraw it without any issues, this does not pose a problem.
If users contribute to a fund after its goal is reached, those additional funds become locked in the contract. Neither the creator nor the contributors can access them, leading to a permanent loss of assets. This could result in significant financial loss, especially in high-value campaigns, and erode trust in the system.
Manual Code Review and Foundry
Add a check in the contribute
function to prevent contributions once the goal is reached. This can be done by comparing amount_raised
against goal
and rejecting the transaction if the goal is met or exceeded.
Alternatively, if the fund owner wants to continue receiving contributions even after reaching the goal
, the contribute
function can check whether the owner has already withdrawn funds. If the withdrawal has not yet occurred, contributions can still be accepted.
Typically the crowdfunding campaigns allow contribution after the goal is achieved. This is normal, because the goal is the campaign to raise as much as possible funds. Therefore, this is a design choice.
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.