sherlock-audit / 2024-09-orderly-network-solana-contract-judging

0 stars 0 forks source link

Abundant Walnut Rooster - Ignored CPI Result in SetDelegate Function Prevents Error Propagation #176

Closed sherlock-admin2 closed 4 days ago

sherlock-admin2 commented 4 days ago

Abundant Walnut Rooster

Low/Info

Ignored CPI Result in SetDelegate Function Prevents Error Propagation

Summary

The ignored CPI result will cause unexpected behavior for developers as the function will silently discard errors, leading to undetected failures in downstream calls.

Root Cause

In set_delegate.rs:23, the CPI call to endpoint_cpi::set_delegate returns a Result, which is not propagated due to assignment to _. This allows any potential error in set_delegate to be ignored, leading to incomplete error handling. https://github.com/sherlock-audit/2024-09-orderly-network-solana-contract/blob/main/solana-vault/packages/solana/contracts/programs/solana-vault/src/instructions/oapp_instr/set_delegate.rs#L23-L31

Internal pre-conditions

  1. endpoint_cpi::set_delegate returns an error result for some input.
  2. The caller function does not receive this error due to the ignored result.

External pre-conditions

No specific external protocol changes are required for the issue to occur.

Attack Path

  1. admin calls SetDelegate::apply expecting correct error propagation.
  2. Result: If endpoint_cpi::set_delegate fails, this failure is not handled or propagated, potentially leaving the admin unaware of the error.

Impact

No response

PoC

No response

Mitigation

Remove the assignment to _ , apply the? operator directly to the endpoint_cpi::set_delegate call and remove the return Ok(()). This change will ensure error propagation up the call stack