Skip to content
NFTVenue Ledger
Directory

Cross Chain Bridge Validator Exploits

ERC-4626 Tokenized Vault Security: First-Depositor Share Inflation & Virtual-Offset Math

Empty ERC-4626 yield vaults without virtual share offsets or dead-share seeding allow a mempool frontrunner to donate tokens and steal up to 50% of the first legitimate deposit.

By Dr. Devon Kurosawa, PhDReview not recorded · Updated
ERC-4626 Tokenized Vault Security: First-Depositor Share Inflation & Virtual-Offset Math — NFTVenue Ledger 2026 quantitative & supervisory data card
NFTVenue Ledger (Cross-Chain Bridge Verification Models, Oracle Manipulation & Exploit RCAs): 10^d virtual share offsets, atomic dead-share seeding, and 4-way rounding rules.Source: NFTVenue Ledger Institutional Research DeskLicense: CC-BY-4.0

Standardized in EIP-4626, Tokenized Yield Vaults underpin lending markets (Morpho, Euler v2, Aave StatATokens), liquid restaking wrappers, and regulated ERC-3643 RWA treasury funds across ecosystems in our marketplaces directory (from Beethoven X boosted pools to Acala Swap). Yet deploying a textbook naive ERC-4626 formula—shares = assets * totalSupply / totalAssets—on an empty vault (totalSupply == 0) creates a classic First-Depositor Share Inflation ("Donation") Exploit responsible for dozens of lending-fork hacks (Hundred Finance $7M, Ovix, Sonne Finance $20M)!

Anchored in our cross-chain bridge, oracle & exploit RCA master guide, OpenZeppelin Contracts v5 neutralizes donation rounding attacks mathematically through Virtual Shares & Assets (_decimalsOffset).

Anatomy of the 4-Step ERC-4626 First-Depositor Donation Attack!#

Trace what happens when Victim Bob submits vault.deposit(20,000 USDC) to a freshly created empty vault (totalSupply = 0, totalAssets = 0) on a public mempool:

  1. Tx_1 — Attacker Frontrun Mint (1 Wei Share): Attacker frontruns Bob by depositing 1 wei of USDC, receiving 1 wei of Vault Share (totalSupply = 1, totalAssets = 1).
  2. Tx_2 — Direct ERC-20 Donation (20,000 USDC + 1 wei): Attacker calls USDC.transfer(address(vault), 20_000e6) directly (bypassing deposit!). Now totalAssets = 20,000e6 + 1, while totalSupply is STILL 1 wei! A single wei of vault share now costs 20,000.000001 USDC!
  3. Tx_3 — Victim Bob's Deposit Rounds Down to 0 Shares!: Bob's vault.deposit(20,000e6) computes:

shares = floor( 20,000e6 * 1 / (20,000e6 + 1) ) = floor( 0.99999999995 ) = 0 shares! If the vault forgets require(shares > 0), Bob hands over 20,000 USDC and receives 0 shares (and even WITH require(shares > 0), if Attacker donates 10,000e6 + 1 instead, Bob gets 1 wei share (50% of pool) for $20k while Attacker holds 1 wei share (50% of pool) on $30k total = $15k -> Attacker steals $5,000 instantly!)!

  1. Tx_4 — Attacker Redeems 1 Wei Share: Attacker calls redeem(1) and sweeps $40,000 (+$20,000 risk-free profit)!
ERC-4626 first-depositor donation rounding exploit vs OpenZeppelin v5 virtual shares and dead-share burning
ERC-4626 first-depositor donation rounding exploit vs OpenZeppelin v5 virtual shares and dead-share burningVerified Exhibit

Comparing Three Defenses: Virtual Offsets vs Dead Shares vs Internal Balance Tracking#

Why did Sonne Finance ($20M) and Hundred Finance ($7M) get hacked on Compound v2 forks even though ERC-4626 inflation was already well known? Because permissionless market creation deployed a brand-new empty cToken market without atomically seeding + burning dead shares inside the same factory transaction!

ERC-4626 Share-Inflation Defense Comparison Matrix#

Quantitative Distribution · Attacker Cost to Steal $1 From Victim
Attacker Cost to Steal $1 From VictimSide Effects / Edge Cases
01None (shares = A * S / T)$0 net loss (10…02Atomic Dead-Share Burn (1e6…Attacker loses …03OpenZeppelin v5 Virtual Off…Attacker loses …
Mitigation TechniqueAttacker Cost to Steal $1 From VictimWorks on Empty Permissionless Market?Side Effects / Edge Cases
None (shares = A * S / T)$0 net loss (100% profitable!)NO (Fatal Drain!)Even require(shares > 0) loses up to 50%!
Internal Accounting (trackedAssets)Blocks raw ERC20.transferPartialBreaks rebasing tokens & complicates yield skim
Atomic Dead-Share Burn (1e6 -> 0xdead)Attacker loses 99.9999% of donation to 0xdead!Yes IF atomic in Factory!Deployer pays tiny dust (e.g. $1 USDC)
OpenZeppelin v5 Virtual Offset (d = 6)Attacker loses 1,000,000 : 1 to virtual pool!YES (Zero Deployer Capital!)Vault token has assetDecimals + 6 decimals
Attacker net financial loss when attempting a $20,000 donation attack across virtual decimal offsets d=0, 3, 6, 9
Attacker net financial loss when attempting a $20,000 donation attack across virtual decimal offsets d=0, 3, 6, 9Verified Exhibit

Exact OpenZeppelin v5 Virtual-Offset & Four-Function Rounding Matrix#

Every ERC-4626 audit verifies both virtual-offset dilution and the four directional rounding modes in Math.mulDiv (getting just ONE of the four rounding directions wrong allows an infinite deposit-redeem 1-wei siphon loop!):

Formula or model from the articleNot independently verified
1) OpenZeppelin v5 ERC-4626 Virtual Shares & Assets Conversion (Decimal Offset d >= 3):
  • shares = mulDiv( assets, totalSupply + 10^d, totalAssets + 1, Rounding )
  • assets = mulDiv( shares, totalAssets + 1, totalSupply + 10^d, Rounding )
  • Why Attacker Donation D Fails When Victim Deposits V:
  • Attacker holds 1 share out of (1 + 10^d) total virtual+real shares!
  • Fraction of donation D permanently forfeited by Attacker to virtual shares = 10^d / (1 + 10^d)
  • At d = 6: Attacker forfeits 1,000,000 / 1,000,001 = 99.9999% of D immediately!
  • 2) Mandatory Vault-Protective Rounding Directions Across All 4 Entrypoints:
  • previewDeposit(assets) -> Floor (Down): Fewer shares minted to user
  • previewMint(shares) -> Ceil (Up): More assets pulled from user
  • previewWithdraw(assets) -> Ceil (Up): More shares burned from user
  • previewRedeem(shares) -> Floor (Down): Fewer assets paid out to user

Auditing Cryptographic Merkle Trees in Cross-Chain Bridges Next#

From arithmetic rounding in vaults, we turn to a devastating cryptographic hashing flaw that drained $570M on BNB Bridge and threatened dozens of Merkle airdrop/bridge contracts: Merkle tree leaf preimage collision & bridge proof forgery and WAD/RAY precision truncation inside our Cross-Chain Bridge & Oracle Security hub.

Frequently asked questions

Does adding require(shares > 0) completely stop the ERC-4626 inflation attack?

No! Even with require(shares > 0), an attacker can donate half of the victim deposit amount + 1 wei so the victim receives 1 wei share instead of 2—still stealing up to 33%–50% of the victim deposit!

How do virtual shares in OpenZeppelin v5 stop donation attacks without locking real tokens?

By adding 10^d (e.g., 1,000,000) to totalSupply and +1 to totalAssets in the conversion denominator, any unsolicited ERC-20 donation is diluted 1,000,000-to-1 across unredeemable virtual shares.

Why did Compound v2 forks like Sonne Finance ($20M) suffer donation attacks on newly listed markets?

Governance queued a proposal adding a new cToken market at 0 totalSupply without atomically minting and burning initial dead cTokens in the same transaction—letting an attacker frontrun the first deposit.

Why must previewMint and previewWithdraw round UP while previewDeposit and previewRedeem round DOWN?

Vault math must always leave fractional sub-wei dust inside the vault; if deposit rounded up or withdraw rounded down, a flash-loop calling deposit(1 wei) + withdraw(1 wei) 10,000 times would drain existing LPs.

Publication record

Published
November 13, 2026
Updated
November 14, 2026
Author
Dr. Devon Kurosawa, PhD
Review
Review not recorded
Automated fact check
Passed in the stored pipeline record
Source URLs
3 recorded

AI assistance recorded: anthropic/claude-opus-4.6. This field does not establish human review or source verification.

Academic & Institutional Attribution

Cite This Research & Embed Live Data Card

Open Attribution License (CC BY 4.0)

Standard academic & institutional research paper citation format.

Dr. Devon Kurosawa, PhD. (2026, November 14). ERC-4626 Tokenized Vault Security: First-Depositor Share Inflation & Virtual-Offset Math. NFTVenue Ledger. https://nftvenueledger.com/protocols/erc4626-vault-first-depositor-share-inflation-rounding-attack
Explore Cross Chain Bridge Validator Exploits Hub (20) →

NFTVenue Ledger Data, Benchmarks & Contributor Records

ERC-4626 Vault Security: Share Inflation & Virtual Offsets | NFTVenue Ledger