Crypto Training

The Auditor Operating System: Repeatable Results in a Hostile Codebase

The working habits that make audit results repeatable from one engagement to the next: a controlled environment, a one-screen threat model with an explicit attacker budget, notes written as claims, variant analysis and a cadence that reaches experiments early. Each habit is tied to an incident that shows why it exists.

Crypto Training•2026-02-14•13 min read

Auditor OS diagram

What separates an experienced auditor from a new one is mostly the quality of output under pressure, since Solidity knowledge is quick to acquire by comparison. The time is short, the codebase is large, the specification is ambiguous, and the people who wrote the code have opinions about what counts as a bug. A process that amounts to reading and hoping gives different results every time under those conditions.

The fix is to produce artifacts that narrow the search as you go, so that at any moment you can say what has been established and what has not. This post describes those artifacts and the habits around them, which is what the title means by an operating system. The step-by-step order of work inside one engagement, with a worked example, is in A Practical Smart Contract Audit Workflow, and this post avoids repeating it.

The four artifacts#

An audit produces four things, in this order.

  1. Model: what is protected, what is trusted and what is assumed.
  2. Map: entry points, roles and the external-call graph.
  3. Experiments: tests, fuzzing campaigns, invariants and PoCs.
  4. Writeup: a minimal reproduction, the impact and guidance for the fix.
flowchart LR M["Model<br/>assets, assumptions, invariants"] --> A["Map<br/>entry points, roles, call graph"] A --> E["Experiments<br/>fuzz, invariants, PoCs"] E --> W["Writeup<br/>impact, repro, fix guidance"]

Each one is the input to the next. Experiments without a model test whatever happens to be easy to test, and a writeup without experiments is an opinion.

Before you start: control your environment#

This part is mundane and it decides whether the rest of the work can be trusted.

Setup stepWhy it matters
pin and record compiler and tool versionsfindings must reproduce, and the compiler is part of the code under review
run the full test suite onceestablishes a baseline and exposes flaky tests
generate a graph of the repositoryshows who owns state, roles and the core flows before you read
locate configuration, deployment scripts and pending governance actionstells you how the system is actually set up and used

The compiler row has a concrete history. On 30 July 2023 several Curve pools were drained through reentrancy even though every relevant function carried @nonreentrant('lock'). According to Vyper's post-mortem, versions 0.2.15, 0.2.16 and 0.3.0 gave each decorated function its own lock slot, so the lock did not hold across functions (our replay of the pETH/ETH pool). Reading the source alone would not have found that. Checking the deployed compiler version against a list of known compiler bugs would have raised the question, and Solidity publishes such a list in its documentation, including a file of bugs by compiler version.

The configuration row has one too. Sonne Finance lost about $20M in May 2024 through a market that governance had queued for listing with no initial deposit, in a timelock whose executor role was open to anyone. The contracts were a known Compound v2 fork. The bug was in the order of operations of a proposal, which is in scope only if you go looking for it.

For the graph, Slither's entry-points, vars-and-auth and call-graph printers give a first draft in a few minutes. If the repository has no tests, build a minimal harness before anything else: one that deploys the system, calls each state-changing entry point and can substitute a hostile token or a reentrant receiver.

Artifact 1: a threat model that fits on one screen#

Before reading thousands of lines, write the protocol down in plain language in a table like this one.

ItemAnswer
assetswhat is valuable (funds, shares, debt positions, admin power, liveness)
trustwhat is trusted (admins, oracles, tokens, keepers, sequencers)
entry pointswhich public functions change state
invariantswhat must always remain true
failure modewhat "unsafe" looks like (loss, freeze, inflation)

The table is a working tool, since it decides which lines of code can matter and therefore where the hours go. Keep it at the top of the notes file and correct it whenever the code contradicts it.

Write down the attacker budget#

Many DeFi losses trace back to a team assuming the attacker had a constraint that did not exist. State the budget explicitly, with a yes or no for each line.

  • Capital for one block is close to free with flash loans. The transaction that drained Makina in January 2026 borrowed 280M USDC and paid about 59.7k USDC in premium for it (the trace is read step by step here).
  • Ordering can be bought. A searcher or builder can place a transaction first in a block or directly around a victim's, so any value that depends on position within a block is attacker-controlled.
  • Many calls fit in one transaction. Contracts have always been able to batch, and since EIP-7702 went live in May 2025 an EOA can run code as itself too. "One transaction is one action" and "msg.sender is a person" are both unsafe assumptions, and the EIP itself notes that require(tx.origin == msg.sender) no longer works as a guard.
  • Per-transaction values can be counted twice. msg.value is one number for the whole call, so a loop or a delegatecall batch that checks it on each iteration accepts the same ETH several times. Opyn lost funds to that in August 2020, and in 2021 samczsun found the same pattern in MISO's auction with more than 109k ETH at risk, as told in "Two Rights Might Make A Wrong".
  • Outcomes can be retried. A contract caller can inspect the outcome and revert when it is unfavourable, which turns any in-transaction randomness or rounding outcome into a free option.

When any answer is yes, iteration and composition belong to the attack surface, and the properties you test have to hold across sequences of calls.

Artifact 2: the map#

The map has two layers, entry points with their access level and the edges where execution leaves trusted code. The workflow post builds both for a real contract in its Steps 1 and 2, including a table of what each kind of external party can do that the code does not expect.

Two kinds of entry point are missed often enough to check by name. Indirect ones arrive through callbacks: hooks, token receivers and flash-loan callbacks are functions an attacker can cause to run, at a moment of the attacker's choosing. Privileged ones arrive through upgradeability and role delegation, where the function that matters is the one that changes who may call everything else. If the protocol integrates Uniswap v4, treat its hook callbacks as ordinary entry points, as argued in Uniswap v4 Hooks: Secure Design Patterns.

Artifact 3: experiments as filters#

People are poor at exhaustive reasoning over call sequences, and machines are good at it, so use experiments to remove whole regions of the search. Three pay off early: two or three invariants over the core accounting, a fuzzer driving the public entry points in sequences the way an attacker would, and at least one hostile mock for each external dependency. Invariant-First Auditing and Foundry for Security cover the mechanics.

Static analysis fits here as a filter too. It is good at missing access control, unchecked return values, shallow reentrancy and dangerous low-level calls, and weak at protocol-specific invariants, ordering dependence and rounding policy. The rule that keeps tool use productive is that every output has to change the model, the map or an experiment. Output that changes none of them is noise, however long the list.

Artifact 4: the writeup#

A finding gets fixed when it contains a minimal reproduction, an impact stated as a broken guarantee, and a fix direction that respects the design. The template, a severity rubric with the evidence each level needs, and a full example are in Steps 6 and 7 of the workflow post.

Variant analysis#

A bug found once should be assumed to exist in other places, in the same codebase and in its relatives. Variant analysis means naming the pattern (for example "state that guards solvency is changed without the solvency check"), searching for every site that matches, and testing each match under the same attacker model. The search can be grep, a Semgrep rule or a Slither script, depending on how syntactic the pattern is.

Forks show what happens when nobody does this across projects. A Compound v2 market with almost no supply can have its exchange rate inflated by a direct token donation, after which a few wei of shares back a large borrow. That one root cause drained Hundred Finance of about $7.4M in April 2023, Onyx of about $2M in November 2023 and Sonne of about $20M in May 2024. By the second and third incidents, the public material on the first was more than enough to recognise the pattern.

So when you review a fork, the first search is the list of incidents in its parent and siblings. The exploit library on this site is indexed for that, and the precedents dataset can be queried by mechanism. The worst outcome of an audit is reporting one instance of a bug while five copies stay in the code.

What to optimize for#

Finding count, lines read and tool output are easy to measure and say little. The measures that track the quality of an audit are the guarantees you captured as invariants, the share of the attack surface you mapped, and the number of high-impact paths you tested adversarially. A good finding count follows from those and is a poor target by itself.

A realistic audit cadence#

Engagements differ, and a default schedule still protects you from spending most of the time reading.

Day 1: establish what is true#

  • run the tests and record versions
  • identify the deployment configuration
  • write the one-screen threat model
  • map entry points and roles

Day 2: map edges and the paths that worry you#

  • draw the external-call graph
  • find the price-critical paths (oracle and pool reads)
  • find the callback paths (hooks, receivers)
  • pick two or three invariants

Day 3 onward: break things on purpose#

  • fuzz sequences of the permissionless entry points
  • write one or two hostile mocks (an unusual token, a reentrant hook)
  • build a minimal PoC for anything that looks like value creation or a liveness failure

The day numbers matter less than the direction, which is to move from reading to experiments as early as the map allows.

Communication is part of security work#

A report the team cannot act on wastes the engagement, and two habits prevent most of that. Ask clarifying questions early whenever an assumption decides severity, such as the oracle choice, the upgrade authority or the pause powers. Share one high-risk hypothesis in the middle of the audit, so the team can confirm or deny the design intent while there is still time to follow it up. Both reduce uncertainty at the moment it is cheapest to reduce.

If you learn that the team intended a guarantee the code does not enforce, that gap is often the most valuable finding you will deliver.

Upgradeability and admin risk#

A protocol whose arithmetic is correct can still be taken over through its upgrade and admin paths, so answer these questions explicitly in every report.

QuestionWhy it matters
Who can upgrade?a single key is a single point of failure
Is there a timelock?it turns an instant takeover into one that can be detected
Are initializers protected?re-initialisation and uninitialised implementations recur as incident causes
Are roles revocable and enumerable?role mistakes are hard to recover from

The initializer row is the one with the longest record. In November 2017 the shared library behind Parity's multisig wallets had never been initialised in its own storage, so anyone could become its owner and destroy it, which froze 513,774 ETH (replay). At Audius, a storage collision between the proxy and its logic contracts made initialize() callable again on live proxies, and in July 2022 an attacker used it to seize governance and move about 18.6M AUDIO (replay). Upgradeable Contracts: Initializers, UUPS Footguns, and Storage Discipline covers the mechanics.

When a project says it is not upgradeable, check the emergency pause powers, the parameter setters and any registry of external modules. Each of those can change behaviour after deployment, which makes it an upgrade path under another name.

Notes that scale#

In the middle of an audit it is tempting to write "looks safe" or "probably fine". Such notes cannot be checked later, by you or anyone else. Write claims that could be defended or refuted:

  • "function X is permissionless and calls token Y before updating Z"
  • "the price is read from pool P's spot balances and can be moved with one block of borrowed liquidity"
  • "the mint path rounds down and the redeem path rounds down, so a round trip can favour the user"

A claim in that form converts directly into a test, and a failing test converts into a finding.

Keep the whole trail, because the report is a snapshot and the trail is what lets a team learn from it: the invariants, the entry-point and edge maps, each hypothesis with the test that settled it, and the decisions ("this risk is accepted because ..."). The same format works for studying incidents. For each post-mortem you read, record which guarantee failed, which trust boundary was crossed, what the code assumed and which test would have caught it. After a few dozen of them the same primitives keep reappearing: reentrancy edges, replay boundaries, mispriced oracle manipulation and upgrade authorization.

Calibrating your judgment#

Zellic's "The Auditooor Grindset" by Luna Tong is a good reading path for building judgment about what is worth an auditor's attention: known pitfalls, real exploits, then published reports. Reading reports from several firms side by side does the rest, since it shows what experienced reviewers chose to write up and what they left out.

A template you can reuse#

One file with these headings, created when you open a new repository, is enough to always know where you are in the audit.

MD
# Threat model

## Assets

## Trust assumptions

## Attacker budget

## Invariants

## Entry points (state changing)

## External calls (edges)

# Attack surfaces

## MEV

## Oracles

## Reentrancy / callbacks

## Rounding / precision

## Upgrades and admin

# Experiments

## Fuzz targets

## Invariants

## PoCs

# Findings

Sources#