Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In ERC20, TotalSupply is broken #108

Open
code423n4 opened this issue Jun 21, 2022 · 4 comments
Open

In ERC20, TotalSupply is broken #108

code423n4 opened this issue Jun 21, 2022 · 4 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/Plex-Engineer/lending-market/blob/ab31a612be354e252d72faead63d86b844172761/contracts/ERC20.sol#L33
https://github.com/Plex-Engineer/lending-market/blob/ab31a612be354e252d72faead63d86b844172761/contracts/ERC20.sol#L95

Vulnerability details

Impact

For an obscure reason as it’s not commented, _totalSupply is not initialized to 0, leading to an inaccurate total supply, which could easily break integrations, computations of market cap, etc.

Proof of Concept

If the constructor is called with _initialSupply = 1000, then 1000 tokens are minted. The total supply will be 2000.

Recommended Mitigation Steps

Remove _initialSupply.

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Jun 21, 2022
code423n4 added a commit that referenced this issue Jun 21, 2022
@tkkwon1998 tkkwon1998 added the sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue label Jun 22, 2022
@tkkwon1998
Copy link
Collaborator

The explanation is not clear. We can't seem to reproduce this issue as we can't find a scenario where the totalSupply function returns an incorrect value.

@Picodes
Copy link

Picodes commented Jun 24, 2022

@tkkwon1998 to clarify:

Deploy the ERC20 with totalSupply_ = 1000.

Then totalSupply() returns 1000, which is incorrect.

Then if someone mints 1000 tokens, there is 1000 tokens in the market but due to _totalSupply += amount;, totalSupply = 2000 which is still incorrect

@GalloDaSballo
Copy link
Collaborator

I believe the submission could have benefitted by:

  • A coded POC
  • Recognizing a revert due to the finding

However the finding is ultimately true in that, because totalSupply is a parameter passed in to the contract, and the ERC20 contract will not mint that amount, the totalSupply will end up not reflecting the total amounts of tokens minted.

For this reason, I believe the finding to be valid and High Severity to be appropriate.

I recommend the warden to err on the side of giving too much information to avoid getting their finding invalidated incorrectly

@GalloDaSballo
Copy link
Collaborator

After further thinking, I still believe the finding is of high severity as the ERC20 standard is also broken, I do believe the submission could have been better developed, however, I think High is in place here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

4 participants