From a753911f0005fa67d0d09f8ef81e6b37eeb49d08 Mon Sep 17 00:00:00 2001 From: Jun Kim <64379343+junkim012@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:56:41 -0500 Subject: [PATCH] fix: L-02 check for receiver or target teller being zero address --- .../Roles/CrossChain/MultiChainTellerBase.sol | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/base/Roles/CrossChain/MultiChainTellerBase.sol b/src/base/Roles/CrossChain/MultiChainTellerBase.sol index 2f47905..4880ffc 100644 --- a/src/base/Roles/CrossChain/MultiChainTellerBase.sol +++ b/src/base/Roles/CrossChain/MultiChainTellerBase.sol @@ -14,6 +14,8 @@ struct Chain { error MultiChainTellerBase_MessagesNotAllowedFrom(uint32 chainSelector); error MultiChainTellerBase_MessagesNotAllowedFromSender(uint256 chainSelector, address sender); error MultiChainTellerBase_MessagesNotAllowedTo(uint256 chainSelector); +error MultiChainTellerBase_TargetTellerIsZeroAddress(); +error MultiChainTellerBase_DestinationChainReceiverIsZeroAddress(); error MultiChainTellerBase_ZeroMessageGasLimit(); error MultiChainTellerBase_GasLimitExceeded(); error MultiChainTellerBase_GasTooLow(); @@ -172,15 +174,25 @@ abstract contract MultiChainTellerBase is CrossChainTellerBase { * @param data bridge data */ function _beforeBridge(BridgeData calldata data) internal override { - if (!selectorToChains[data.chainSelector].allowMessagesTo) { + Chain chain = selectorToChains[data.chainSelector]; + + if (!chain.allowMessagesTo) { revert MultiChainTellerBase_MessagesNotAllowedTo(data.chainSelector); } - if (data.messageGas > selectorToChains[data.chainSelector].messageGasLimit) { + if (chain.targetTeller == address(0)) { + revert MultiChainTellerBase_TargetTellerIsZeroAddress(); + } + + if (data.destinationChainReceiver == address(0)) { + revert MultiChainTellerBase_DestinationChainReceiverIsZeroAddress(); + } + + if (data.messageGas > chain.messageGasLimit) { revert MultiChainTellerBase_GasLimitExceeded(); } - if (data.messageGas < selectorToChains[data.chainSelector].minimumMessageGas) { + if (data.messageGas < chain.minimumMessageGas) { revert MultiChainTellerBase_GasTooLow(); } }