Platform: Code4rena
Start Date: 27/01/2022
Pot Size: $75,000 USDT
Total HM: 6
Participants: 29
Period: 7 days
Judge: leastwood
Total Solo HM: 6
Id: 72
League: ETH
Rank: 9/29
Findings: 2
Award: $2,454.74
🌟 Selected for report: 1
🚀 Solo Findings: 0
pauliax
.transfer is no longer recommended as recipients with custom fallback functions (smart contracts) will not be able to handle that:
if (address(token) == weth) { IWETH(weth).withdraw(amount); payable(to).transfer(amount);
You can read more here: https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/
Solution (don't forget re-entrancy protection): https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol#L53-L59
#0 - ColaM12
2022-02-03T06:28:10Z
Duplicate to #228
🌟 Selected for report: pauliax
1627.6042 USDT - $1,627.60
pauliax
function transferTo allows transferring amount from beneficiary to any address. However, 'to' is considered valid when it does not have an amount locked yet:
function transferTo(address to, uint amount) external ... require(releaseVars[to].amount == 0, 'to is exist');
It locks this amount for releaseVars[beneficiary].endTime. Because the blockchain is public, a malicious actor could monitor the mempool, and crash any attempt of transferTo by frontrunning it and calling transferTo with the smallest fraction (dust) from his own address to the 'to' address, making it unavailable to receive new locks for some time (even 4 years is possible?).
A few possible solutions would be to introduce a reasonable minimum amount to transfer or add a 2-step approval, where 'to' first have to approve the beneficiary.
19.0749 USDT - $19.07
pauliax
The condition should be _locked.amount > 0:
require(_locked.amount >= 0, "Nothing to withdraw");
safe32 should be n <= 2 ** 32:
require(n < 2 ** 32, errorMessage);
#0 - ColaM12
2022-02-03T07:00:31Z
Duplicate to #132
10.3004 USDT - $10.30
pauliax
There are variables that do not change so they can be marked as immutable to greatly improve the gas costs. Examples of such variables are: Airdrop.sol
IERC20 public token;
Adminable.sol
address payable public developer;
OLETokenLock.sol
OLEToken public token;
Reserve.sol
IERC20 public oleToken;
Please review all the state variables and apply immutable where possible.
#0 - ColaM12
2022-02-03T06:30:44Z
Duplicate to #11
pauliax
You should cache storage access to improve gas efficiency, e.g.: tranches[_trancheId] is accessed 5 times in function _claim. function acceptAdmin could first set local variable oldPendingAdmin and then compare against it.
#0 - ColaM12
2022-02-03T06:29:22Z
Duplicate to #137
10.3004 USDT - $10.30
pauliax
.length in a loop can be extracted into a variable and used where necessary to reduce the number of storage reads GovernorAlpha.sol
for (uint i = 0; i < proposal.targets.length; i++)
#0 - ColaM12
2022-02-03T06:34:52Z
Duplicate to #15
47.0985 USDT - $47.10
pauliax
Assigned operations to constant variables are re-evaluated every time. See https://github.com/ethereum/solidity/issues/9232 Change from 'constant' to 'immutable'.
// The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); // The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); // The EIP-712 typehash for the ballot struct used by the contract bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,bool support)"); uint constant NEXT_OFFSET = ADDRESS_SIZE + FEE_SIZE;
#0 - ColaM12
2022-02-03T06:40:12Z
Duplicate to #123