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: 44/99
Findings: 3
Award: $91.43
π Selected for report: 0
π Solo Findings: 0
π Selected for report: hyh
Also found by: 0x29A, 0xNineDec, 0xf15ers, 0xkowloon, GreyArt, IllIllI, KIntern, Kenshin, Lambda, WatchPug, Wayne, berndartmueller, byterocket, cccz, codexploder, horsefacts, kenzo, obront, obtarian, oyc_109, peritoflores, rajatbeladiya, rfa, saian, unforgiven, zer0dot
11.084 USDC - $11.08
https://github.com/code-423n4/2022-06-infinity/blob/765376fa238bbccd8b1e2e12897c91098c7e5ac6/contracts/staking/InfinityStaker.sol#L346 https://github.com/code-423n4/2022-06-infinity/blob/765376fa238bbccd8b1e2e12897c91098c7e5ac6/contracts/core/InfinityExchange.sol#L1230
The function rescueETH
is supposed to withdraw ETH stored in the contracts, but instead they transfer msg.value
sent from the msg.sender
to the destination address. Any ETH held by the 2 contracts are locked forever.
msg.value
should be replaced with address(this).balance
and the function itself does not have to be payable
as it should not require any payments.
#0 - nneverlander
2022-06-22T11:18:45Z
Duplicate
#1 - nneverlander
2022-07-05T11:41:23Z
#2 - HardlyDifficult
2022-07-09T16:45:13Z
π 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
48.9784 USDC - $48.98
Summary: Typo in OrderTypes.sol Location: https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/libs/OrderTypes.sol#L39 Issue: ordes -> orders
Summary: Typo in InfinityExchange.sol Location: https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L58 Issue: adress -> address
Summary: storage variable name is not properly camelcased Location: https://github.com/code-423n4/2022-06-infinity/blob/765376fa238bbccd8b1e2e12897c91098c7e5ac6/contracts/staking/InfinityStaker.sol#L23 Issue: the storage variable userstakedAmounts should be renamed to userStakedAmounts because user and staked are two words.
Summary: ReentrancyGuard in InfinityStaker seems unnecessary. Location: https://github.com/code-423n4/2022-06-infinity/blob/765376fa238bbccd8b1e2e12897c91098c7e5ac6/contracts/staking/InfinityStaker.sol#L15 Issue: ReentrancyGuard does not seem to be useful for InfinityStaker because the only token being transferred is INFINITY_TOKEN, which is an ERC-20 token deployed by the team and not an ERC-777 token with callback hooks after each transfer. It can reduce code size and save gas by removing it.
Summary: There should be a ceiling to PROTOCOL_FEE_BPS Location: https://github.com/code-423n4/2022-06-infinity/blob/765376fa238bbccd8b1e2e12897c91098c7e5ac6/contracts/core/InfinityExchange.sol#L1266 Issue: There should be a hard coded ceiling for PROTOCOL_FEE_BPS, in case the contract owner is compromised (even if it is a multi-sig or a token governed time-locked contract).
#0 - nneverlander
2022-06-23T12:10:18Z
Duplicate
π 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.3666 USDC - $31.37
Summary: userMinOrderNonce[msg.sender] should be cached in memory Location: https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L380 Issue: The function is reading from the storage the value userMinOrderNonce[msg.sender] twice inL380 and L381. The value should be cached in a memory variable to reduce gas cost. Based on hardhat-gas-report, the average gas used for cancelAllOrders was 39017 and after the optimization the average gas used is 38855.
Summary: The size of isOrderValid can be reduced by re-writing the code Location: https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L520 Issue: The logic in L520
if ( orderExpired || !sigValid || order.signer == address(0) || !_complications.contains(order.execParams[0]) || !_currencies.contains(order.execParams[1]) ) { return false; } return true;
can be re-written as
return ( !orderExpired && sigValid && order.signer != address(0) && _complications.contains(order.execParams[0]) && _currencies.contains(order.execParams[1]) );
According to hardhat, the contract size is 0.025 KB smaller this way.
if (totalPower > PLATINUM_STAKE_THRESHOLD) { return StakeLevel.PLATINUM; } else if (totalPower > GOLD_STAKE_THRESHOLD) { return StakeLevel.GOLD; } else if (totalPower > SILVER_STAKE_THRESHOLD) { return StakeLevel.SILVER; } else if (totalPower > BRONZE_STAKE_THRESHOLD) { return StakeLevel.BRONZE; } else { return StakeLevel.NONE; }
return secondsSinceStake >= durationInSeconds ? userStakedAmounts[user][duration].amount : 0;
secondsSinceStake can be less than durationInSeconds and thus an
unnecessary expensive operation can be avoided. The average gas spent for
rageQuit and unstake before the optimization are 88626 and 71345, and after the
optimization are 88378 and 66758.
#0 - nneverlander
2022-06-23T12:09:54Z
Thanks