ERC4626 Inflation Attack Explained in Detail
An ERC4626 inflation attack targets vault share math when supply is empty or tiny. A common shape is: attacker deposits a dust amount, donates assets directly to the vault, then a victim deposits and receives zero or too few shares because of rounding.
The victim's assets increase the vault value, but the attacker owns most or all shares.
{
"preset": "flow",
"autoplaySecs": 5.0,
"edges": [
{"idx": 0, "stepReveal": 0},
{"idx": 1, "stepReveal": 1},
{"idx": 2, "stepReveal": 2},
{"idx": 3, "stepReveal": 3, "accent": true}
],
"steps": [
{"title": "Step 1 - Attacker gets first shares", "desc": "The vault starts with tiny supply, so the first shares control the exchange rate.", "activeNodes": ["attacker", "dust"], "activeEdges": [0], "tone": "warning", "navLabel": "Step 1 - Attacker gets first shares"},
{"title": "Step 2 - A direct donation raises assets", "desc": "Assets increase without minting new shares, making each existing share look expensive.", "activeNodes": ["dust", "donation"], "activeEdges": [1], "tone": "danger", "navLabel": "Step 2 - A direct donation raises assets"},
{"title": "Step 3 - Victim deposits into skewed math", "desc": "The victim deposits after the attacker has changed the asset-to-share rate.", "activeNodes": ["donation", "victim"], "activeEdges": [2], "tone": "danger", "navLabel": "Step 3 - Victim deposits into skewed math"},
{"title": "Step 4 - Rounding gives too few shares", "desc": "Integer rounding can mint zero or too few shares for the victim.", "activeNodes": ["victim", "rounding"], "activeEdges": [3], "tone": "danger", "navLabel": "Step 4 - Rounding gives too few shares"},
{"title": "Audit lesson", "desc": "Low-supply vaults need mitigations such as virtual shares, seeded liquidity, or minimum-share checks.", "activeNodes": ["donation", "rounding"], "activeEdges": [3], "tone": "info", "navLabel": "Audit lesson"}
]
}
How the share price gets inflated
Step through the empty-vault attack: a tiny first deposit plus a direct donation makes the victim receive too few shares.
Smart contract example
attacker deposits 1 -> attacker donates 100 -> victim deposits 100 -> victim receives 0 shares
The exact numbers depend on the vault's conversion and rounding logic.
ERC4626 Inflation Attack in Auditing
ERC4626 vaults are often integrated as yield sources, collateral, and strategy tokens. Inflation bugs can steal first deposits or make small deposits unsafe.
Auditors review low-supply share math before treating the vault as safe.
Red flags in code
-
Empty vault has no virtual shares, virtual assets, or seeded liquidity.
-
totalAssets()uses raw token balance without internal accounting. -
Deposits lack minimum-share protection.
-
Direct donations change the share price.
-
Tests skip first-depositor and dust-deposit cases.
How to test or review it
-
Simulate attacker dust deposit, donation, and victim deposit.
-
Check
previewDepositagainst actual minted shares. -
Fuzz low supply, low assets, and rounding boundaries.
-
Test virtual-share or dead-share mitigations.
-
Confirm routers or callers enforce minimum shares when needed.
Keep learning this topic
ERC-4626 Vaults
ERC-4626 is the tokenized vault standard where users deposit an asset and receive vault shares that represent a claim on the vault's assets.
Donation Attack
A donation attack manipulates protocol accounting by transferring tokens directly to a contract without using the intended deposit path.
Rounding Error
A rounding error is the difference between the mathematically exact result and the integer-rounded result returned by smart contract math.
Practice this in real audit scenarios
Definitions help, but auditors need reps. SCH turns concepts like ERC4626 Inflation Attack into exploit labs, code review habits, and report-writing practice.
Start the free trial or see the full smart contract auditing course.