Summary
sendMintMessage
do not follow the official checklist mentioned by layerzero.
Vulnerability Details
function sendMintMessage(address user_, uint256 amount_, address refundTo_) 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),
@> bytes("")
);
}
sendMintMessage
has hardcoded adress(0x0)
for zroPaymentAddress
and similarly uses bytes(0)
for adapterParams
. Which is not a recommended practice. As this will prevent using ZRO
token as fee which will be launching in coming future.
All checklist can be checked here. See point 5 and 7.
As keeping this values as params will be more useful for future updates, to have flexibility to use ZRO as fees.
Impact
composability issue with future updates, if layerzero introduced some breaking changes.
Tools Used
Manual Review
Recommendations
Add input params for zroPaymentAddress
as well as for adapterParams
as given below.
function sendMintMessage(address user_, uint256 amount_, address refundTo_
+ address zroPaymentAddress_, 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, // communicator LayerZero chainId
receiverAndSenderAddresses_, // send to this address to the communicator
payload_, // bytes payload
payable(refundTo_), // refund address
- address(0x0), // future parameter
- bytes("") // adapterParams (see "Advanced Features")
+ zroPaymentAddress_,
+ adapterParams_
);
}