DeFi security audits

The bugs that drain DeFi aren't in the syntax. They're in the math.

Oracle manipulation, AMM and vault share-price math, liquidation logic, flash-loan-enabled drains, cross-chain message trust, accounting drift. Guardix maps your protocol's invariants first, then hunts each of these against them — and proves the critical ones with a working exploit on a mainnet fork.

Built for Solidity teams shipping on EVM

Ethereum
Arbitrum
Optimism
Base
Polygon
01Attack surface

Seven ways DeFi protocols get drained.

Generic Solidity scanners stop at reentrancy and missing checks. These are the failure modes that move money — and the exact thing Guardix grounds each one in.

01 Oracle & price manipulation
Spot price read from an AMM pool, a single-source feed, a missing staleness/heartbeat check, or a TWAP window short enough to flash-twist within one block.
Guardix flags every price read, traces it to its source, and checks it against the freshness and manipulation-resistance invariant it extracted for that feed. A spot price feeding a mint or a liquidation is a critical candidate.
Grounds in → INV · feed freshness
02 AMM / LP & swap math
Rounding that favors the caller, a broken k-invariant, fee-on-transfer or rebasing tokens corrupting reserve accounting, first-depositor share inflation, or a donation attack on a balanceOf-based reserve.
It checks the constant-product and share-issuance invariants, models the empty-pool and single-wei deposit cases, and watches for reserves read from raw token.balanceOf(this).
Grounds in → INV · constant-product
03 Vault / ERC-4626 share price
convertToShares / convertToAssets rounding the wrong direction, an inflation or donation attack on the first deposit, a share price movable by a direct transfer, or a withdrawal reading stale totalAssets.
Guardix extracts the shares-to-assets monotonicity invariant — no holder gains free value — and tries to violate it. The classic first-depositor inflation drain is a fork-exploit candidate.
Grounds in → INV · shares ↔ assets
04 Lending, liquidation & bad debt
Liquidation priced off a manipulable oracle, health-factor math rounding the wrong way, self-liquidation, a liquidation incentive that leaves the protocol insolvent, or interest accrual that can be front-run.
Findings are graded against the collateralization invariant — a position can never be drawn below the LTV threshold without reverting — and the bad-debt invariant, then liquidation entry points are checked against both.
Grounds in → INV · collateralization
05 Flash-loan-enabled drains
Not a bug class on its own — an amplifier. Single-transaction access to unbounded capital turns a small oracle skew, a governance-quorum gap, or a share-price wobble into a full drain.
Every finding is reasoned about under the attacker-has-unlimited-single-tx-capital assumption — and the fork proof of concept actually takes a flash loan to drive the drain end to end.
Grounds in → Assumption · unbounded capital
06 Cross-chain & bridge trust
Message-verification gaps, replayable proofs, trusting an L2-to-L1 message before finality, a mint without a matching burn, or unstated relayer assumptions.
Guardix maps the trust boundary — who can produce a valid message — checks the mint/release path against the locked-equals-minted invariant, and flags any release that doesn't verify the source-chain proof.
Grounds in → INV · locked == minted
07 Accounting & invariant drift
An internal ledger diverging from real token balances, fee accounting that double-counts, reward math that can be claimed twice, or totalSupply drifting from the sum of balances after an edge path.
This is what the invariant-extraction pass exists for: every accounting invariant becomes a finding-grading rule, and any drift between accounting state and actual balances is graded against it.
Grounds in → INV · ledger == balances

An eighth surface — MEV and transaction ordering — sits partly in scope: a missing deadline or an unsanitized slippage bound is mechanical, but sandwich economics and extraction strategy are where a human still wins. See the honest line below.

02A finding, end to end

A share-price finding, traced from the line to the drained vault.

Not a textbook reentrancy. A real ERC-4626 economic bug — the code, the invariant it violates, and the verdict Guardix had to earn.

First-depositor inflation lets an attacker steal later deposits.

The first deposit sets the share rate 1:1, then totalAssets() reads balanceOf. An attacker mints one share, donates assets directly to the vault to inflate the rate, and every subsequent depositor rounds down to zero shares — their funds become the attacker's.

ERC4626Vault.sol lines 88–93
                  
88 function deposit(uint256 assets) external returns (uint256 shares) {
89 shares = totalSupply == 0
90 ? assets // first depositor sets the rate 1:1
91 : assets * totalSupply / totalAssets(); // totalAssets reads balanceOf
92 _mint(msg.sender, shares);
93 }
INV-006 state

Shares and assets stay monotonic — no depositor can gain or lose value from another deposit. Share price must not be movable by a direct token transfer.

Extracted from the vault during the architecture pass, before any finding was raised. The deposit path on line 89 can violate it whenever the vault is empty.

Kept — proven on a fork

A flash loan minted one share, donated to inflate the rate, and stole the next depositor's 40 ETH on a mainnet fork. The exploit script ships with the finding.

Had a virtual-shares offset or a dead-shares mint guarded line 89, Guardix would cite that line and drop it — never silently.

03By protocol type

Find your system. See what we check.

The named checks Guardix runs for each protocol family — not a taxonomy of categories you already know.

DEX / AMM
  • k-invariant preservation
  • fee-on-transfer & rebasing tokens
  • first-deposit / donation inflation
  • slippage & deadline on swaps
Lending & borrowing
  • oracle source for liquidation
  • health-factor rounding direction
  • bad-debt socialization path
  • interest-accrual front-running
Vaults & yield (ERC-4626)
  • share ↔ asset rounding direction
  • first-depositor inflation
  • strategy-loss accounting
  • withdrawal reading stale totalAssets
Perps & derivatives
  • funding-rate manipulation
  • mark vs index price source
  • liquidation-engine solvency
  • open-interest / position caps
Bridges & cross-chain
  • message-verification completeness
  • replay protection
  • locked == minted invariant
  • finality assumptions
Stablecoins & RWA
  • peg defense under depeg
  • reserve / collateral accounting
  • mint / redeem authority
  • pause / blocklist privilege scope
04The honest line

What we won't pretend to catch.

Manual auditors genuinely win on the bugs that live in your protocol's economic design, not its code. On a DeFi page, where economic attacks dominate, pretending otherwise would be the easiest way to lose your trust.

So run Guardix continuously to clear the mechanical and known-class DeFi attack surface for $200 a commit — then spend the human budget where it actually pays off.

Read the full comparison →
  • Novel, bespoke economic exploits with no precedent in code or history
  • Multi-protocol composability and game-theoretic incentive failures
  • Governance-attack economics and quorum / timelock design
  • MEV strategy design — ordering and extraction beyond a missing deadline
  • Mechanism-design flaws that are correct in code but wrong by intent
05Every commit

Every new strategy is new attack surface.

DeFi protocols ship fixes, adapters, and integrations constantly. A one-shot human audit is stale the moment you add a vault adapter or a new collateral type. Guardix re-runs on every commit and diffs against the last scan — same $200.

e7b2f4a −2 critical vs previous scan Read how it works →

Audit your protocol before the exploit does.

Connect your repo and get a DeFi-aware report — oracle, AMM, vault, and liquidation findings graded against your invariants, with the criticals proven on a fork.