RustFund

First Flight #36
Beginner FriendlyRust
100 EXP
View results
Submission Details
Severity: high
Invalid

Unchecked External Call Results

Summary

The contract performs external calls with invoke but does not inspect the return value to see if the call was successful. If the external call fails, the contract will continue to execute, perhaps leading to inconsistencies.

Vulnerability Details

Failure to handle unsuccessful external calls may result in discrepancies in the contract's state.

Impact

  1. Failed transactions may not revert, leading to incorrect state updates.

  2. Attackers could manipulate failure scenarios to exploit the contract.

Tools Used

invoke(
&system_instruction::transfer(
&ctx.accounts.user.key,
&campaign.key(),
amount,
),
&[
ctx.accounts.user.to_account_info(),
campaign.to_account_info(),
ctx.accounts.system_program.to_account_info(),
],
)?;

Recommendations

  1. Check the result of invoke and handle errors properly.

  2. Abort execution if the call fails to prevent state inconsistencies.

    This assures that failed external calls do not jeopardize the contract's integrity, preventing unexpected behavior.

    let transfer_result = invoke(
    &system_instruction::transfer(
    &ctx.accounts.user.key,
    &campaign.key(),
    amount,
    ),
    &[
    ctx.accounts.user.to_account_info(),
    campaign.to_account_info(),
    ctx.accounts.system_program.to_account_info(),
    ],
    );
    if transfer_result.is_err() {
    return Err(ProgramError::Custom(1)); // Custom error for failed transfer
    }
Updates

Appeal created

bube Lead Judge 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.