Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Periphery/Executor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ contract Executor is IAxelarExecutable, Ownable, ReentrancyGuard, ILiFi {
error InvalidStargateRouter();
error InvalidCaller();
error UnAuthorized();
error NotAContract();

/// Events ///
event AxelarGatewaySet(address indexed gateway);
Expand Down Expand Up @@ -277,6 +278,7 @@ contract Executor is IAxelarExecutable, Ownable, ReentrancyGuard, ILiFi {
// The first 20 bytes of the payload are the callee address
address callTo = payload.toAddress(0);

if (!_isContract(callTo)) revert NotAContract();
if (callTo == address(erc20Proxy)) revert UnAuthorized();

// The remaining bytes should be calldata
Expand All @@ -300,6 +302,7 @@ contract Executor is IAxelarExecutable, Ownable, ReentrancyGuard, ILiFi {
// The first 20 bytes of the payload are the callee address
address callTo = payload.toAddress(0);

if (!_isContract(callTo)) revert NotAContract();
if (callTo == address(erc20Proxy)) revert UnAuthorized();

// The remaining bytes should be calldata
Expand Down Expand Up @@ -343,4 +346,15 @@ contract Executor is IAxelarExecutable, Ownable, ReentrancyGuard, ILiFi {
}
return balances;
}

/// @dev Checks if address is a contract address
/// @param addr the address to check
/// @return bool whether or not address is a contract
function _isContract(address addr) private view returns (bool) {
uint256 size;
assembly {
size := extcodesize(addr)
}
return size > 0;
}
}