veToken Finance contest - GalloDaSballo's results

Lock more veAsset permanently.

General Information

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

veToken Finance

Findings Distribution

Researcher Performance

Rank: 20/71

Findings: 2

Award: $990.30

๐ŸŒŸ Selected for report: 1

๐Ÿš€ Solo Findings: 0

Findings Information

๐ŸŒŸ Selected for report: GalloDaSballo

Also found by: IllIllI

Labels

bug
2 (Med Risk)
disagree with severity
sponsor acknowledged

Awards

937.187 USDT - $937.19

External Links

Lines of code

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L48

Vulnerability details

Impact

veTokenMinter allows any operator to mint new tokens, that's fine in the context of it being used for:

  • havingย VeAssetDepositor deposit for the user and mint
  • Having the Booster mint reward tokens

However because of the open ended system that allows any address to be set as operator, the system allows the admin to set themselves as the operator and to mint an excess amount of tokens, diluting other users.

Because this seems to be used exclusively by the VeAssetDepositor and the Booster hardcoding these two addresses would provide stronger security guarantees

Proof of Concept

addOperator(malicious, {"from": gov})

mint(malicious, AMOUNT, {"from": malicious})

Set the minters as immutable to provide stronger security guarantees

#0 - jetbrain10

2022-06-15T16:41:20Z

admin will be controlled by DAO to prevent this happen

#1 - GalloDaSballo

2022-07-25T00:31:25Z

Because am judging the contest am forfeiting any winnings.

I do believe that the system would be best if the minters where hardcoded (it would also save gas)

Make unchanged variable immutable | 2.1k gas

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/StashFactory.sol#L23

rewardFactory is never changed, making it immutable will save 2.1k gas for each time it is read for the first time. This type of gas saving is the biggest you can have.

Avoid setting default value to storage | 100 gas

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L110

In this constructor call you're setting isShutdown = false;, by default bool values will be false so this assignment will cost extra gas.

This used to save 800 gas but I believe it saves 100 gas now

Needless == true | 3 gas

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L110

Cache Array length | 3 gas per check

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L217

Cache var to avoid length check, this will save 3 gas per iteration

Use ++i or ideally unchecked

For loop iterations, you can save 3 gas with pre-increment and almost 20 gas per iteration with unchecked { ++i }

See an example of how to code it here: https://github.com/GalloDaSballo/badger-onchain-rewards/blob/ececa503bcc388786bf68d4e12601c834917ed67/contracts/RewardsManager.sol#L391

#0 - GalloDaSballo

2022-07-14T02:04:34Z

Saves 2.1k rest is poorly developed

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