QA Report #66
Labels
bug
Something isn't working
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
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 Staking.sol, 78, IERC20(TOKE_POOL).approve(CURVE_POOL, type(uint256).max);
approve without approving 0 first Staking.sol, 91, IERC20Upgradeable(TOKE_TOKEN).approve(COW_RELAYER, type(uint256).max);
approve without approving 0 first Staking.sol, 82, IERC20(STAKING_TOKEN).approve(TOKE_POOL, type(uint256).max);
Add a timelock
To give more trust to users: functions that set key/critical variables should be put behind a timelock.
Code instances:
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:
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:
Does not validate the input fee parameter
Some fee parameters of functions are not checked for invalid values. Validate the parameters:
Code instances:
Require with not comprehensive message
The following requires has a non comprehensive messages.
This is very important to add a comprehensive message for any require. Such that the user has enough
information to know the reason of failure:
Code instance:
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:
Not verified claimer
If a functions gets as input a claimer param, then it should make sure the claimer address is not address(0).
Otherwise it will cause to loss of the funds or access.
Code instance:
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:
Not verified owner
Code instance:
Init frontrun
Most contracts use an init pattern (instead of a constructor) to initialize contract parameters. Unless these are enforced to be atomic with contact deployment via deployment script or factory contracts, they are susceptible to front-running race conditions where an attacker/griefer can front-run (cannot access control because admin roles are not initialized) to initially with their own (malicious) parameters upon detecting (if an event is emitted) which the contract deployer has to redeploy wasting gas and risking other transactions from interacting with the attacker-initialized contract.
Many init functions do not have an explicit event emission which makes monitoring such scenarios harder. All of them have re-init checks; while many are explicit some (those in auction contracts) have implicit reinit checks in initAccessControls() which is better if converted to an explicit check in the main init function itself.
(details credit to: code-423n4/2021-09-sushimiso-findings#64)
The vulnerable initialization functions in the codebase are:
Code instances:
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:
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:
Unbounded loop on array that can only grow can lead to DoS
A malicious attacker that is also a protocol owner can push unlimitedly to an array, that some function loop over this array.
If increasing the array size enough, calling the function that does a loop over the array will always revert since there is a gas limit.
This is a Med Risk issue since it can lead to DoS with a reasonable chance of having untrusted owner or even an owner that did a mistake in good faith.
Code instances:
Duplicates in array
Code instance:
BatchRequests.addAddress pushed (_address)
The text was updated successfully, but these errors were encountered: