Platform: Code4rena
Start Date: 05/10/2022
Pot Size: $50,000 USDC
Total HM: 2
Participants: 80
Period: 5 days
Judge: GalloDaSballo
Id: 168
League: ETH
Rank: 55/80
Findings: 2
Award: $83.13
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0x4non
Also found by: 0x1f8b, 0xNazgul, 0xSmartContract, Deivitto, IllIllI, Lambda, RaymondFam, Rolezn, RustyRabbit, Trust, arcoun, bin2chen, brgltd, csanuragjain, d3e4, enckrish, exd0tpy, ladboy233, nicobevi, rbserver, rotcivegaf, simon135, zzykxx
50.4817 USDC - $50.48
Severity Low
Context: BlurExchange.sol#L246
Description: These functions doesn't have any checks to ensure that the variables being set is within some kind of value range.
Recommendation: Each variable input parameter updated should have it's own value range checks to ensure their validity.
Severity: Low
Context: ExecutionDelegate.sol#L36
, ExecutionDelegate.sol#L45
, BlurExchange.sol#L215
, BlurExchange.sol#L224
, BlurExchange.sol#L233
, BlurExchange.sol#L242
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: ExecutionDelegate.sol#L36
, ExecutionDelegate.sol#L45
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: Consider adding explicit zero-address validation on input parameters of address type.
Severity: Low
Context: ExecutionDelegate.sol#L36
, ExecutionDelegate.sol#L45
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: Consider adding events to functions that change critical parameters.
Severity: Low
Context: BlurExchange.sol#L95
Description: None of the initialize functions emit emit init-specific events. They all however have the initializer modifier (from Initializable) so that they can be called only once. Off-chain monitoring of calls to these critical functions is not possible.
Recommendation: It is recommended to emit events in your initialization functions.
Severity: Informational
Context: ExecutionDelegate.sol#L36
, ExecutionDelegate.sol#L45
, ExecutionDelegate.sol#L75
, ExecutionDelegate.sol#L90
, ExecutionDelegate.sol#L106
, ExecutionDelegate.sol#L121
Description: Visibility keyword should be before the list of modifiers as per best practice.
Recommendation: Consider moving the visibility keyword before the list of modifiers.
Severity Informational
Context: BlurExchange.sol#L57-L58
, MerkleVerifier.sol#L17
, MerkleVerifier.sol#L33
, MerkleVerifier.sol#L17
Description:
The linked variables do not conform to the standard naming convention of Solidity whereby functions and variable names(local and state) utilize the mixedCase
format unless variables are declared as constant
in which case they utilize the UPPER_CASE_WITH_UNDERSCORES
format. Private variables and functions should lead with an _underscore
.
Recommendation: Consider 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: ExecutionDelegate.sol#L21
, EIP712.sol#L112
, BlurExchange.sol#L35
Description: The best-practice layout for a contract should follow the following order: state variables, events, modifiers, constructor and functions. Function ordering helps readers identify which functions they can call and find constructor and fallback functions easier. Functions should be grouped according to their visibility and ordered as: constructor, receive function (if exists), fallback function (if exists), external, public, internal, private. Functions should then further be ordered with view functions coming after the non-view labeled ones.
Recommendation: Consider adopting recommended best-practice for code structure and layout.
Severity: Informational
Context: EIP712.sol#L24
, EIP712.sol#L27
, BlurExchange.sol#L124
, BlurExchange.sol#L205
, BlurExchange.sol#L388
, BlurExchange.sol#L425
, BlurExchange.sol#L429
Description: Max line length must be no more than 120 but many lines are extended past this length.
Recommendation: Consider cutting down the line length below 120.
Severity: Informational
Context: ReentrancyGuarded.sol#L10 (Can be private)
, EIP712.sol#L33
, EIP712.sol#L37
Description: There is missing visibility on some state variables that are default to public. It's best practice to explicityl mark visibility of state variables and can save gas depending on the marking.
Recommendation: Consider explicitly marking visibility of state.
Severity: Informational
Context: BlurExchange.sol#L53
Description: It's best practice that when there is an empty block, to add a comment in the block explaining why it's empty.
Recommendation:
Consider adding /* Comment on why */
to the empty blocks.
Severity Informational
Context: BlurExchange.sol#L134
, BlurExchange.sol#L183
Description: Some revert messages are unclear which can lead to confusion. Unclear revert messages may cause misunderstandings on reverted transactions.
Recommendation: Consider making revert messages more clear.
Severity: Informational
Context: BlurExchange.sol#L59
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.
ABIEncoderV2
With 0.8+
Severity: Informational
Context: ExecutionDelegate.sol
, BlurExchange.sol
Description:
ABIEncoderV2
is being stated in a solidity version 0.8+
which is not needed since ABIEncoderV2
is activated by default 0.8+
.
Recommendation:
Consider removing pragma experimental ABIEncoderV2;
.
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: Consider adding in full NatSpec comments for all functions to have complete code documentation for future use.
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.
#0 - GalloDaSballo
2022-10-22T20:30:26Z
L
NC
NC
NC
R for the internal / Public functions, disagree for name as they want to use it for a function
NC
NC
NC
Disputed as they have it for compatibility
NC
NC
NC
NC
NC
#1 - GalloDaSballo
2022-10-22T20:30:55Z
1L 1R 11NC
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0xNazgul, 0xSmartContract, Aymen0909, Heuss, Lambda, Pheonix, RaymondFam, ReyAdmirado, Ruhum, Shinchan, Shishigami, __141345__, adriro, ajtra, c3phas, ch0bu, cryptostellar5, d3e4, enckrish, gogo, halden, lucacez, mcwildy, medikko, neko_nyaa, pedr02b2, pfapostol, ret2basic, rvierdiiev, saian, sakman, sakshamguruji
32.6464 USDC - $32.65
uint
Instead of bool for reentrancyLock
Context: ReentrancyGuarded.sol
Description:
Use of a bool
for setting reentrancy to "lock" and "unlocked" costs more gas than using a uint
.
Recommendation:
Consider implementing a similar ReentrancyGuard
to solmates'
++index
instead of index++
to increment a loop counterContext: PolicyManager.sol#L77
, EIP712.sol#L77
, BlurExchange.sol#L199
, BlurExchange.sol#L476
, MerkleVerifier.sol#L38
Description:
Due to reduced stack operations, using ++index
saves 5 gas per iteration.
Recommendation:
Use ++index
to increment a loop counter.
Context: PolicyManager.sol#L77
, EIP712.sol#L77
, BlurExchange.sol#L199
, BlurExchange.sol#L476
, MerkleVerifier.sol#L38
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; } }
Recommendation: Consider doing the increment in the for loop post condition in an unchecked block.
Context: EIP712.sol#L77
, BlurExchange.sol#L199
, BlurExchange.sol#L476
, MerkleVerifier.sol#L38
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: To save some gas the use of custom errors leads to cheaper deploy time cost and run time cost. The run time cost is only relevant when the revert condition is met.
Recommendation: Use Custom Errors instead of strings.
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.
#0 - GalloDaSballo
2022-10-26T21:25:47Z
5k lock 150 rest
5150