Skip to content
critical DeFi Economic No SWC entry CWE-682

Vault Inflation / First-Depositor Share Attack

SAFE-0019 DeFi Economic Checked automatically by the scanner
1

What goes wrong

In an ERC-4626-style vault, the first depositor mints 1 wei of shares then 'donates' a large amount of the underlying directly to the vault, inflating share price so subsequent depositors' deposits round down to zero shares and are effectively stolen.

2

How to fix it

the pattern that is safe
// OZ ERC4626 with decimals offset (virtual shares) mitigates inflation:
constructor() ERC4626(asset) { }    // override _decimalsOffset() to >0
// or mint dead shares to address(0) on first deposit / enforce min deposit
Classic ERC-4626 inflation attack. Use OZ v4.9+ decimals offset or seed liquidity.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0019 among them. Paste an address or the source itself — a small per-scan fee, shown before you sign, or unlimited on any plan.

Run the scanner See how it is attacked Read the docs