Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

enfrasico - Deposits cannot be made when there is no limit for totalSupply and per wallet limit #665

Closed
sherlock-admin2 opened this issue Aug 30, 2023 · 11 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Escalation Resolved This issue's escalations have been approved/rejected Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Aug 30, 2023

enfrasico

medium

Deposits cannot be made when there is no limit for totalSupply and per wallet limit

Summary

Deposits cannot be made due to overflow when tsLimit == uint256.max && walletLimit == uint256.max as _maxMint returns uint256.max under these conditions.

Vulnerability Detail

The code flow will look like this when a user tries to deposit.

  1. deposit() is called
  2. It calls maxDeposit() to check if the assets currently deposited is more than what the user can deposit at maximum
  3. maxDeposit() calls convertToAssets() which calls _maxMint()
  4. _maxMint() returns uint256.max when tsLimit == uint256.max && walletLimit == uint256.max
  5. Overflow happens at convertToAssets() since uint256.max cannot be multiplied with any number > 0

Impact

Deposits cannot be made by users when we want to set no limits for total supply and per wallet supply.

Code Snippet

https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/vault/LMPVault.sol#L936-L938

Tool used

Manual Review

Recommendation

Consider this special case for when we want do not want to restrict total supply and per wallet supply.

Duplicate of #577

@github-actions github-actions bot added the Excluded Excluded by the judge without consulting the protocol or the senior label Sep 11, 2023
@sherlock-admin2
Copy link
Contributor Author

1 comment(s) were left on this issue during the judging contest.

Trumpero commented:

low, totalSupplyLimit and perWalletLimit will be set by the admin (in the constructor and setter function). The deposit() function is disabled until these parameters are set, and it does not cause any loss

@sherlock-admin sherlock-admin changed the title Lucky Magenta Squid - Deposits cannot be made when there is no limit for totalSupply and per wallet limit enfrasico - Deposits cannot be made when there is no limit for totalSupply and per wallet limit Oct 3, 2023
@sherlock-admin sherlock-admin added the Non-Reward This issue will not receive a payout label Oct 3, 2023
@yixxas
Copy link

yixxas commented Oct 3, 2023

Escalate

This is a valid medium. This is a bug in core functionality. It is true that totalSupplyLimit and perWalletLimit are set by the admin, but it is part of the Tokemak's specification that these values are set to uint256.max if the protocol wants to allow unlimited supply or unlimited wallet. But setting these values to such will prevent deposit() from being callable and hence users cannot mint shares with deposit().

@sherlock-admin2
Copy link
Contributor Author

Escalate

This is a valid medium. This is a bug in core functionality. It is true that totalSupplyLimit and perWalletLimit are set by the admin, but it is part of the Tokemak's specification that these values are set to uint256.max if the protocol wants to allow unlimited supply or unlimited wallet. But setting these values to such will prevent deposit() from being callable and hence users cannot mint shares with deposit().

You've created a valid escalation!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

@sherlock-admin sherlock-admin added the Escalated This issue contains a pending escalation label Oct 3, 2023
@nevillehuang
Copy link

nevillehuang commented Oct 5, 2023

Escalate

#465, #503 and #731 are duplicates of this issue

@xiaoming9090
Copy link
Collaborator

This issue should be valid and fixed. An overflow could occur if the admin decided to set it to "no limit".

@sherlock-admin2
Copy link
Contributor Author

Escalate

#465, #503 and #731 are duplicates of this issue

You've created a valid escalation!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

@Trumpero
Copy link
Collaborator

Trumpero commented Oct 9, 2023

I understand that this is a valid issue and needs to be fixed, but I believe it should be a low issue. It doesn't cause any loss of funds since users are unable to deposit any funds in this case. It can't break the protocol, as the admin is able to set a new configuration and resolve it (they can config a very large value for perWalletLimit, such as type(uint128).max, instead of type(uint256).max). Therefore, I believe the impact of this issue is low and doesn't meet the requirements of a medium issue.

@Evert0x
Copy link
Contributor

Evert0x commented Oct 23, 2023

I believe this issue falls into the following category

https://docs.sherlock.xyz/audits/judging/judging#vii.-list-of-issue-categories-that-are-not-considered-valid

Issues that cause minor inconvenience to users where there is no material loss of funds are not considered valid. Funds are temporarily stuck and can be recovered by the administrator or owner. Also, if a submission is a design opinion/suggestion without any clear indications of loss of funds is not a valid issue.

Planning to reject escalation and keep invalid

@Evert0x
Copy link
Contributor

Evert0x commented Oct 26, 2023

Result:
Invalid
Unique

@sherlock-admin2
Copy link
Contributor Author

sherlock-admin2 commented Oct 26, 2023

Escalations have been resolved successfully!

Escalation status:

@sherlock-admin sherlock-admin removed the Escalated This issue contains a pending escalation label Oct 26, 2023
@sherlock-admin2 sherlock-admin2 added the Escalation Resolved This issue's escalations have been approved/rejected label Oct 26, 2023
@yixxas
Copy link

yixxas commented Oct 26, 2023

Hi @Evert0x, I believe there is a mistake here, and would like to request for a re-review. According to Trumpero's comment, and I quote, "admin is able to set a new configuration and resolve it (they can config a very large value for perWalletLimit, such as type(uint128).max", but this directly contradicts the specification of ERC-4626.

If we look at ERC4626's specification for maxDeposit, Screenshot 2023-10-26 at 5 31 19 PM

Specifically, if there is no limit for the maximum amount of assets to be deposited, the vault MUST return 2**256 - 1. The protocol cannot simply set the value to any other value since Tokemak's vault is intended to be integrated with other protocols. Furthermore, it is part of the contest's README that explicitly requires the vault to be ERC-4626 compliant.

@Evert0x Evert0x added the Medium A valid Medium severity issue label Oct 31, 2023
@sherlock-admin sherlock-admin added Reward A payout will be made for this issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label and removed Non-Reward This issue will not receive a payout Excluded Excluded by the judge without consulting the protocol or the senior labels Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Escalation Resolved This issue's escalations have been approved/rejected Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

7 participants