MorpheusAI

MorpheusAI
Foundry
22,500 USDC
View results
Submission Details
Severity: low
Valid

Use custom gas in `sendMintMessage` instead of default gas

Summary:

A potential issue related to the handling of gas limits in the sendMintMessage function of the L1Sender.sol contract was found. Currently it utilizes a default gas limit of 200,000, potentially leading to suboptimal gas usage. To address this issue, it is recommended to implement the use of adapterParams to allow users to set a custom gas limit, providing more flexibility and cost optimization.

Vulnerability Details:

The vulnerability lies in the sendMintMessage function of the L1Sender.sol, where a default gas limit of 200,000 will be used by default. This fixed gas limit may not be optimal for all transactions, potentially leading to either overpayment for unused gas or insufficient gas for complex transactions. By not allowing users to customize the gas limit, the contract misses an opportunity for gas optimization.

Impact:

The impact of the current implementation is primarily related to potential suboptimal gas usage. In scenarios where transactions have varying gas requirements, users may incur unnecessary costs or face delays due to inadequate gas limits. The issue does not pose a direct security threat but affects the efficiency and cost-effectiveness of protocol transactions.

Tools Used:

Manual review.

Recommendations:

Implement adapterParams for Custom Gas Limit:

  • Introduce a parameter for adapterParams in the sendMintMessage function to allow users to set a custom gas limit.

  • Ensure proper encoding and decoding of adapterParams according to the LayerZero documentation.

E.g the code can be changed like this

function sendMintMessage(
address user_,
uint256 amount_,
address refundTo_,
bytes calldata adapterParams
) external payable onlyDistribution {
RewardTokenConfig storage config = rewardTokenConfig;
bytes memory receiverAndSenderAddresses_ = abi.encodePacked(config.receiver, address(this));
bytes memory payload_ = abi.encode(user_, amount_);
ILayerZeroEndpoint(config.gateway).send{value: msg.value}(
config.receiverChainId,
receiverAndSenderAddresses_,
payload_,
payable(refundTo_),
address(0x0),
+ adapterParams // Pass adapterParams here
);
}

and from Distribution claim function you can pass the custom settings in adapterParams

// Example usage in Distribution.sol
L1Sender(l1Sender).sendMintMessage{value: msg.value}(user_, pendingRewards_, _msgSender(), adapterParams);
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

LayerZero Integration: Do not hardcode zero bytes (bytes(0)) as adapterParamers.

Support

FAQs

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