Аудит смарт-контрактов: что проверяют, этапы и стоимость
Аудит смарт-контрактов Solidity, Rust, Tact: reentrancy, flash loan, centralization. Slither, Foundry fuzzing, external audit. Сколько стоит аудит перед mainnet.
Аудит смарт-контракта — обязательный этап перед запуском DeFi-протокола, token sale, стейкинг-платформы или NFT mint с real funds. Один баг в Solidity-контракте может стоить миллионы долларов — история знает десятки hacks (The DAO, Ronin, Wormhole). Аудит smart contract снижает риск, повышает доверие инвесторов и часто требуется для листинга на CEX.
Разберём, что проверяют аудиторы, этапы, инструменты и стоимость аудита смарт-контракта.
Зачем нужен аудит смарт-контракта
- Безопасность средств пользователей — TVL, treasury, user deposits
- Доверие community — публикация audit report перед launch
- CEX listing — биржи требуют audit от recognized firm
- Investor due diligence — VC проверяют audit перед инвестицией
- Legal risk mitigation — due care при работе с client funds
- Insurance — Nexus Mutual и др. требуют audit
Без аудита: launch at your own risk + potential total loss.
Что проверяют при аудите
1. Reentrancy
Повторный вход в контракт до завершения транзакции. Классика — The DAO hack 2016.
Проверка: Checks-Effects-Interactions, ReentrancyGuard, pull over push pattern.
2. Access control
- Кто может вызвать
onlyOwnerfunctions? - Timelock на critical changes?
- Multisig vs single EOA?
- Renounced ownership — irreversible?
3. Integer overflow/underflow
Solidity 0.8+ — built-in checks. Но: unsafe casting, assembly blocks.
4. Flash loan attacks
Манипуляция price oracle, reward calculation через borrowed funds в одной tx.
5. Front-running / MEV
Sandwich attacks на DEX, slippage protection.
6. Centralization risks
- Owner can pause, upgrade, drain
- Proxy pattern — upgrade to malicious implementation
- Admin key compromise scenario
7. Logic errors
- Incorrect reward math
- Wrong token decimals handling
- Fee-on-transfer token incompatibility
- Rebasing token issues
8. Gas optimization
Не security-critical, но reduces user cost and DoS via gas limit.
9. Compliance with standards
ERC-20, ERC-721, ERC-1155 — correct implementation.
10. Solana/TON specific
- Missing signer check (Solana)
- Account ownership validation
- PDA seed collisions
- TON message handling
Этапы аудита смарт-контракта
Этап 0: Pre-audit (ваша команда)
- 100% unit test coverage critical paths
- Foundry fuzzing 10k+ runs
- Slither/Mythril automated scan
- Internal code review
- Freeze codebase — no changes during audit
Этап 1: Automated analysis
- Slither — static analysis, 100+ detectors
- Mythril — symbolic execution
- Echidna — property-based fuzzing
- Semgrep — custom rules
Automated finds 30–50% issues; не заменяет manual review.
Этап 2: Manual review
Auditor читает каждую строку:
- Business logic vs specification
- Economic attacks (game theory)
- Integration risks (oracle, external calls)
- Upgrade path security
Срок: 1–4 недели depending on LOC.
Этап 3: Report
Findings classified:
| Severity | Description | Action |
|---|---|---|
| Critical | Direct fund loss | Must fix before launch |
| High | Likely exploit | Must fix |
| Medium | Possible under conditions | Should fix |
| Low | Best practice | Recommended |
| Informational | Notes | Optional |
Этап 4: Remediation
Dev team fixes findings → auditor re-reviews critical/high.
Этап 5: Final report
Published on website, GitHub, submitted to CEX.
Этап 6: Bug bounty (post-launch)
Immunefi, Code4rena — ongoing community audit.
Стоимость аудита смарт-контракта
| Объём кода | Automated only | Boutique firm | Top firm |
|---|---|---|---|
| < 200 LOC (token) | $0–500 | $3–8k | $10–20k |
| 200–1000 LOC (staking) | $500–1k | $8–20k | $20–50k |
| 1000–5000 LOC (DeFi) | $1–2k | $20–50k | $50–150k |
| 5000+ LOC (protocol) | $2–5k | $50–100k | $100–500k+ |
Факторы цены:
- Количество contracts и LOC
- Complexity (AMM math, oracle, cross-chain)
- Timeline (rush = premium)
- Reputation of firm
- Blockchain (Solana/TON auditors fewer → premium)
OpenZeppelin, Trail of Bits, Consensys Diligence, Certik — top tier.
Как подготовиться к аудиту
- Documentation — spec, architecture diagram, tokenomics
- Tests — unit + integration + fuzz
- Clean code — NatSpec comments, naming
- No dead code — remove unused functions
- Testnet deploy — auditor can interact
- Budget 2–4 weeks dev time for fixes post-audit
Audit ≠ guarantee
Даже audited contracts взламывают (Euler Finance 2023 — $197M). Audit снижает risk, не eliminует. Combine:
- External audit
- Bug bounty
- Timelock + multisig
- Gradual TVL cap at launch
- Monitoring (Forta, Tenderly alerts)
Аудит для разных блокчейнов
| Chain | Language | Audit firms |
|---|---|---|
| Ethereum/EVM | Solidity | 50+ firms |
| Solana | Rust/Anchor | OtterSec, Neodyme, Sec3 |
| TON | Tact/FunC | TonBit, limited market |
| BSC/Polygon | Solidity | Same as Ethereum |
Итог
Аудит смарт-контракта — must-have перед mainnet с user funds. Automated tools + manual review + fix cycle + published report. Бюджет: $5–50k для типичного DeFi project. NexForge разрабатывает смарт-контракты с pre-audit preparation: Foundry tests, fuzzing, Slither — и координирует external audit перед launch.