智能合約審計報價申請應提交哪些資料
A repo link isn't a scope. What to send with a smart contract audit quote request
文章指出,智能合約審計報價申請不能只提供程式碼庫連結和上線日期,還要提交足以界定審計範圍與系統風險的資料。建議資料包括納入及排除範圍、角色權限表、系統不變量、信任假設、已接受問題,以及部署和升級腳本。報價還會受 nSLOC、程式碼用途、外部整合、語言、時限及修正覆核影響。
A repo link and a launch date are enough to start a conversation about an audit. They aren't enough to price one. Whoever quotes from them has to guess how long it'll take to understand your system before anyone starts attacking it, and that guess ends up in the number.
Sherlock puts a size on it: teams that hand over a clean scope often get back one to two full days of reviewer attention that would otherwise go into basic orientation.
I covered the basics in an earlier post: a frozen commit, a build that runs on a fresh clone, tests that hit the revert paths, NatSpec on public and external functions. This one is what goes on top of that, the pieces that decide what's in scope and how long it takes. It's also what I'd want to see before quoting.
The scope sheet
Nascent's audit readiness checklist ends with the scoping form Code4rena used in audit prep. It's the closest thing to a standard form I know of, and filled in it answers most of what a firm asks on the first call:
- Repo URL, number of contracts in scope, total SLoC
- External imports, interfaces and structs, external calls
- Mostly composition or mostly inheritance
- Line coverage from your tests
- Any other part of the codebase someone has to understand first, and which
- Oracles, ERC-20 conformance, and whether ERC-721, ERC-777, fee-on-transfer or rebasing tokens can reach the contracts
- Novel curve logic or math
- Timelock, NFT, AMM, fork of a known project, rollups, multi-chain, side-chain
- Specific areas you want looked at ("please try to break X")
That last field is the one most often left empty, and it's the most useful. If you think the liquidation math is the weak spot, say so. Review time goes where you point it, and you get a sharper answer on the part you were already worried about.
Next to the form, two file lists: what's in scope and what's explicitly out (the frontend, libraries you didn't touch). If a module has to keep moving during the audit, put it on its own branch and leave it out of the scoped commit. "Audit main and ignore the new stuff" doesn't work, because main is the thing that moves.
Put the deploy and upgrade scripts in scope
Nascent's checklist is direct about this: deployments and upgrades need the same security attention as the runtime code. A role granted to the deployer and never handed over, or an upgrade script that initializes the wrong proxy, never shows up in the contracts. If the scripts aren't on the scope list, nobody reads them.
A roles table
One page, a row per role. Something like:
| Role | Held by | Can call | Assumed | If compromised |
|---|---|---|---|---|
| Owner | 3-of-5 Safe |
upgradeToAndCall, setFeeRecipient
|
not malicious | replaces the implementation |
| Pauser | EOA | pause |
acts only in incidents | freezes withdrawals |
| Keeper | bot | harvest |
can be front-run | harvests at a bad price |
The first question of the Rekt Test is whether all actors, roles and privileges are documented. Trail of Bits' reasoning is that the written version gives auditors something to hold the code against: the privileges the contracts actually grant next to the ones you meant to grant. The last column is where it gets uncomfortable, like a pauser that can also sweep funds or a keeper that sets its own fee.
Write the invariants down, tested or not
The things that must hold whatever gets called, in whatever order. Total shares times share price matches what the vault holds. Nobody withdraws more than they put in plus their yield.
If you already fuzz them, hand over the suite. If you don't, send the list anyway. The auditor builds adversarial cases from it, and it shows what you think the system promises. Nascent's FREI-PI pattern goes further and re-checks the system-level invariants after every interaction, counting each token or ETH transfer as one.
Your assumptions, and the issues you've already accepted
Nascent's example of written assumptions is a good model: the owner isn't malicious, Chainlink doesn't lie about prices and reports at least once a day, every token the owner approves is a plain ERC-20 with no transfer hooks, and no reorg goes deeper than 30 blocks. A few lines, nothing formal.
That sets your trust boundary on day one, so review time goes into whether those assumptions hold instead of rediscovering them. Add the issues you've already looked at and decided to live with. Otherwise some of them come back as Medium findings you settled months ago, and both sides spend time writing and answering them. Sherlock's guide says the same about open concerns: list them, because hiding them only makes reviewers rediscover what you already suspected.
What makes the quote move
- Size. Firms size scope in nSLOC, source lines without comments or blank lines. Consensys's solidity-code-metrics reports it per file, so you can check the number a firm comes back with.
- What the lines do. 500 lines of plain ERC-20 and 500 lines of cross-chain message handling are not the same job.
- Integrations. Every oracle, bridge or external protocol adds its behaviour to the threat model. A 600-line Uniswap v4 hook isn't a 600-line scope when what it does depends on how PoolManager calls it.
- Language. There are fewer experienced reviewers for Rust, Move, Cairo or circuits than for Solidity, and the price follows that.
- Rush. Two weeks for a six-week scope means a firm pulling people off other work, and that costs extra.
- The fix review. Budget at least one pass over your fixes after the report. It's the line people forget.
Run the Rekt Test before you ask
The Rekt Test is twelve yes/no questions that came out of a discussion led by Trail of Bits' Dan Guido with people from Anchorage Digital, Euler Labs, Fireblocks, Immunefi, Ribbit Capital and others. In short form:
- Actors, roles and privileges documented
- External services, contracts and oracles documented
- A written and tested incident response plan
- The best ways to attack your system written down
- Identity and background checks on everyone
- Someone with security in their role
- Hardware security keys for production systems
- Key management that needs several people and physical steps
- Key invariants defined and tested on every commit
- The best automated tools run on your code
- External audits, plus a disclosure policy or bug bounty
- Ways to abuse your own users considered and mitigated
Questions 1, 2, 4 and 9 are the roles table, the dependency list, your attack notes and the invariants from above. A no on any of the twelve is still worth sending with the request, since it tells the firm where you stand before the first call.
The packet
- Repo URL, branch and commit hash
- In-scope and out-of-scope file lists
- README with a one-command build
- Passing tests and a coverage report
- Fuzz and invariant tests, or at least the invariants list
- Spec or whitepaper, and architecture diagrams that match the current code
- NatSpec on public and external functions
- Roles table
- Assumptions and accepted issues
- Deploy and upgrade scripts
- The filled-in scope sheet, including what you want broken
Adapted from a guide our team published on zealynx.io, which also has an FAQ and a glossary. This version leaves out the original's price figures (the 15 to 30% savings, the language premiums, the price table and the rush-fee ranges), which I couldn't trace to a public source, and Sherlock's contest-length table, which is no longer in Sherlock's docs now that its contests have been replaced. It corrects the Rekt Test's authors (Trail of Bits' post names Ribbit Capital, not the Solana Foundation) and drops firm attributions I couldn't find in the cited sources. The basics it shares with my earlier pre-audit post are linked instead of repeated.
I wrote this with help from AI for drafting and editing. The opinions and the audit experience are mine.
來源:DEV Community · dev.to