VTVL contest - DimitarDimitrov's results

Building no-code token management tools to empower web3 founders and investors, starting with token vesting.

General Information

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

VTVL

Findings Distribution

Researcher Performance

Rank: 154/198

Findings: 2

Award: $9.83

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2022-09-vtvl/blob/f68b7f3e61dad0d873b5b5a1e8126b839afeab5f/contracts/token/VariableSupplyERC20Token.sol#L36-L46

Vulnerability details

Impact

Check in mint() can broke.

For example: if mintableSupply = 100 and amount = 100. This mean only 100 tokens can be minted(mintableSupply = 100). So if check(40line) pass, require also and mintableSupply now is = 0. Now admin can mint infinity tokons.

Proof of Concept

https://github.com/code-423n4/2022-09-vtvl/blob/f68b7f3e61dad0d873b5b5a1e8126b839afeab5f/contracts/token/VariableSupplyERC20Token.sol#L36-L46

Tools Used

code analytics

Move _mint(account, amount); inside if(mintableSupply > 0). Create new var mintWithNoLimit. Create another if if(mintWithNoLimit) and mint in second if.

#0 - 0xean

2022-09-23T23:51:56Z

dupe of #3

Awards

9.086 USDC - $9.09

Labels

bug
G (Gas Optimization)

External Links

1. There are many places where require is used.

https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/AccessProtected.sol#L25 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/AccessProtected.sol#L40 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L82 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L107 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L111 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L129 https://github.com/code-423n4/2022-09-vtvl/blob/f68b7f3e61dad0d873b5b5a1e8126b839afeab5f/contracts/VTVLVesting.sol#L255-L257 https://github.com/code-423n4/2022-09-vtvl/blob/f68b7f3e61dad0d873b5b5a1e8126b839afeab5f/contracts/VTVLVesting.sol#L262-L264 https://github.com/code-423n4/2022-09-vtvl/blob/f68b7f3e61dad0d873b5b5a1e8126b839afeab5f/contracts/VTVLVesting.sol#L270-L278 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L295 https://github.com/code-423n4/2022-09-vtvl/blob/f68b7f3e61dad0d873b5b5a1e8126b839afeab5f/contracts/VTVLVesting.sol#L344-L351 https://github.com/code-423n4/2022-09-vtvl/blob/f68b7f3e61dad0d873b5b5a1e8126b839afeab5f/contracts/VTVLVesting.sol#L374 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L402 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L426 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/token/FullPremintERC20Token.sol#L11 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/token/VariableSupplyERC20Token.sol#L27 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/token/VariableSupplyERC20Token.sol#L41

Optimize this using revert and custom errors combination. This will save a lot of gas.

2. Use memory instead storage:

https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L106 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L124 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L197

Special case: https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L367 if this become Claim memory usrClaim = claims[_msgSender()]; this https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L381 should become claims[_msgSender()].amountWithdrawn += amountRemaining;

Same for: https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L420

3. Can use calldata instead memory

https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L147 https://github.com/code-423n4/2022-09-vtvl/blob/f68b7f3e61dad0d873b5b5a1e8126b839afeab5f/contracts/VTVLVesting.sol#L334-L340 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/token/VariableSupplyERC20Token.sol#L21

4. Good practice

4.1. Use one version of solidity compiler

https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/AccessProtected.sol#L2 0.8.14 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/VTVLVesting.sol#L2 0.8.14 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/token/FullPremintERC20Token.sol#L2 0.8.14 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/token/VariableSupplyERC20Token.sol#L2 ^0.8.14

Migrate all to 0.8.14

4.2. Do not copy code

https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/AccessProtected.sol#L17-L18

In this case you can use setAdmin(_msgSender(), true);

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter