QA Report #16
Labels
bug
Something isn't working
edited-by-warden
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
1 Does not validate the input fee parameter
Some fee parameters of functions are not checked for invalid values. Validate the parameters:
Code instances:
2 safeApprove of openZeppelin is deprecated
You use safeApprove of openZeppelin although it's deprecated.
(see https://github.com/OpenZeppelin/openzeppelin-contracts/blob/566a774222707e424896c0c390a84dc3c13bdcb2/contracts/token/ERC20/utils/SafeERC20.sol#L38)
You should change it to increase/decrease Allowance as OpenZeppilin says.
Code instances:
3 Not verified input
external / public functions parameters should be validated to make sure the address is not 0.
Otherwise if not given the right input it can mistakenly lead to loss of user funds.
Code instances:
4 Solidity compiler versions mismatch
The project is compiled with different versions of solidity, which is not recommended because it can lead to undefined behaviors.
Code instance:
5 Not verified owner
Code instances:
6 Named return issue
Users can mistakenly think that the return value is the named return, but it is actually the actualreturn statement that comes after. To know that the user needs to read the code and is confusing.
Furthermore, removing either the actual return or the named return will save gas.
Code instance:
7 Two Steps Verification before Transferring Ownership
The following contracts have a function that allows them an admin to change it to a different address. If the admin accidentally uses an invalid address for which they do not have the private key, then the system gets locked.
It is important to have two steps admin change where the first is announcing a pending new admin and the new address should then claim its ownership.
A similar issue was reported in a previous contest and was assigned a severity of medium: code-423n4/2021-06-realitycards-findings#105
Code instances:
8 Never used parameters
Those are functions and parameters pairs that the function doesn't use the parameter. In case those functions are external/public this is even worst since the user is required to put value that never used and can misslead him and waste its time.
Code instances:
9 Check transfer receiver is not 0 to avoid burned money
Transferring tokens to the zero address is usually prohibited to accidentally avoid "burning" tokens by sending them to an unrecoverable zero address.
Code instances:
10 Missing commenting
Code instances:
11 Add a timelock
To give more trust to users: functions that set key/critical variables should be put behind a timelock.
Code instances:
12 Must approve 0 first
Some tokens (like USDT) do not work when changing the allowance from an existing non-zero allowance value.
They must first be approved by zero and then the actual allowance must be approved.
Code instances:
approve without approving 0 first ReceiverImplementation.sol, 63, IERC20(wrappedTokenAddress).approve(gateway, amount);
approve without approving 0 first AxelarDepositService.sol, 29, IERC20(wrappedTokenAddress).approve(gateway, amount);
approve without approving 0 first ReceiverImplementation.sol, 37, IERC20(tokenAddress).approve(gateway, amount);
13 Two arrays length mismatch
The functions below fail to perform input validation on arrays to verify the lengths match.
A mismatch could lead to an exception or undefined behavior.
Consider making this a medium risk please.
14 Override function but with different argument location
Code instance:
AxelarGasService.sol.payGasForContractCallWithToken inherent IAxelarGasService.sol.payGasForContractCallWithToken but the parameters does not match
https://github.com/code-423n4/2022-07-axelar/tree/main/contracts/interfaces/IAxelarGasService.sol#L71
15 Tokens with fee on transfer are not supported
There are ERC20 tokens that charge fee for every transfer() / transferFrom().
Vault.sol#addValue() assumes that the received amount is the same as the transfer amount,
and uses it to calculate attributions, balance amounts, etc.
But, the actual transferred amount can be lower for those tokens.
Therefore it's recommended to use the balance change before and after the transfer instead of the amount.
This way you also support the tokens with transfer fee - that are popular.
Code instances:
16 approve return value is ignored
Some tokens don't correctly implement the EIP20 standard and their approve function returns void instead of a success boolean.
Calling these functions with the correct EIP20 function signatures will always revert.
Tokens that don't correctly implement the latest EIP20 spec, like USDT, will be unusable in the mentioned contracts as they revert the transaction because of the missing return value.
We recommend using OpenZeppelin’s SafeERC20 versions with the safeApprove function that handle the return value check as well as non-standard-compliant tokens.
The list of occurrences in format (solidity file, line number, actual line)
Code instances:
AxelarDepositService.sol, 29, IERC20(wrappedTokenAddress).approve(gateway, amount);
ReceiverImplementation.sol, 63, IERC20(wrappedTokenAddress).approve(gateway, amount);
ReceiverImplementation.sol, 37, IERC20(tokenAddress).approve(gateway, amount);
17 transfer return value of a general ERC20 is ignored
Need to use safeTransfer instead of transfer. As there are popular tokens, such as USDT that transfer/trasnferFrom method doesn’t return anything. The transfer return value has to be checked (as there are some other tokens that returns false instead revert), that means you must
Another popular possibility is to add a whiteList.
Those are the appearances (solidity file, line number, actual line):
Code instance:
The text was updated successfully, but these errors were encountered: