This report highlights two vulnerabilities in the contract:
Direct SOL Transfers Not Tracked – The contract tracks contributions using amount_raised
, but users can send SOL directly to the fund’s address, bypassing the tracking mechanism. This creates accounting discrepancies and allows withdrawals to exceed intended limits.
Multiple Withdrawals Possible – The withdraw
The function does not update the campaign’s state after a successful withdrawal, allowing creators to drain funds multiple times.
These issues lead to uncontrolled fund withdrawals, incorrect refunds, and financial inconsistencies, violating the protocol’s guarantees of security and transparency.
Vulnerability Details
amount_raised
only tracks contributions made via the contribute
function.
Users can send SOL directly to the fund account, inflating its actual balance (lamports()
) without updating amount_raised
.
This leads to:
Withdrawals exceeding tracked contributions.
Refund shortfalls if lamports()
is lower than expected.
Campaign raises 100 SOL
via contribute
, setting amount_raised = 100
.
A donor sends 20 SOL directly to the campaign account (now lamports() = 120
).
The creator calls withdraw()
, receiving 100 SOL
, leaving 20 SOL
unaccounted for.
The extra 20 SOL remains accessible but untracked, violating transparency guarantees.
The withdraw
the function does not reset amount_raised
after a withdrawal.
No mechanism (e.g., a closed
flag) exists to prevent repeated withdrawals.
The creator can call withdraw
multiple times, draining the contract.
The campaign successfully raises 100 SOL
(amount_raised = 100
).
The creator calls withdraw()
, receiving 100 SOL
.
Since amount_raised
is not reset, the creator calls withdraw()
again.
Result: The creator withdraws another 100 SOL, exceeding the actual campaign balance.
Recommendations & Fixes
lamports()
for WithdrawalsEnsure that withdrawals do not exceed the actual fund balance.
Updated Code:
Introduce a closed
flag to prevent multiple withdrawals.
Updated Struct:
Updated Function:
3. Block Direct Transfers to Fund Accounts
Prevent direct SOL transfers by using Program-Derived Addresses (PDAs).
Updated Account Definition:
4. Implement Explicit Error Codes
Define an error for multiple withdrawals.
Conclusion
These vulnerabilities compromise the protocol’s financial integrity and trust model. By tracking all SOL movements and implementing proper withdrawal restrictions, we can restore alignment with the protocol’s security guarantees.
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.