The refund
function in the provided code directly manipulates the lamports of accounts using try_borrow_mut_lamports()
. This approach bypasses the Solana runtime's safety checks, leading to potential security vulnerabilities and program instability.
In the refund
function, lamports are transferred between accounts by directly adjusting their balances:
This method of direct lamport manipulation can lead to several issues:
Bypassing Rent Exemption Checks: Accounts in Solana must maintain a minimum balance to be rent-exempt. Directly reducing an account's lamports without verifying rent exemption can result in the account being marked for deletion by the Solana runtime.
Ownership Constraints: Only the owning program of an account can modify its data and lamport balance. Direct manipulation without proper checks can violate these constraints, leading to program errors.
Lack of Atomicity: Direct lamport transfers lack the atomic transaction guarantees provided by the system program's transfer instruction, potentially leading to inconsistent states in case of program interruptions.
Exploiting this vulnerability can result in unauthorized fund transfers, violation of Solana's account ownership rules, and potential loss of funds due to accounts becoming non-rent-exempt.
Code analysis and Solana's official documentation.
Replace the direct lamport manipulation with Solana's system program transfer instruction to ensure safe and compliant fund transfers in refund() & withdraw() functions:
This approach leverages Solana's native mechanisms for transferring lamports, ensuring adherence to the platform's safety and security protocols.
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.