Before depositing into an ERC-4626 vault, the most effective way to protect against share inflation attacks is to check whether the vault has already set up effective "dead shares" or virtual share/decimal offset protection. If the vault is brand new, totalSupply is 0 or very small, and it lacks these protections, your deposit could be rounded down to 0 shares in extreme cases. Your money enters the vault, but your share balance becomes zero, and an attacker can redeem all assets using just 1 wei of initial shares.

A leading global cryptocurrency platform,suitable for both beginners and experienced traders.
New user benefit: 20% off trading fees upon registration!!
How the Attack Works: Why Your Deposit Becomes a "Donation"
ERC-4626 vaults determine the share price using totalAssets / totalSupply. When a vault is empty or nearly empty, an attacker first deposits 1 wei to receive 1 share, then transfers tokens directly to the contract address without calling deposit. This makes totalAssets spike while totalSupply stays unchanged. The price per share is now pushed extremely high.
When you then call deposit normally with a certain amount of assets, the vault calculates your shares using a formula roughly like assets × totalSupply / totalAssets. Since totalSupply is still 1 and totalAssets has been inflated enormously, your deposit amount divided by a huge denominator can round down to 0. You receive 0 shares, and your deposit effectively becomes a donation to the vault. The attacker then uses that 1 share to redeem all remaining assets, including your deposit.
OpenZeppelin's documentation quantifies the attack cost: without decimal offset protection, if a victim plans to deposit u assets, the attacker only needs to invest about u+1 assets to complete the attack, with gains roughly equal to the victim's entire deposit.
What to Check Before Depositing
Check the relationship between totalSupply and totalAssets. If totalSupply is extremely small (like 1 wei or single digits) while totalAssets is already large, the vault has either already been attacked or its protection mechanism is flawed. A healthy vault should have enough share supply early on to make rounding losses negligible. OpenZeppelin's guide notes that to limit deposit rounding loss to within 1%, you need to receive at least 100 shares. If the share price has been pushed extremely high, the same deposit will yield far fewer than 100 shares, exposing the risk.
Check whether the vault uses OpenZeppelin 5.x's virtual share mechanism. Since v4.9, OpenZeppelin has introduced configurable virtual assets and virtual shares in its ERC-4626 implementation via _decimalsOffset(). The default offset (0) already makes attacks unprofitable, and larger offsets increase attack costs by several orders of magnitude. This doesn't completely eliminate attacks, but it makes the value an attacker could capture from donations get absorbed by virtual shares, offsetting their expected gains and removing the economic incentive. If the vault you're depositing into is based on OpenZeppelin 5.x and hasn't overridden _convertToShares and _convertToAssets, protection likely exists. If the vault was deployed before 2023 or is based on an older implementation, be extra cautious.
Check for dead shares. Some protocols (like Morpho Vault V2) require vaults to mint a batch of non-redeemable shares to the 0x...dEaD address at deployment, establishing a baseline for share supply that makes inflation attacks economically unfeasible. Morpho's documentation provides specific quantity references: assets with 18 decimals need at least 1e9 dead shares, while 6-decimal assets need 1e18. You can check on a block explorer whether the vault contract's balanceOf(0x000000000000000000000000000000000000dEaD) is greater than zero. If it returns 0, this protection doesn't exist.
Check whether the vault tracks internal balances instead of balanceOf. Some implementations use internal accounting variables (like _accountedAssets) instead of asset.balanceOf(address(this)) to calculate totalAssets, meaning direct transfers won't affect the share price. This design fundamentally cuts off the donation attack path. You can confirm in the contract source code or audit report whether totalAssets() directly reads the token balance.
What to Do If the Vault Has No Protection
Don't deposit. Especially when the vault is newly deployed and totalSupply is extremely small. The attacker's cost is just your deposit amount plus 1 wei. The attack window closes once meaningful liquidity enters, but the first depositor is precisely the highest-risk position.
If you must deposit, test with a minimal amount and check your shares. First deposit a small amount you can fully afford to lose, then check the actual number of shares you received after the transaction confirms. If the share count is significantly lower than expected (for example, you should receive 100 shares at the current share price but only get 1 or 0), stop immediately. However, this method has limitations: if an attack occurs between your test transaction and your actual deposit, passing the test doesn't guarantee safety for a larger amount.
Use a frontend or router that supports slippage checks. OpenZeppelin's comments mention that users can protect themselves through a wrapper that performs checks (like ERC4626Router), verifying that the number of shares received matches expectations. Morpho's documentation also recommends that user-facing applications implement min-received checks. If you're depositing through an aggregator or frontend, confirm whether it sets a lower bound on share amounts in the transaction.
An Easily Overlooked Edge Case
Share inflation attacks primarily threaten early depositors in a vault. Once a vault has accumulated meaningful liquidity and a sufficiently large share supply, the same donation attack would require an amount of assets too large to be profitable, and the attack window closes. So if you're depositing into a vault that has been running for a while with substantial TVL, the probability of this specific risk is lower. But "running for a while" doesn't equal safety: if the vault was previously attacked or the share price has been pushed to abnormal levels for other reasons, you could still receive very few shares. Before depositing, checking the current share price (totalAssets / totalSupply) and its trend over a recent period tells you more than just looking at TVL.
Additionally, even if a vault has virtual share protection, OpenZeppelin notes that virtual shares capture a small portion of the vault's accrued value, and when the vault incurs losses, users who exit first bear slightly less loss than those who exit later. This is the cost of protection, not an attack, but if you require precision in share pricing, you should be aware of this.

A leading global cryptocurrency platform,suitable for both beginners and experienced traders.
New user benefit: 20% off trading fees upon registration!!
References
- OpenZeppelin Docs·ERC-4626,2026-10-30
- OpenZeppelin Contracts v5.4.0·ERC4626.sol(source code comments),2026-10-30
- OWASP SCWE-135·ERC4626 Share Inflation via Donations,2026-10-30
- QuillAudits·Understanding ERC-4626 Vault Inflation Attacks,2026-10-30
- Zellic·Regarding inflation attacks,2026-10-30
- Morpho Docs·Vaults & ERC4626 Mechanics,2026-10-30


