Platform: Code4rena
Start Date: 20/09/2022
Pot Size: $30,000 USDC
Total HM: 12
Participants: 198
Period: 3 days
Judge: 0xean
Total Solo HM: 2
Id: 164
League: ETH
Rank: 56/198
Findings: 3
Award: $60.12
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Czar102
Also found by: 0xDecorativePineapple, 0xNazgul, 0xSky, 0xbepresent, 0xmatt, Atarpara, Bahurum, DimitarDimitrov, Franfran, GimelSec, JGcarv, JLevick, Junnon, OptimismSec, Rolezn, Ruhum, Soosh, Tomo, Trust, __141345__, adriro, ajtra, bin2chen, cRat1st0s, cccz, cryptonue, d3e4, innertia, jag, joestakey, neumo, obront, pashov, pauliax, pcarranzav, peanuts, rajatbeladiya, rbserver, reassor, seyni, wagmi, zzykxx, zzzitron
0.7375 USDC - $0.74
The mintableSupply
can be set during deployment to any number or 0. If set to 0 it is meant to be minted at will. If set to anything > 0
, it is meant to only mint that supply. However, if mintableSupply
is > 0
and it gets fully minted, mintableSupply
is now = 0
making it possible to mint at will. This goes against the design logic.
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
Manual Review
Consider adding a bool
flag to be set on deployment so that if the deployer can choose either a mint at will token or a token with a mintableSupply
.
#0 - 0xean
2022-09-24T00:37:35Z
dupe of #3
🌟 Selected for report: AkshaySrivastav
Also found by: 0v3rf10w, 0x040, 0x1f8b, 0x4non, 0x5rings, 0x85102, 0xA5DF, 0xDecorativePineapple, 0xNazgul, 0xSky, 0xSmartContract, 0xbepresent, 0xf15ers, 0xmatt, 2997ms, Aeros, Aymen0909, B2, Bahurum, Bnke0x0, CertoraInc, Chom, ChristianKuri, CodingNameKiki, Deivitto, Diana, Diraco, Dravee, ElKu, Funen, IllIllI, JC, JLevick, JohnSmith, JohnnyTime, KIntern_NA, Lambda, Margaret, MasterCookie, OptimismSec, RaymondFam, Respx, ReyAdmirado, RockingMiles, Rohan16, Rolezn, Ruhum, RustyRabbit, Sm4rty, SooYa, StevenL, TomJ, Tomo, V_B, Waze, Yiko, __141345__, a12jmx, ajtra, ak1, async, ayeslick, aysha, berndartmueller, bin2chen, bobirichman, brgltd, bulej93, c3phas, carrotsmuggler, cccz, ch13fd357r0y3r, chatch, cryptostellar5, cryptphi, csanuragjain, d3e4, datapunk, delfin454000, dic0de, djxploit, durianSausage, eighty, erictee, exd0tpy, fatherOfBlocks, gogo, got_targ, hansfriese, ignacio, ikbkln, indijanc, innertia, joestakey, karanctf, ladboy233, leosathya, lukris02, martin, medikko, millersplanet, nalus, natzuu, neko_nyaa, neumo, obront, oyc_109, pcarranzav, peanuts, pedr02b2, pedroais, peiw, peritoflores, prasantgupta52, rajatbeladiya, rbserver, reassor, ret2basic, rokinot, romand, rotcivegaf, rvierdiiev, sach1r0, seyni, sikorico, slowmoses, sorrynotsorry, supernova, tibthecat, tnevler, ubermensch, yongskiws, zzykxx, zzzitron
50.293 USDC - $50.29
Severity: Informational
Context: VTVLVesting.sol
Description: Elastic supply tokens could dynamically adjust their price, supply, user's balance, etc. Such a mechanism makes a DeFi system complex, while many security accidents are caused by the elastic tokens. For example, a DEX using deflationary token must double check the token transfer amount when taking swap action because of the difference of actual transfer amount and parameter.
Recommendation: In terms of confidentiality, integrity and availability, it is highly recommend that one should not use elastic supply tokens & weird-ERC20 tokens.
Severity Low
Context: VTVLVesting.sol#L217
, VTVLVesting.sol#L371
, VTVLVesting.sol#L436
Description: Downcasting from uint256/int256 in Solidity does not revert on overflow. This can easily result in undesired exploitation or bugs.
Recommendation: Consider using SafeCast library from OpenZeppelin.
Severity: Low
Context: AccessProtected.sol#L39
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: Informational
Context: VTVLVesting.sol#L364
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: VariableSupplyERC20Token.sol#L19
, VariableSupplyERC20Token.sol#L21
, VariableSupplyERC20Token.sol#L25
, VariableSupplyERC20Token.sol#L49
, AccessProtected.sol#L9
, VTVLVesting.sol#L34
, VTVLVesting.sol#L36
, VTVLVesting.sol#L69
, VTVLVesting.sol#L88
, VTVLVesting.sol#L165
, VTVLVesting.sol#L169
, VTVLVesting.sol#L173-L174
, VTVLVesting.sol#L176
, VTVLVesting.sol#L184-L185
, VTVLVesting.sol#L202
, VTVLVesting.sol#L212
, VTVLVesting.sol#L235
, VTVLVesting.sol#L240-L241
, VTVLVesting.sol#L256
, VTVLVesting.sol#L260-L262
, VTVLVesting.sol#L266
, VTVLVesting.sol#L269
, VTVLVesting.sol#L294-L295
, VTVLVesting.sol#L312-L313
, VTVLVesting.sol#L326
, VTVLVesting.sol#L330
, VTVLVesting.sol#L354
, VTVLVesting.sol#L357
, VTVLVesting.sol#L369
, VTVLVesting.sol#L432
, VTVLVesting.sol#L447
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: VTVLVesting.sol#L50
, VTVLVesting.sol#L53
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: AccessProtected.sol#L24
, VTVLVesting.sol#L32
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: FullPremintERC20Token.sol#L9
, VTVLVesting.sol#L114-L115
, VTVLVesting.sol#L133
, VTVLVesting.sol#L136-L138
Description: There is commented code that makes the code messy and unneeded.
Recommendation: Consider removing the commented out code.
Severity: Informational
Context: VTVLVesting.sol#L266
Description: There should never be any TODOs in the code when deploying.
Recommendation: Consider finishing the TODOs before deploying.
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: VariableSupplyERC20Token.sol
Description: Contracts should be deployed with the same compiler version and flags that they have been tested with thoroughly. Locking the pragma helps to ensure that contracts do not accidentally get deployed using, for example, an outdated compiler version that might introduce bugs that affect the contract system negatively.
Recommendation: Consider locking the pragma version.
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: IllIllI
Also found by: 0v3rf10w, 0x040, 0x1f8b, 0x4non, 0x85102, 0xA5DF, 0xDanielC, 0xNazgul, 0xSmartContract, 0xbepresent, 0xc0ffEE, 0xsam, 2997ms, AkshaySrivastav, Amithuddar, Atarpara, Aymen0909, B2, Bnke0x0, CertoraInc, Chom, ChristianKuri, CodingNameKiki, Deivitto, Diana, DimitarDimitrov, Diraco, Funen, JC, JLevick, JohnSmith, Junnon, KIntern_NA, Lambda, MasterCookie, Matin, Noah3o6, Ocean_Sky, OptimismSec, RaymondFam, Respx, ReyAdmirado, RockingMiles, Rohan16, Rolezn, Ruhum, Saintcode_, Satyam_Sharma, Sm4rty, SnowMan, SooYa, Sta1400, StevenL, Tadashi, Tagir2003, TomJ, Tomio, Tomo, V_B, Waze, WilliamAmbrozic, Yiko, __141345__, a12jmx, adriro, ajtra, ak1, async, aysha, beardofginger, bobirichman, brgltd, bulej93, c3phas, carrotsmuggler, caventa, ch0bu, cryptostellar5, cryptphi, csanuragjain, d3e4, delfin454000, dharma09, djxploit, durianSausage, eighty, emrekocak, erictee, exd0tpy, fatherOfBlocks, francoHacker, gianganhnguyen, gogo, got_targ, hxzy, ignacio, ikbkln, imare, indijanc, jag, jpserrat, karanctf, ladboy233, leosathya, lucacez, lukris02, m9800, malinariy, martin, medikko, mics, millersplanet, mrpathfindr, nalus, natzuu, neko_nyaa, oyc_109, pauliax, peanuts, pedroais, peiw, pfapostol, prasantgupta52, rbserver, ret2basic, rokinot, rotcivegaf, rvierdiiev, sach1r0, samruna, seyni, slowmoses, subtle77, supernova, tgolding55, tibthecat, tnevler, w0Lfrum, yaemsobak, zishansami
9.0896 USDC - $9.09
Context: VTVLVesting.sol#L436
Description: This imports are unneeded because they are imported from another contract.
Recommendation: Consider removing the the extra imports.
Context: VTVLVesting.sol#L436
Description:
The event ClaimRevoked()
takes uint256 revocationTimestamp
but when the event is emitted uint40(block.timestamp)
is used, which does a pointless casting uint256 -> uint40 -> uint256
.
Recommendation:
Consider just emitting block.timestamp
.
Context: VTVLVesting.sol#L27
Description: It's cheaper to skip initialization of state variables to their default values.
Recommendation: Consider skipping the initialization of these listed variable.
++index
instead of index++
to increment a loop counterContext: VTVLVesting.sol#L353
Description:
Due to reduced stack operations, using ++index
saves 5 gas per iteration.
Recommendation:
Use ++index
to increment a loop counter.
Context: VTVLVesting.sol#L353
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.
require()
, Use != 0
Instead of > 0
With Uint ValuesContext: FullPremintERC20Token.sol#L11
, VariableSupplyERC20Token.sol#L27
, VariableSupplyERC20Token.sol#L31
, VariableSupplyERC20Token.sol#L40
, VTVLVesting.sol#L107
, VTVLVesting.sol#L256-L257
, VTVLVesting.sol#L263
, VTVLVesting.sol#L272-L273
, VTVLVesting.sol#L449
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: 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.