Closed code423n4 closed 1 year ago
asselstine marked the issue as sponsor confirmed
Picodes marked the issue as satisfactory
This finding, https://github.com/code-423n4/2023-07-pooltogether-findings/issues/89 and https://github.com/code-423n4/2023-07-pooltogether-findings/issues/458 would all be mitigated by having the check at the _mint
level. Because of this I'll flag them as duplicates.
Picodes marked the issue as primary issue
Picodes marked issue #458 as primary and marked this issue as a duplicate of 458
I've moved the maxMint
check into the _mint
function in this PR: https://github.com/GenerationSoftware/pt-v5-vault/pull/11
There is also another edge case we need to check for.
When the Vault is partially collateralized, meaning users can withdraw their full deposit but there are not enough yield available in the YieldVault to back the amount of shares minted by mintYieldFee
, then the transaction should revert to avoid minting more shares and enter in an undercollateralization state.
This issue has been fixed in the following PR: https://github.com/GenerationSoftware/pt-v5-vault/pull/13
Lines of code
https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L394-L402
Vulnerability details
Impact
Theoretically, it is possible to mint more than the
maxMint
amount using themintYieldFee
function in theVault
contract.Proof of Concept
The functions in
Vault
contract likemint
,mintWithPermit
call the_beforeMint
function which checks whether_shares
are greater thanmaxMint
amount and reverts if it's indeed the case. But, themintYieldFee
amount does not check this. TheyieldFeeTotalSupply
is a unit256 which gets subtracted withshares
, but the maxMint only allows for uint96. So theoretically, it is possible to mint more shares than maxMint, because shares are a uint256 value, not uint96 in the function.But, there is a scenario where the protocol should be mindful. There is no limit on the decimals of the asset tokens that are used as the vaults can be created permissionless by anyone. And shares also have the same amount of decimals. So,
yieldFeeTotalSupply
could accumulate in amount (even if the underlying value is less) to be greater than max(uint96) value, which makes it possible for a share greater thanmaxMint
(max(uint96)) amount to be subtracted fromyieldFeeTotalSupply
and hence possible to mint shares greater than max(uint96) value.Tools Used
Manual review
Recommended Mitigation Steps
It is recommended that the protocol add the
maxMint
check in themintYieldFee
function.Assessed type
Invalid Validation