Low level call returns true if the address doesn’t exist
The low-level call and delegatecall functions in Solidity return true even if the target address does not exist, so the contract may treat a call to a non-existent address as successful. In the AxelarGateway and its proxy, this could lead to a gateway that is non-functional (a 'dud') if the implementation address is wrong, but the token call is only made to validated addresses.
Originally disclosed on Code4rena
Submitted by CertoraInc
AxelarGateway.sol#L545-L548 AxelarGatewayProxy.sol#L16-L24
As written in the solidity documentation, the low-level functions call, delegatecall and staticcall return true as their first return value if the account called is non-existent, as part of the design of the EVM. Account existence must be checked prior to calling if needed.
Proof of Concept
The low-level functions call and delegatecall are used in some places in the code and it can be problematic. For example, in the _callERC20Token of the AxelarGateway contract there is a low level call in order to call the ERC20 functions, but if the given tokenAddress doesn’t exist success will be equal to true and the function will return true and the code execution will be continued like the call was successful.
function _callERC20Token(address tokenAddress, bytes memory callData) internal returns (bool) {
(bool success, bytes memory returnData) = tokenAddress.call(callData);
return success && (returnData.length == uint256(0) || abi.decode(returnData, (bool)));
}
Another place that this can happen is in AxelarGatewayProxy’s constructor
constructor(address gatewayImplementation, bytes memory params) {
_setAddress(KEY_IMPLEMENTATION, gatewayImplementation);
(bool success, ) = gatewayImplementation.delegatecall(
abi.encodeWithSelector(IAxelarGateway.setup.selector, params)
);
if (!success) revert SetupFailed();
}
If the gatewayImplementation address doesn’t exist, the delegate call will return true and the function won’t revert.
Tools Used
Remix, VS Code
Recommended Mitigation Steps
Check before any low-level call that the address actually exists, for example before the low level call in the callERC20 function you can check that the address is a contract by checking its code size.
deluca-mike (Axelar) confirmed, but disagreed with severity and commented:
_callERC20Tokenis only called with a token address that has been set and was already validated by the gateway, and thus they do already exist.See:
As for
gatewayImplementation.delegatecall, this is a valid find, but there isn’t much risk because it would just mean that the gateway deployed would be a dud, and it would need to be redeployed correctly before the Axelar network can start interacting with it. In any case, we will fix this by checking that there is code at that address.
2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.Given that this would affect the protocols availability (the gateway being a “dud”) the finding does qualify as med risk.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code uses low-level calls without first checking that the target address contains code, relying on the call's success flag which is true for non-existent accounts.
Impact
The gateway could be deployed as a non-functional 'dud' if the implementation address is wrong, affecting protocol availability, but the token call is only made to validated addresses so no direct asset risk.
What the attacker needed
GatewayImplementation address has no code; deployment of the proxy with wrong address
The fix
The team will fix this by checking that there is code at the implementation address before the delegatecall.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In Solidity, when you use a low-level call to send data to another address, the call reports success even if that address has no code. This can fool a contract into thinking an action worked when it did not. The report shows two places where this could cause problems, but the impact is limited because one is only used with known addresses and the other would just create a broken gateway that needs redeployment.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.