Cheerful Taffy Dolphin - First Depositor Share Price Manipulation via Zero Minimum Deposit Enables Unfair Value Extraction From Subsequent Depositors #39
Labels
Sponsor Disputed
The sponsor disputed this issue's validity
Cheerful Taffy Dolphin
Medium
First Depositor Share Price Manipulation via Zero Minimum Deposit Enables Unfair Value Extraction From Subsequent Depositors
Summary
A vulnerability exists in the Vault contract where an attacker can manipulate the initial share price ratio by exploiting the lack of minimum deposit enforcement during initialization. While the contract has a
minDeposit
parameter in itsVaultParameter
struct, the initialization explicitly sets this to zero, creating a window where an attacker can establish an unfavorable share ratio through a minimal initial deposit before any deposit limits are enforced.The issue lies in the initialization sequence and how it affects early depositors.
https://github.com/sherlock-audit/2025-01-perennial-v2-4-update/blob/main/perennial-v2/packages/vault/contracts/Vault.sol#L70
convertToShares()
:_update()
function enforces minimum deposit checks:vulnerability sequence:
minDeposit = 0
_totalShares.isZero()
Impact
The impact manifests in the share/asset ratio manipulation through the
convertToShares()
calculation:When legitimate users deposit after the attack:
Share Dilution: If attacker deposits 1 wei and manipulates _totalAssets to 100 ETH, a user depositing 50 ETH would receive shares calculated as:
50 ETH * (1 wei) / 100 ETH
, resulting in dramatically fewer shares than their deposit proportion warrants.Value Extraction: The attacker can then extract value by redeeming their disproportionate shares. Their 1 wei initial deposit now controls a significant portion of the vault's shares, allowing them to claim an unfair percentage of all subsequent deposits when redeeming. The profit is realized as:
(initial_share_price - manipulated_share_price) * attacker_shares
.This creates a systemic asymmetry where every new deposit inherently advantages the attacker's position due to the manipulated share/asset ratio established during initialization.
Recommendation:
Add mandatory minimum deposit enforcement in initialization:
This ensures there's always a meaningful minimum deposit requirement from the very first deposit, preventing share price manipulation through tiny initial deposits.
While the owner could theoretically call
updateParameter()
right after initialization to set a minimum, relying on external actions for security invariants is unsafe. The contract must enforce these constraints at the protocol level.The fix makes the security guarantee explicit in code rather than depending on proper owner operation.
The text was updated successfully, but these errors were encountered: