Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LZ_security - Due to missing checks on minimum gas and fee passed through LayerZero, executions can fail on the destination chain #151

Open
sherlock-admin2 opened this issue Oct 27, 2024 · 0 comments
Labels
Sponsor Disputed The sponsor disputed this issue's validity

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Oct 27, 2024

LZ_security

Medium

Due to missing checks on minimum gas and fee passed through LayerZero, executions can fail on the destination chain

Summary

Due to missing checks on the minimum gas and fee passed through LayerZero, executions can fail on the destination chain. An attacker can exploit this vulnerability to attack the system.

Root Cause

In LayerZero, the destination chain’s function call requires a specific gas amount; otherwise, it will revert with an out-of-gas exception. It falls under the responsibility of the oApp to ensure that appropriate limits are established.

The logic of the Deposit() operation assumes that the user will first call oapp_quote() to obtain an estimated native_fee price, and then pass this parameter into the Deposit() function.

https://github.com/sherlock-audit/2024-09-orderly-network-solana-contract/blob/main/solana-vault/packages/solana/contracts/programs/solana-vault/src/instructions/vault_instr/deposit.rs#L141

pub fn apply(
        ctx: &mut Context<'_, '_, '_, 'info, Deposit<'info>>,
        deposit_params: &DepositParams,
        oapp_params: &OAppSendParams,
    ) -> Result<MessagingReceipt> {
       //-----skip

@>>        let options = EnforcedOptions::get_enforced_options(&ctx.accounts.enforced_options, &None);

        let endpoint_send_params = EndpointSendParams {
            dst_eid: ctx.accounts.vault_authority.dst_eid,
            receiver: ctx.accounts.peer.address,
            message: lz_message,
            options: options,
@>>            native_fee: oapp_params.native_fee,
            lz_token_fee: oapp_params.lz_token_fee,
        };

        let receipt = oapp::endpoint_cpi::send(
            ctx.accounts.oapp_config.endpoint_program,
            ctx.accounts.oapp_config.key(),
            ctx.remaining_accounts,
            seeds,
            endpoint_send_params,
        )?;

        emit!(OAppSent {
            guid: receipt.guid,
            dst_eid: ctx.accounts.vault_authority.dst_eid,
        });

        Ok(receipt)
    }
}

From the code, it can be seen that the function does not check the gas limit and gas fee. As a result, an attacker can exploit this by deliberately passing in a very small gas limit and gas fee, causing the message to fail execution on the EVM side due to “out of gas.”

The attacker can also pass in a very small or even zero token_amount, making the attack nearly cost-free.

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

The attacker can exploit execution failures on the EVM side to block the system, causing a Denial of Service (DoS) attack.

PoC

No response

Mitigation

In the Deposit function, execute oapp_quote() internally, and use the obtained parameters for the cpi::send() call.

@sherlock-admin3 sherlock-admin3 added the Sponsor Disputed The sponsor disputed this issue's validity label Nov 3, 2024
@sherlock-admin4 sherlock-admin4 changed the title Fit Canvas Pangolin - Due to missing checks on minimum gas and fee passed through LayerZero, executions can fail on the destination chain LZ_security - Due to missing checks on minimum gas and fee passed through LayerZero, executions can fail on the destination chain Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sponsor Disputed The sponsor disputed this issue's validity
Projects
None yet
Development

No branches or pull requests

2 participants