Platform: Code4rena
Start Date: 26/05/2022
Pot Size: $75,000 USDT
Total HM: 31
Participants: 71
Period: 7 days
Judge: GalloDaSballo
Total Solo HM: 18
Id: 126
League: ETH
Rank: 32/71
Findings: 3
Award: $262.40
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: xiaoming90
Also found by: 0xNazgul, FSchmoede, Funen, Kumpa, VAD37, berndartmueller, cccz, kirk-baird
https://github.com/code-423n4/2022-05-vetoken/blob/main/contracts/Booster.sol#L219-L241
Function setFees()
only checks that the total fees are <= MaxFees
. There is no individual value range validity of each fee being set.
Manual Review
Each fee input parameter updated in setFees()
should have it's own value range checks to ensure their validity.
#0 - jetbrain10
2022-06-15T16:19:46Z
same as #215
#1 - GalloDaSballo
2022-07-24T22:05:37Z
Dup of #215
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0x29A, 0xDjango, 0xNazgul, 0xf15ers, BouSalman, Chom, Deivitto, Dravee, ElKu, FSchmoede, Funen, GimelSec, Hawkeye, MiloTruck, Picodes, SecureZeroX, SmartSek, TerrierLover, WatchPug, _Adam, asutorufos, berndartmueller, c3phas, catchup, cccz, cogitoergosumsw, cryptphi, csanuragjain, delfin454000, dipp, ellahi, gzeon, hansfriese, horsefacts, hyh, kirk-baird, minhquanym, oyc_109, pauliax, reassor, robee, sashik_eth, shenwilly, simon135, sorrynotsorry, sseefried, unforgiven, xiaoming90, z3s
110.3392 USDT - $110.34
Severity: Low
Context: VeAssetDepositor.sol#L53-L57
, VeAssetDepositor.sol#L59-L66
, Booster.sol#L123-L127
, Booster.sol#L129-L133
, Booster.sol#L135-L139
, Booster.sol#L141-L160
, Booster.sol#L162-L166
, Booster.sol#L168-L172
, Booster.sol#L174-L190
, Booster.sol#L193-L217
, Booster.sol#L219-L241
, Booster.sol#L243-L247
, VeTokenMinter.sol#L32-L46
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: Booster.sol#L193-L217
, Booster.sol#L219-L241
, VeTokenMinter.sol#L41-L46
Description: None of the onlyOwner functions that change critical protocol addresses/parameters appear to have a timelock 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 timelock to these functions for a time-delayed change to alert users and protect against possiable malicious changes by compromised owners(s).
Severity: Low
Context: VeAssetDepositor.sol#L53-L57
, Booster.sol#L123-L127
, Booster.sol#L129-L133
, Booster.sol#L135-L139
, Booster.sol#L141-L160
, Booster.sol#L162-L166
, Booster.sol#L168-L172
, VE3DRewardPool.sol#L114-L116
, VE3DRewardPool.sol#L118-L120
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: VE3DRewardPool.sol#L114-L116
, VE3DRewardPool.sol#L118-L120
, VoterProxy.sol#L62-L89
, VeTokenMinter.sol#L32-L46
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.
Severity: Informational
Context: VeAssetDepositor.sol#L93 (ammount => amount)
, VeAssetDepositor.sol#L126 (isnt => isn't)
, Booster.sol#L31 (platoform => platform)
, Booster.sol#L363 (seperate => separate)
, Booster.sol#L414 (seperate => separate)
, VE3dRewardPool.sol#L204 (dont => don't)
Description: Spelling errors in comments can cause confusion to both users and developers.
Recommendation: Check all misspellings to ensure they are corrected.
SafeMath.sol
With ^0.8.0
Severity: Informational
Context: All Contracts
Description:
There is no need of SafeMath.sol
in ^0.8.0
.
Recommendation:
Remove the use of SafeMath.sol
for it is unneeded with 0.8.0
and up
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.
#0 - GalloDaSballo
2022-07-06T23:27:32Z
NC
Disagree as you can't prove there's no timelock
Valid Low
Valid NC
##Â Spelling Errors Valid Refactoring
Valid Refactoring (version is correct, no risk)
Valid NC
Neat report
1L, 2R, 3NC
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0x29A, 0xKitsune, 0xNazgul, 0xf15ers, 0xkatana, Cityscape, Dravee, ElKu, FSchmoede, Funen, GalloDaSballo, Hawkeye, Kaiziron, MiloTruck, Randyyy, RoiEvenHaim, Ruhum, SecureZeroX, SmartSek, TerrierLover, TomJ, Tomio, WatchPug, Waze, _Adam, asutorufos, c3phas, catchup, cogitoergosumsw, delfin454000, ellahi, fatherOfBlocks, gzeon, hansfriese, horsefacts, jonatascm, minhquanym, oyc_109, pauliax, reassor, robee, sach1r0, saian, sashik_eth, simon135, z3s
52.4549 USDT - $52.45
++index
instead of index++
to increment a loop counterContext: Booster.sol#L325-L342
, BaseRewardPool.sol#L172-L187
, BaseRewardPool.sol#L195-L212
, BaseRewardPool.sol#L214-L233
, BaseRewardPool.sol#L239-L261
, BaseRewardPool.sol#L267-L287
, VE3DRewardPool.sol#L146-L164
, VE3DRewardPool.sol#L209-L226
, VE3DRewardPool.sol#L233-L250
, VE3DRewardPool.sol#L252-L269
, VE3DRewardPool.sol#L275-L330 (For both)
, VoterProxy.sol#L207-L222
Description:
Due to reduced stack operations, using ++index
saves 5 gas per iteration.
Recommendation:
Use ++index
to increment a loop counter.
Context: Booster.sol#L325-L342
, BaseRewardPool.sol#L172-L187
, BaseRewardPool.sol#L195-L212
, BaseRewardPool.sol#L214-L233
, BaseRewardPool.sol#L239-L261
, BaseRewardPool.sol#L267-L287
, VE3DRewardPool.sol#L146-L164
, VE3DRewardPool.sol#L275-L330 (For L281)
, VoterProxy.sol#L207-L222
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: Booster.sol#L325-L342
, BaseRewardPool.sol#L172-L187
, BaseRewardPool.sol#L195-L212
, BaseRewardPool.sol#L214-L233
, BaseRewardPool.sol#L239-L261
, BaseRewardPool.sol#L267-L287
, VE3DRewardPool.sol#L146-L164
, VE3DRewardPool.sol#L209-L226
, VE3DRewardPool.sol#L233-L250
, VE3DRewardPool.sol#L252-L269
, VE3DRewardPool.sol#L275-L330 (For both)
, VoterProxy.sol#L207-L222
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; i = unchecked_inc(i)) { // do something that doesn't change the value of i } function unchecked_inc(uint i) returns (uint) { unchecked { return i + 1; } }
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.
require()
, Use != 0
Instead of > 0
With Uint ValuesContext: VeAssetDepositor.sol#L127-L167
, BaseRewardPool.sol#L172-L187
, BaseRewardPool.sol#L195-L212
, BaseRewardPool.sol#L214-L233
, VE3DRewardPool.sol#L209-L226
, VE3DRewardPool.sol#L233-L250
, VE3DRewardPool.sol#L252-L269
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.
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.
#0 - GalloDaSballo
2022-07-14T01:48:34Z
Saves 1k at most