Platform: Code4rena
Start Date: 01/08/2022
Pot Size: $50,000 USDC
Total HM: 26
Participants: 133
Period: 5 days
Judge: Jack the Pug
Total Solo HM: 6
Id: 151
League: ETH
Rank: 29/133
Findings: 4
Award: $266.32
๐ Selected for report: 1
๐ Solo Findings: 0
๐ Selected for report: MiloTruck
Also found by: 0x52, 8olidity, Ruhum, __141345__, cccz, codexploder, cryptonue, hansfriese, sseefried
49.6901 USDC - $49.69
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/HomeFi.sol#L185-L197
There are some functions that the admin can call to brick various parts of the system
Even if the owner is benevolent the fact that there is a rug vector available may negatively impact the protocolโs reputation.
Admin can set LenderFee to an amount that can break / rug the protocol.
/// @inheritdoc IHomeFi function replaceLenderFee(uint256 _newLenderFee) external override onlyAdmin { // Revert if no change in lender fee require(lenderFee != _newLenderFee, "HomeFi::!Change"); // Reset variables lenderFee = _newLenderFee; emit LenderFeeReplaced(_newLenderFee); }
Set maximum and minimum amount (of the LenderFee) allowed
#0 - horsefacts
2022-08-06T21:56:56Z
Duplicate of https://github.com/code-423n4/2022-08-rigor-findings/issues/400 (lender can set a greater than 100% fee that underflows) Maybe duplicate of https://github.com/code-423n4/2022-08-rigor-findings/issues/252 (lender can extract 100% fee)
154.2761 USDC - $154.28
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/Community.sol#L206-L282
When publishing a project, there is still possibility the project doesn't have any task or 0 budget.
According to contest guideline, there is an information says
"Note that you cannot submit a project with no total budget. Therefore it requires at least one task with a budget > 0."
Meanwhile, on publishProject()
in Community.sol, there is no check of this condition.
Add a new require
which will check if the first task (which is at index 1), its cost is > 0.
// Local instance of variables. For saving gas. IProject _projectInstance = IProject(_project); ... // Revert if project doesn't have one task with budget > 0 require(_projectInstance.tasks[1].cost > 0, "First task > 0");
#0 - parv3213
2022-08-11T12:00:39Z
The docs here were deprecated. A project doesn't have to have any task published in a community.
#1 - jack-the-pug
2022-08-27T10:45:12Z
This is a valid Medium based on the docs (even though it's deprecated now)
๐ Selected for report: Lambda
Also found by: 0x1f8b, 0x52, 0xA5DF, 0xNazgul, 0xNineDec, 0xSmartContract, 0xSolus, 0xf15ers, 0xkatana, 0xsolstars, 8olidity, Aymen0909, Bahurum, Bnke0x0, CertoraInc, Chom, CodingNameKiki, Deivitto, Dravee, ElKu, Extropy, Funen, GalloDaSballo, Guardian, IllIllI, JC, Jujic, MEP, Noah3o6, ReyAdmirado, Rohan16, Rolezn, Ruhum, Sm4rty, SooYa, Soosh, Throne6g, TomJ, Tomio, TrungOre, Waze, Yiko, _Adam, __141345__, a12jmx, ajtra, ak1, arcoun, asutorufos, ayeslick, benbaessler, berndartmueller, bin2chen, bobirichman, brgltd, bulej93, byndooa, c3phas, codexploder, cryptonue, cryptphi, defsec, delfin454000, dipp, djxploit, erictee, exd0tpy, fatherOfBlocks, gogo, hake, hansfriese, horsefacts, hyh, ignacio, indijanc, joestakey, kaden, mics, minhquanym, neumo, obront, oyc_109, p_crypt0, pfapostol, poirots, rbserver, robee, rokinot, rotcivegaf, sach1r0, saian, samruna, saneryee, scaraven, sikorico, simon135, sseefried, supernova
40.6283 USDC - $40.63
block.timestamp
is being used several times inside Community.sol
file.
Block timestamps have historically been used for a variety of applications, such as entropy for random numbers (see the Entropy Illusion for further details), locking funds for periods of time, and various state-changing conditional statements that are time-dependent. Miners have the ability to adjust timestamps slightly, which can prove to be dangerous if block timestamps are used incorrectly in smart contracts.
Block timestamps should not be used for entropy or generating random numbersโi.e., they should not be the deciding factor (either directly or through some derivation) for winning a game or changing an important state.
Time-sensitive logic is sometimes required; e.g., for unlocking contracts (time-locking), completing an ICO after a few weeks, or enforcing expiry dates. It is sometimes recommended to use block.number and an average block time to estimate times; with a 10 second block time, 1 week equates to approximately, 60480 blocks. Thus, specifying a block number at which to change a contract state can be more secure, as miners are unable to easily manipulate the block number.
Not inlining costs 20 to 40 gas because of two extra JUMP instructions and additional stack operations needed for function calls.
example internal function mintNFT()
inside HomeFi.sol
current solidity version is 0.8.15 meanwhile project is using 0.8.6. OpenZeppelin library currently 4.7.2 while the project is using 4.4.2. It's best to use latest version because there are some features improvement and security patch.
๐ Selected for report: c3phas
Also found by: 0x040, 0x1f8b, 0xA5DF, 0xNazgul, 0xSmartContract, 0xSolus, 0xc0ffEE, 0xkatana, 0xsam, 8olidity, Aymen0909, Bnke0x0, CertoraInc, Chinmay, Chom, CodingNameKiki, Deivitto, Dravee, ElKu, Extropy, Fitraldys, Funen, GalloDaSballo, Guardian, IllIllI, JC, Lambda, MEP, Metatron, MiloTruck, Noah3o6, NoamYakov, PaludoX0, ReyAdmirado, Rohan16, Rolezn, Ruhum, Sm4rty, SooYa, TomJ, Tomio, Waze, _Adam, __141345__, a12jmx, ajtra, ak1, apostle0x01, asutorufos, ballx, benbaessler, bharg4v, bobirichman, brgltd, cryptonue, defsec, delfin454000, dharma09, djxploit, durianSausage, eierina, erictee, fatherOfBlocks, gerdusx, gogo, hake, hyh, ignacio, jag, kaden, kyteg, lucacez, mics, minhquanym, oyc_109, pfapostol, rbserver, ret2basic, robee, rokinot, sach1r0, saian, samruna, scaraven, sikorico, simon135, supernova, teddav, tofunmi, zeesaw
21.7223 USDC - $21.72
Rigor is using solidity version 0.8.6, while custom errors are available from solidity version 0.8.4, so it's suitable to use custom error. Custom errors save ~50 gas each time theyโre hitby avoiding having to allocate and store the revert string. Not defining the strings also save deployment gas
The overheads outlined below are PER LOOP, excluding the first loop
example loop _changeOrderedTask.length
inside Project.sol
Saves 6 gas per loop
example loop inside Community.sol, Project.sol, HomeFiProxy.sol, Tasks.sol
for (uint256 i = 0; i < _length; i++)
See (this issue)[https://github.com/code-423n4/2022-01-xdefi-findings/issues/128] which describes the fact that there is a larger deployment gas cost, but with enough runtime calls, the change ends up being cheaper.
this issue exist inside Community.sol, Disputes.sol
require( _lendingNeeded >= _communityProject.totalLent && _lendingNeeded <= IProject(_project).projectCost(), "Community::invalid lending" );
If needed, the value can be read from the verified contract source code. Savings are due to the compiler not having to create non-payable getter functions for deployment calldata, and not adding another entry to the method ID table
example issue in Project.sol
uint256 public constant override VERSION = 25000;