Platform: Code4rena
Start Date: 01/07/2022
Pot Size: $75,000 USDC
Total HM: 17
Participants: 105
Period: 7 days
Judge: Jack the Pug
Total Solo HM: 5
Id: 143
League: ETH
Rank: 36/105
Findings: 2
Award: $147.37
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0v3rf10w, 0x1f8b, 0x29A, 0xDjango, 0xNazgul, 0xNineDec, 0xdanial, 0xf15ers, Bnke0x0, Ch_301, Chandr, Chom, Funen, GimelSec, Hawkeye, JC, Kaiziron, Lambda, Meera, MiloTruck, Noah3o6, Picodes, ReyAdmirado, Rohan16, Sm4rty, TerrierLover, TomJ, Waze, _Adam, __141345__, asutorufos, aysha, berndartmueller, brgltd, cccz, codexploder, defsec, delfin454000, djxploit, durianSausage, fatherOfBlocks, hake, horsefacts, hubble, jayfromthe13th, joestakey, jonatascm, m_Rassska, oyc_109, pashov, rajatbeladiya, rbserver, robee, sach1r0, sahar, samruna, simon135, svskaushik, zzzitron
109.1272 USDC - $109.13
Severity: Low
Context: JBProjects.sol#L179-L184
, JBOperatorStore.sol#L109-L123
, JBDirectory.sol#L211-L342
, JBPayoutRedemptionPaymentTerminal.sol#L622-L666
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: This may hinder detecting discrepancies between on-chain and off-chain states leading to flawed assumptions of on-chain state and protocol behavior.
Severity: Low
Context: JBTokenStore.sol#L160-L166
, JBController.sol#L369-L382
, JBPayoutRedemptionPaymentTerminal.sol#L283-L311
, JBSingleTokenPaymentTerminalStore.sol#L276-L284
Description: Lack of zero-address validation on address parameters may lead to transaction reverts, waste gas, require resubmission of transactions and may even force contract redeployments in certain cases within the protocol.
Recommendation: Add explicit zero-address validation on input parameters of address type.
Severity: Low
Context: IJBPriceFeed.sol#L5
Description:
The function currentPrice()
calls Chainlink's latestRoundData which might return stale/incomplete results which get used in the protocol.Prices from historical or Incomplete Chainlink rounds may allow stale data to be used in the protocol.
Recommendation: Consider adding validation checks on return values of latestRoundData.
Severity Informational
Context: IJBController.sol#L19-L21
, IJBETHERC20ProjectPayerDeployer.sol#L8-L19
, IJBETHERC20SplitsPayerDeployer.sol#L8-L22
, IJBSplitsPayer.sol#L15-L27
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: JBFundingCycleStore.sol#L47 (instrinsic => intrinsic)
, JBProjects.sol#L84 (adherance => adherence)
, JBSplitsStore.sol#218 (extention => extension)
, JBDirectory.sol#L206 (allowedlisted => allowlisted)
, JBController.sol#L28 (preconfifigured => preconfigured)
, JBController.sol#L29 (adherance => adherence)
, JBController.sol#L341 (adherance => adherence)
, JBController.sol#L898 (dont => do not)
, JBPayoutRedemptionPaymentTerminal.sol#L247 (adherance => adherence)
, JBPayoutRedemptionPaymentTerminal.sol#L799 (incure => incur)
, JBPayoutRedemptionPaymentTerminal.sol#L837 (convinience => convenience)
, JBPayoutRedemptionPaymentTerminal.sol#L948 (convinience => convenience)
, JBPayoutRedemptionPaymentTerminal.sol#L1019 (substracting => subtracting)
, JBPayoutRedemptionPaymentTerminal.sol#L1077 (prefered => preferred)
, JBPayoutRedemptionPaymentTerminal.sol#L1116 (prefered => preferred)
, JBPayoutRedemptionPaymentTerminal.sol#L1470 (guage => gauge)
, JBSingleTokenPaymentTerminalStore.sol#L384 (mumber => number)
, JBSingleTokenPaymentTerminalStore.sol#L452 (areference => a reference)
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: Using very old versions of Solidity prevents benefits of bug fixes and newer security checks. Using the latest versions might make contracts susceptible to undiscovered compiler bugs.
Recommendation: Consider using the most recent version.
🌟 Selected for report: 0xA5DF
Also found by: 0v3rf10w, 0x09GTO, 0x1f8b, 0x29A, 0xDjango, 0xKitsune, 0xNazgul, 0xdanial, 0xf15ers, Aymen0909, Bnke0x0, Ch_301, Cheeezzyyyy, Chom, ElKu, Funen, Hawkeye, IllIllI, JC, JohnSmith, Kaiziron, Lambda, Limbooo, Meera, Metatron, MiloTruck, Noah3o6, Picodes, Randyyy, RedOneN, ReyAdmirado, Rohan16, Saintcode_, Sm4rty, TomJ, Tomio, Tutturu, UnusualTurtle, Waze, _Adam, __141345__, ajtra, apostle0x01, asutorufos, brgltd, c3phas, cRat1st0s, codexploder, defsec, delfin454000, djxploit, durianSausage, exd0tpy, fatherOfBlocks, hake, horsefacts, ignacio, jayfromthe13th, joestakey, jonatascm, kaden, kebabsec, m_Rassska, mektigboy, mrpathfindr, oyc_109, rajatbeladiya, rbserver, rfa, robee, sach1r0, sashik_eth, simon135
38.2406 USDC - $38.24
Context: JBFundingCycleStore.sol#L724-L734
, JBSplitsStore.sol#L204-L276 (For all three)
, JBSplitsStore.sol#L304-L335
, JBOperatorStore.sol#L85-L92
, JBOperatorStore.sol#L135-L149
, JBOperatorStore.sol#L165-L173
, JBDirectory.sol#L139-L142
, JBDirectory.sol#L167-L170
, JBDirectory.sol#L275-L277 (for Both)
, JBController.sol#L913-L967
, JBController.sol#L1014-L1054
, JBSingleTokenPaymentTerminalStore.sol#L862-L863
Description:
(This is only relevant if you are using the default solidity checked arithmetic). i++
involves checked arithmetic, which is not required. This is because the value of i
is always strictly less than length <= 2**256 - 1. Therefore, the theoretical maximum value of i
to enter the for-loop body is 2**256 - 2
. This means that the i++
in the for loop can never overflow. Regardless, the overflow checks are performed by the compiler.
Unfortunately, the Solidity optimizer is not smart enough to detect this and remove the checks. One can manually do this by:
for (uint i = 0; i < length;) { // do something that doesn't change the value of i unchecked { ++i; } }
Note that it’s important that the call to unchecked_inc
is inlined. This is only possible for solidity versions starting from 0.8.2
.
Recommendation: The increment in the for loop post condition can be made unchecked.
Context: JBSplitsStore.sol#L204-L276 (For all three)
, JBOperatorStore.sol#L85-L92
, JBOperatorStore.sol#L135-L149
, JBOperatorStore.sol#L165-L173
, JBDirectory.sol#L139-L142
, JBDirectory.sol#L167-L170
, JBDirectory.sol#L275-L277 (for Both)
, JBController.sol#L913-L967
, JBController.sol#L1014-L1054
, JBPayoutRedemptionPaymentTerminal.sol#L1008-L1173
, JBSingleTokenPaymentTerminalStore.sol#L862-L863
Description: One can save gas by caching the array length (in stack) and using that set variable in the loop. Replace state variable reads and writes within loops with local variable reads and writes. This is done by assigning state variable values to new local variables, reading and/or writing the local variables in a loop, then after the loop assigning any changed local variables to their equivalent state variables.
Recommendation:
Simply do something like so before the for loop: uint length = variable.length
. Then add length
in place of variable.length
in the for loop.
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.