Platform: Code4rena
Start Date: 14/06/2022
Pot Size: $50,000 USDC
Total HM: 19
Participants: 99
Period: 5 days
Judge: HardlyDifficult
Total Solo HM: 4
Id: 136
League: ETH
Rank: 49/99
Findings: 2
Award: $84.25
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: joestakey
Also found by: 0x1f8b, 0x29A, 0x52, 0xDjango, 0xNazgul, 0xNineDec, 0xf15ers, 0xkowloon, 0xmint, 8olidity, BowTiedWardens, Chom, Cityscape, Czar102, ElKu, FSchmoede, Funen, GimelSec, GreyArt, IllIllI, KIntern, Kaiziron, Kenshin, Lambda, MadWookie, MiloTruck, PPrieditis, Picodes, Ruhum, Sm4rty, StErMi, TerrierLover, TomJ, Treasure-Seeker, VAD37, WatchPug, Wayne, _Adam, a12jmx, abhinavmir, antonttc, apostle0x01, asutorufos, berndartmueller, cccz, cloudjunky, codexploder, cryptphi, csanuragjain, defsec, delfin454000, fatherOfBlocks, georgypetrov, hake, hansfriese, horsefacts, hyh, k, kenta, nxrblsrpr, oyc_109, peritoflores, rajatbeladiya, reassor, rfa, robee, sach1r0, saian, samruna, shenwilly, simon135, sorrynotsorry, sseefried, throttle, unforgiven, wagmi, zzzitron
53.0326 USDC - $53.03
Severity: Low
Context: InfinityExchange.sol#L104-L117
, InfinityExchange.sol#L1235-L1257
, InfinityStaker.sol#L49-L52
, InfinityStaker.sol#L375-L377
, InfinityToken.sol#L37-L56
Description: Lack of zero-address validation on address parameters may lead to reverts and force contract redeployments.
Recommendation: Add explicit zero-address validation on input parameters of address type.
Severity: Low
Context: InfinityExchange.sol#L1235-L1269
, InfinityStaker.sol#L351-L377
Description: Setter functions are missing checks to validate if the new value being set is the same as the current value already set in the contract. Such checks will showcase mismatches between on-chain and off-chain states.
Recommendation: Add in the additional checks to validate if the new value being set is the same as the current value already set in the contract.
Severity: Low
Context: InfinityExchange.sol#L1235-L1252
, InfinityStaker.sol#L351-L372
Description:
None of the onlyOwner
functions that change critical protocol addresses/parameters appear to have a time lock for a time-delayed change to alert: (1) users and give them a chance to engage/exit protocol if they are not agreeable to the changes (2) team in case of compromised owner(s) and given them a chance to perform incident response.
Recommendation: Add a time lock to these functions for a time-delayed change to alert users and protect against possible malicious changes by compromised owners(s).
Severity: Low
Context: InfinityExchange.sol#L1220-L1257
, InfinityStaker.sol#L345-L377
Description: Several functions update critical parameters that are missing event emission. These should be performed to ensure tracking of changes of such critical parameters.
Recommendation: Add events to functions that change critical parameters.
receive()
Function Should Emit An EventSeverity: Low
Context: InfinityExchange.sol#L121
, InfinityStaker.sol#L57
Description:
Consider emitting an event inside this function with msg.sender
and msg.value
as the parameters. This would make it easier to track incoming ether transfers.
Recommendation:
Add events to the receive()
functions.
Severity Informational
Context: InfinityExchange.sol#L263
,
Description: Some revert messages are unclear which can lead to confusion. Unclear revert messages may cause misunderstandings on reverted transactions.
Recommendation: Make revert messages more clear.
Severity: Informational
Context: InfinityExchange.sol#L61
, InfinityStaker.sol#L33-L136
Description: There are multiple occasions where certain numbers have been hardcoded, either in variables or in the code itself. Large numbers can become hard to read.
Recommendation: Consider using underscores for number literals to improve its readability.
Severity Informational
Context: InfinityExchange.sol#L80-L102
, InfinityToken.sol#L35
Description: Parameters of certain events are expected to be indexed so that they’re included in the block’s bloom filter for faster access. Failure to do so might confuse off-chain tooling looking for such indexed events.
Recommendation: Add the indexed keyword to event parameters that should include it.
Severity Informational
Context: InfinityStaker.sol#L23 (userstakedAmount => userStakedAmount)
, InfinityStaker.sol#L120 (vestedsixMonths => vestedSixMonths)
Description:
The linked variables do not conform to the standard naming convention of Solidity whereby functions and variable names utilize the camelCase
format.
Recommendation: Naming conventions utilized by the linked statements are adjusted to reflect the correct type of declaration according to the Solidity style guide.
Severity: Informational
Context: InfinityExchange.sol#L58 (adress => address)
, InfinityExchange.sol#L77 (storate => storage)
, InfinityExchange.sol#L1260 (updateWethTranferGas => updateWethTransferGas)
, InfinityOrderBookComplication.sol#L255 (dont => do not)
, InfinityStaker.sol#L112 (untake => Unstake)
Description: Spelling errors in comments can cause confusion to both users and developers.
Recommendation: Check all misspellings to ensure they are corrected.
Severity: Informational
Context: All Contracts
Description: Some functions are missing @notice/@dev NatSpec comments for the function, @param for all/some of their parameters and @return for return values. Given that NatSpec is an important part of code documentation, this affects code comprehension, auditability and usability.
Recommendation: Add in full NatSpec comments for all functions to have complete code documentation for future use.
Severity: Informational
Context: All Contracts
Description: Elastic supply tokens could dynamically adjust their price, supply, user's balance, etc. Such a mechanism makes a DeFi system complex, while many security accidents are caused by the elastic tokens. For example, a DEX using deflationary token must double check the token transfer amount when taking swap action because of the difference of actual transfer amount and parameter.
Recommendation: In terms of confidentiality, integrity and availability, it is highly recommend that one should not use elastic supply tokens.
Severity Informational
Context: All Contracts
Description: Using too recent of a pragma is risky since they are not battle tested. A rise of a bug that wasn't known on release would cause either a hack or a need to secure funds and redeploy.
Recommendation:
Use a Pragma version that has been used for sometime. I would suggest 0.8.4
for the decrease of risk and still has the gas optimizations implemented.
#0 - nneverlander
2022-06-23T12:27:17Z
Thanks
#1 - HardlyDifficult
2022-07-12T00:12:50Z
🌟 Selected for report: IllIllI
Also found by: 0v3rf10w, 0x1f8b, 0x29A, 0xAsm0d3us, 0xDjango, 0xKitsune, 0xNazgul, 0xf15ers, 0xkatana, 0xkowloon, BowTiedWardens, Chom, ElKu, FSchmoede, Funen, GimelSec, Kaiziron, Kenshin, Lambda, MadWookie, MiloTruck, PPrieditis, Picodes, PwnedNoMore, StErMi, Tadashi, TerrierLover, TomJ, Tomio, Wayne, Waze, _Adam, antonttc, apostle0x01, asutorufos, c3phas, codexploder, defsec, delfin454000, fatherOfBlocks, hake, hansfriese, hyh, joestakey, k, kenta, oyc_109, peritoflores, reassor, rfa, robee, sach1r0, simon135, slywaters, zer0dot
31.2227 USDC - $31.22
require()
, Use != 0
Instead of > 0
With Uint ValuesContext: InfinityExchange#L390-L402 (For L392)
Description:
In a require, when checking a uint, using != 0
instead of > 0
saves 6 gas. This will jump over or avoid an extra ISZERO
opcode.
Recommendation:
Use != 0
instead of > 0
with uint values but only in require()
statements.
Immutable
Context: InfinityStaker#L25
Description:
Solidity 0.6.5
introduced immutable
as a major feature. It allows setting contract-level variables at construction time which gets stored in code rather than storage. Each call to it reads from storage, using a sload
costing 2100 gas cold or 100 gas warm. Setting it to immutable
will have each storage read of the state variable to be replaced by the instruction push32 value
, where value
is set during contract construction time and this costs only 3 gas.
Recommendation:
Set the state variable to immutable
Context: All Contracts
Description:
You can cut out 10 opcodes in the creation-time EVM bytecode if you declare a constructor payable. Making the constructor payable eliminates the need for an initial check of msg.value == 0
and saves 21 gas on deployment with no security risks.
Recommendation: Set the constructor to payable.
Context: All Contracts
Description:
Contracts most called functions could simply save gas by function ordering via Method ID. Calling a function at runtime will be cheaper if the function is positioned earlier in the order (has a relatively lower Method ID) because 22 gas are added to the cost of a function for every position that came before it. The caller can save on gas if you prioritize most called functions. One could use This tool
to help find alternative function names with lower Method IDs while keeping the original name intact.
Recommendation:
Find a lower method ID name for the most called functions for example mostCalled()
vs. mostCalled_41q()
is cheaper by 44 gas.