code-423n4 / 2023-07-pooltogether-findings

12 stars 7 forks source link

deposit function does not check for the `maxMint` amount. #458

Open code423n4 opened 12 months ago

code423n4 commented 12 months ago

Lines of code

https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L407-L415

Vulnerability details

Impact

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

Proof of Concept

The deposit function has a check for maxDeposit and reverts if the deposit value is more than max(uint96). 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 max(uint96) and if the vault is under-collateralised, the ratio of _assetUnit to _exchangeRate is greater than or equal to 2, then the calculation in _convertToShares:

_assets.mulDiv(_assetUnit, _exchangeRate, _rounding); could return a value more than the maxMint amount. This is possible in those scenarios where the _assetUnit is a big enough number (possible, as there is no limit on the decimals of the underlying asset, and _assetUnit = 10 ** super.decimals()) and the Vault is severely under-collateralized.

Tools Used

Manual Review

Recommended Mitigation Steps

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

Assessed type

Invalid Validation

c4-sponsor commented 11 months ago

asselstine marked the issue as sponsor confirmed

c4-judge commented 11 months ago

Picodes marked the issue as satisfactory

c4-judge commented 11 months ago

Picodes marked the issue as primary issue

c4-judge commented 11 months ago

Picodes marked the issue as duplicate of #435

Picodes commented 11 months ago

See https://github.com/code-423n4/2023-07-pooltogether-findings/issues/435#issuecomment-1668221692

c4-judge commented 11 months ago

Picodes marked the issue as selected for report

PierrickGT commented 11 months ago

Fixed in the following PR: https://github.com/GenerationSoftware/pt-v5-vault/pull/11