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

Deposit function does not check for the maxMint amount. #61

Closed
c4-bot-8 opened this issue Apr 11, 2024 · 3 comments
Closed

Deposit function does not check for the maxMint amount. #61

c4-bot-8 opened this issue Apr 11, 2024 · 3 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-501 grade-c QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax 🤖_61_group AI based duplicate group recommendation satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@c4-bot-8
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2024-04-panoptic/blob/833312ebd600665b577fbd9c03ffa0daf250ed24/contracts/CollateralTracker.sol#L417

Vulnerability details

Summary

The deposit function has a check for maxDeposit and reverts if the deposit value is more than type(uint104).max.

function maxDeposit(address) external pure returns (uint256 maxAssets) {
        return type(uint104).max;
    }

function deposit(uint256 assets, address receiver) external returns (uint256 shares) {
        if (assets > type(uint104).max) revert Errors.DepositTooLarge();
        //...
}

But, it does not check the shares to be less than maxMint amount and hence bypasses this check. Theoretically, if the assets are equal to type(uint104).max and if the vault is undercollateralised, then the calculation in convertToShares(type(uint104).max) * DECIMALS) / (DECIMALS + COMMISSION_FEE) could return a value more than the maxMint amount. This is possible in those scenarios where the asset has big number of decimals (README confirms it) and the Vault is severely under-collateralized.

Impact

It is theoretically possible for the deposit amount to mint shares more than the maxMint amount

Tools Used

Manual rewiew

Recommended Mitigation Steps

Include the maxMint check in the deposit function to prevent this problem.

Assessed type

ERC4626

@c4-bot-8 c4-bot-8 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Apr 11, 2024
c4-bot-8 added a commit that referenced this issue Apr 11, 2024
@c4-bot-11 c4-bot-11 added the 🤖_61_group AI based duplicate group recommendation label Apr 22, 2024
@c4-judge
Copy link
Contributor

Picodes marked the issue as duplicate of #553

@c4-judge
Copy link
Contributor

Picodes marked the issue as satisfactory

@c4-judge c4-judge added satisfactory satisfies C4 submission criteria; eligible for awards duplicate-501 and removed duplicate-553 labels Apr 29, 2024
@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels May 9, 2024
@c4-judge
Copy link
Contributor

c4-judge commented May 9, 2024

Picodes changed the severity to QA (Quality Assurance)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-501 grade-c QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax 🤖_61_group AI based duplicate group recommendation satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

4 participants