After a successful withdrawal by the campaign creator, the amount_raised
field in the fund account is not reset or updated. This oversight leads to an inconsistent state, potentially causing misrepresentation of the campaign’s funds and creating opportunities for logical errors or unintended behavior in subsequent transactions.
Flaw Description:
Upon a withdrawal operation, the contract transfers the funds from the campaign account to the creator’s account. However, the amount_raised
field, which tracks the total contributions received, remains unchanged after the withdrawal. This means that the internal state of the fund still reflects the original raised amount, even though the actual funds have been moved.
Code Analysis:
The withdraw
function currently performs the fund transfer as follows:
The function deducts the funds from the campaign account and credits the creator’s account, but does not update the amount_raised
field. As a result, the contract state continues to indicate that the campaign has raised funds even after they have been withdrawn.
Operational Risks:
The state inconsistency may lead to operational issues, such as repeated or erroneous calls to the withdrawal function, affecting the overall reliability of the contract.
User Trust:
Contributors and campaign creators rely on accurate state representation to make informed decisions. An incorrect amount_raised
can erode trust in the platform’s transparency and reliability.
Downstream Effects:
Future contract logic or integrations (e.g., automated refund processes, success criteria evaluations) that depend on amount_raised
could behave unpredictably, leading to further financial or reputational damage.
Manual Review
Reset or Update amount_raised
:
Modify the withdraw
function to reset amount_raised
to zero or adjust it appropriately to reflect the current funds in the campaign account after a withdrawal. For example:
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.