CollateralTracker::deposit()
does not account for the maximum amount of shares that can be minted
#410
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-501
edited-by-warden
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
Lines of code
https://github.com/code-423n4/2024-04-panoptic/blob/833312ebd600665b577fbd9c03ffa0daf250ed24/contracts/CollateralTracker.sol#L417-L440
Vulnerability details
Description
The
deposit()
function can mint more shares thanmaxMint()
. Aside from deviating the ERC4626 standard, it defeats the purpose of capping the shares to a limited number as calculated inmaxMint()
.deposit()
Even if there is a validation for depositing the maximum
assets
which istype(uint104).max
, it does not prevent the minting of more shares than themaxMint()
.Looking at the
previewDeposit()
function below (which is responsible for calculating the shares), the ratio oftotalSupply
andtotalAssets()
is in fact an "exchange rate" of assets to shares. WhentotalAssets()
drops way belowtotalSupply
, there is a possibility of minting shares more than its maximum limit. This scenario happens when the vault is gravely undercollateralized.previewDeposit()
Impact
ERC4626 standard is aimed to create a consistent implementation of tokenized vaults. By not conforming to it, breaks composability.
Proof of Concept
Tools Used
Manual Review
Recommended Mitigation Steps
Add validation to the
deposit()
function and usemaxMint()
as the limit.function deposit(uint256 assets, address receiver) external returns (uint256 shares) { if (assets > type(uint104).max) revert Errors.DepositTooLarge(); shares = previewDeposit(assets); + if (shares > maxMint()) revert Errors.SharesBeyondMaxLimit(); ... // mint collateral shares of the Panoptic Pool funds (this ERC20 token) _mint(receiver, shares); ... emit Deposit(msg.sender, receiver, assets, shares); }
Assessed type
ERC4626
The text was updated successfully, but these errors were encountered: