RemoteAddressValidator can incorrectly convert addresses to lowercase
Submitted by Jeiwan, also found by Shubham and Chom
The validateSender and addTrustedAddress functions of RemoteAddressValidator can incorrectly handle the passed address arguments, which will result in false negatives. E.g. a valid sender address may be invalidated.
Proof of Concept
The RemoteAddressValidator._lowerCase function is used to convert an address to lowercase. Since the protocol is expected to support different EVM and non-EVM chains, account addresses may have different format, thus the necessity to convert them to strings and to convert the strings to lowercase when comparing them. However, the function only converts the hexadecimal letters, i.e. the characters in ranges A-F:
if ((b >= 65) && (b <= 70)) bytes(s)[i] = bytes1(b + uint8(32));
Here, 65 corresponds to A, and 70 corresponds to F. But, since different EVM and non-EVM chains are supported, addresses can contain other characters. For example, Cosmos uses bech32 addresses and Evmos supports both hexadecimal and bech32 addresses.
If not all alphabetical characters of an address are converted to lowercase, then the address comparison in the validateSender can fail and result in a false revert.
Recommended Mitigation Steps
In the _lowerCase function, consider converting all alphabetical characters to lowercase, e.g.:
diff --git a/contracts/its/remote-address-validator/RemoteAddressValidator.sol b/contracts/its/remote-address-validator/RemoteAddressValidator.sol
index bb101e5..e83431b 100644
--- a/contracts/its/remote-address-validator/RemoteAddressValidator.sol
+++ b/contracts/its/remote-address-validator/RemoteAddressValidator.sol
@@ -55,7 +55,7 @@ contract RemoteAddressValidator is IRemoteAddressValidator, Upgradable {
uint256 length = bytes(s).length;
for (uint256 i; i < length; i++) {
uint8 b = uint8(bytes(s)[i]);
- if ((b >= 65) && (b <= 70)) bytes(s)[i] = bytes1(b + uint8(32));
+ if ((b >= 65) && (b <= 90)) bytes(s)[i] = bytes1(b + uint8(32));
}
return s;
}
deanamiel (Axelar) disagreed with severity and commented:
Corrected Severity: QA
This was originally meant to cover the EVM addresses, but we implemented a fix to account for non-EVM addresses as well.
Public PR link: https://github.com/axelarnetwork/interchain-token-service/pull/96
berndartmueller (judge) commented:
I’m maintaining the medium severity for this issue as it prevents using any non-EVM addresses.
milapsheth (Axelar) commented:
We consider this finding QA or Low severity since the scope of the implementation is for EVM chains (even though Axelar’s cross-chain messaging API is generic). Non EVM chains require further consideration that wasn’t the focus for this version.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity business logic bug in Axelar Network. Code4rena made it public on 29 November 2023. Found in the 2023-07-axelar audit contest (finding M-03), also found by 2 other wardens.
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.