Closed sherlock-admin3 closed 1 month ago
1 comment(s) were left on this issue during the judging contest.
Honour commented:
Invalid: design choice.
This is invalid, the computations are correct, and misses the root cause of incorrect decimal offset and lack of virtual shares that allows first depositor inflation attacks
Escalate, This is dup of #141
NoOne
High
Share Inflation Vulnerability in
_convertToSharesWithTotals
and_convertToAssetsWithTotals
Summary
The vulnerability is located in the CuratedVaultGetters.sol .sol contract within the
_convertToSharesWithTotals
and_convertToAssetsWithTotals
functions. The issue arises when the first user deposits into the vault whilenewTotalAssets
andtotalSupply
are both zero. In this scenario, the function incorrectly multiplies by10 ** _decimalsOffset()
, leading to an overinflated calculation of shares and assets.Impact
Over-Inflation of Shares: The first depositor receives an excessive number of shares, giving them a disproportionate claim on the vault's assets. This can destabilize the vault's share distribution and undermine the fairness of the system.
Collateral Exploitation: The inflated shares can be used as collateral in other contracts, allowing users to borrow more assets than they should be entitled to. This could lead to significant financial loss and drain the vault's assets, as the over-inflated shares enable users to manipulate the system.
Code Snippet
Poc
write this test in
CuratedVaultFactoryTest.sol
and run withforge test --mt testSharesCalculation -vv
Recommendation
Change
_convertToSharesWithTotals
and_convertToAssetsWithTotals
to