ERC-4626 vault audit: share math, rounding and donation attacks
An ERC-4626 vault audit checks how the vault turns assets into shares and back, which way each conversion rounds, whether a donation can move the share price, and what every contract that prices the shares assumes. QuillShield audits the vault together with the contracts around it, then checks each pull request against that audit.
What goes wrong in ERC-4626 vaults?
Vault bugs gather in four places: the conversion between assets and shares, the direction that conversion rounds, the balance the vault believes it holds, and the contracts outside the vault that trust its share price.
- Donations to an empty vault. When
totalAssets()reads the vault's token balance, a transfer made before the first real deposit can round later deposits down to 0 shares. The page on the ERC-4626 inflation attack has the vulnerable code and the fix. - Rounding that favors the caller. EIP-4626 asks a vault to round in its own favor: down on shares minted and assets paid out, up on shares burned and assets taken in. A
previewWithdrawthat rounds down lets every withdrawal keep a sliver of value that belongs to the other depositors, and the page on rounding and precision errors shows how slivers become an exploit. - Assets that are not plain ERC-20s. Fee-on-transfer and rebasing tokens make the amount the vault receives differ from the amount it was told about, and tokens with transfer hooks can call back into the vault in the middle of a deposit, which the reentrancy page covers.
- Strategy accounting. Once the vault puts its assets to work,
totalAssets()depends on what each strategy reports. A loss reported late, or a gain anyone can trigger in one transaction, moves the share price for every holder at once. - Contracts that price your shares. A lending market that takes the shares as collateral inherits each of these bugs, and it often treats
convertToAssetsas a price nobody can push. See oracle price manipulation.
What has gone wrong before?
Resupply's loss on 26 June 2025 came from the last item on that list. A new Resupply lending pair priced its collateral from a CurveLend vault that had no deposits yet. According to Resupply's post-mortem, the attacker donated 2,000 crvUSD to the vault's controller and deposited 2 crvUSD for 1 wei of shares, which pushed the price of a single share far above its real value.
Resupply computed its exchange rate as 1e36 divided by that share price, and the result rounded down to 0. With a rate of 0 every position's loan-to-value came out as 0, each borrow passed the solvency check, and the pair was left with $10M of bad debt. The vault did what its code said. The loss happened in a contract that trusted the vault's share price without asking whether the vault was empty.
How do a full audit and pull request checks fit a vault team?
Put the vault and what it depends on in scope: the strategies, the oracle adapters and any router your users deposit through. QuillShield reviews them as one codebase, so a rounding choice in the vault is read next to the contract that relies on it. Before the audit starts, add your trust assumptions and privileged roles as context, such as who can add a strategy, who can pause deposits and which tokens the vault will accept.
A separate reviewer agent tries to disprove each finding before you see it. Each finding that holds up comes with the exact lines, the impact, a recommended fix and the proof of concept result, so you can see whether a share calculation really leaks value before you change it.
After launch, a new strategy, a new fee or another asset arrives as a pull request. Each full audit of a GitHub or GitLab.com repository includes five pull request checks, and each check compares the change with the audit's security graph. On GitHub you can make the check required, so a strategy change with a High or Critical finding can't merge. A change that adds Solidity files, more than 150 lines or more than 5 changed files also gets a recommendation for a new full audit, without blocking.
QuillShield does not replace a manual audit. For a large launch you can request one from QuillAudits and use QuillShield for every change between audits.
What does a vault audit cost?
A full audit is priced from the lines of Solidity in scope, not counting comments and blank lines. As of November 2026 the pricing page lists 1,000 lines at $379 and 5,000 lines at $1,169, and you see the exact quote before anything is charged. After the five included checks, a pull request check costs $5 for up to 50 added lines of Solidity plus $0.10 for each added line after that. The guide to running your first audit shows where you choose the files in scope, and sign-up is free.
What should you check before you launch a vault?
- Can a plain transfer change
totalAssets(), and is the first deposit protected by virtual shares, a seeded deposit or a minimum? - Does every preview and convert function round in the vault's favor, and do
deposit,mint,withdrawandredeemmatch their previews? - Which tokens can the vault hold, and what happens with fee-on-transfer, rebasing or hook-carrying tokens?
- Can anyone trigger a harvest or a report that moves the share price inside one transaction?
- Do the max functions return 0 when deposits or withdrawals are paused, instead of reverting?
- Which contracts outside the vault read its share price, and what do they do with a new, empty or freshly donated vault?
- Do invariant tests check that the vault's assets always cover what its shares are worth?
Common questions
Do I need an audit if my vault uses OpenZeppelin's ERC4626?
Yes. The base contract gives you the share math and, since version 4.9, a virtual offset against the inflation attack. Your strategies, fees, access rules and integrations are new code, and that is what the audit has to cover.
What should be in scope for a vault audit?
The vault, its strategies, oracle adapters and routers, and any contract of yours that prices the vault's shares. Resupply's loss came from a contract that priced a vault, not from the vault itself.
How much does an ERC-4626 vault audit cost with QuillShield?
It depends on the lines of Solidity in scope. The pricing page lists 1,000 lines at $379 and 5,000 lines at $1,169 as of November 2026, and the quote shows the exact price before you pay.
Can a pull request check block a risky strategy change?
On GitHub, if your plan includes branch protection or rulesets. Mark the QuillShield check as required for the branch, and GitHub refuses to merge a change whose check found a High or Critical issue, or one at the severity you chose.