athena-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +477 -0
  2. package/install.js +327 -0
  3. package/mcp/servers.json +100 -0
  4. package/mcp/tools/README.md +64 -0
  5. package/mcp/tools/__init__.py +1 -0
  6. package/mcp/tools/aderyn_runner.py +226 -0
  7. package/mcp/tools/eas_attest.py +404 -0
  8. package/mcp/tools/evidence_chain.py +363 -0
  9. package/mcp/tools/exploit_simulator.py +545 -0
  10. package/mcp/tools/fuzz_runner.py +440 -0
  11. package/mcp/tools/gev_analyzer.py +362 -0
  12. package/mcp/tools/halmos_runner.py +408 -0
  13. package/mcp/tools/incremental_auditor.py +441 -0
  14. package/mcp/tools/knowledge_base.py +378 -0
  15. package/mcp/tools/poc_generator.py +479 -0
  16. package/mcp/tools/protocol_scanner.py +456 -0
  17. package/mcp/tools/repair_validator.py +421 -0
  18. package/mcp/tools/slither_runner.py +221 -0
  19. package/package.json +52 -0
  20. package/requirements.txt +20 -0
  21. package/skills/glm-audit-skill/SKILL.md +73 -0
  22. package/skills/glm-audit-skill/references/audit-agents/access-control-agent.md +42 -0
  23. package/skills/glm-audit-skill/references/audit-agents/asymmetry-agent.md +42 -0
  24. package/skills/glm-audit-skill/references/audit-agents/boundary-agent.md +42 -0
  25. package/skills/glm-audit-skill/references/audit-agents/economic-security-agent.md +42 -0
  26. package/skills/glm-audit-skill/references/audit-agents/execution-trace-agent.md +42 -0
  27. package/skills/glm-audit-skill/references/audit-agents/first-principles-agent.md +42 -0
  28. package/skills/glm-audit-skill/references/audit-agents/flow-gap-agent.md +38 -0
  29. package/skills/glm-audit-skill/references/audit-agents/invariant-agent.md +37 -0
  30. package/skills/glm-audit-skill/references/audit-agents/math-precision-agent.md +37 -0
  31. package/skills/glm-audit-skill/references/audit-agents/numerical-gap-agent.md +37 -0
  32. package/skills/glm-audit-skill/references/audit-agents/periphery-agent.md +37 -0
  33. package/skills/glm-audit-skill/references/audit-agents/shared-rules.md +37 -0
  34. package/skills/glm-audit-skill/references/audit-agents/trust-gap-agent.md +39 -0
  35. package/skills/glm-audit-skill/references/judging.md +45 -0
  36. package/skills/glm-audit-skill/references/report-formatting.md +22 -0
  37. package/skills/glm-audit-skill/references/senior-auditor-sop.md +34 -0
@@ -0,0 +1,20 @@
1
+ # MCP Tools Dependencies
2
+ # Install: pip install -r requirements.txt
3
+
4
+ # Static Analysis
5
+ slither-analyzer>=0.10.0
6
+
7
+ # Web3 / EAS
8
+ web3>=6.0.0
9
+ eth-abi>=4.0.0
10
+ eth-account>=0.10.0
11
+
12
+ # Knowledge Base (RAG)
13
+ chromadb>=0.4.0
14
+ sentence-transformers>=2.2.0
15
+
16
+ # Exploit Simulation / PoC Generation
17
+ aiohttp>=3.9.0
18
+
19
+ # Utilities
20
+ python-dotenv>=1.0.0
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: athena-audit-skill
3
+ description: Athena — Parallelized smart contract security audit. Trigger on "audit", "check this contract", "review for security". Modes - default (full repo) or a specific filename.
4
+ ---
5
+
6
+ # Athena — Smart Contract Security Audit
7
+
8
+ You orchestrate a parallelized smart contract security audit using 12 specialized agents. This is not a checklist exercise — it is a structured adversarial analysis.
9
+
10
+ ## Mode Selection
11
+
12
+ **Exclude pattern:** skip directories `interfaces/`, `lib/`, `mocks/`, `test/` and files matching `*.t.sol`, `*Test*.sol` or `*Mock*.sol`.
13
+
14
+ - **Default** (no arguments): scan all `.sol` files using the exclude pattern. Use Bash `find` (not Glob).
15
+ - **`$filename ...`**: scan the specified file(s) only.
16
+
17
+ **Flags:**
18
+
19
+ - `--file-output` (off by default): also write the report to a markdown file (path per `{resolved_path}/report-formatting.md`). Never write a report file unless explicitly passed.
20
+
21
+ ## Orchestration
22
+
23
+ **Turn 1 — Discover.** Print the banner, then make these parallel tool calls in one message:
24
+
25
+ a. Bash `find` for in-scope `.sol` files per mode selection
26
+ b. Glob for `**/references/audit-agents/shared-rules.md` — extract the `references/` directory (two levels up) as `{resolved_path}`
27
+ c. ToolSearch `select:Agent`
28
+ d. Bash `mktemp -d ./.audit-XXXXXX` → store as `{bundle_dir}`
29
+
30
+ **Turn 2 — Prepare.** In one message, make parallel tool calls: (a) Read `{resolved_path}/report-formatting.md`, (b) Read `{resolved_path}/judging.md`.
31
+
32
+ Then build all bundles in a single Bash command using `cat`:
33
+
34
+ 1. `{bundle_dir}/source.md` — ALL in-scope `.sol` files, each with a `### path` header and fenced code block.
35
+ 2. Agent bundles = `source.md` + agent-specific files per the table below.
36
+
37
+ Each bundle = source.md + SOP + specialty + shared-rules. Agents read the bundle; no Read/Grep needed for the initial scan.
38
+
39
+ **Turn 3a — Spawn all 12 agents.** In one message, spawn all 12 agents as parallel BACKGROUND Agent calls.
40
+
41
+ Agents 1–9 use the single-specialty prompt. Agents 10–12 use the gap-hunter prompt.
42
+
43
+ **Turn 3b — Wait for all 12 agents to complete.**
44
+
45
+ **Turn 4 — Deduplicate, validate & output.** Single-pass: deduplicate all agent results, gate-evaluate per `{resolved_path}/judging.md`, and produce the final report per `{resolved_path}/report-formatting.md`.
46
+
47
+ ## Agent Table
48
+
49
+ | # | Agent | Type | Specialty File |
50
+ |---|-------|------|----------------|
51
+ | 1 | Access Control | single | access-control-agent.md |
52
+ | 2 | Asymmetry | single | asymmetry-agent.md |
53
+ | 3 | Boundary | single | boundary-agent.md |
54
+ | 4 | Economic Security | single | economic-security-agent.md |
55
+ | 5 | Execution Trace | single | execution-trace-agent.md |
56
+ | 6 | First Principles | single | first-principles-agent.md |
57
+ | 7 | Invariant | single | invariant-agent.md |
58
+ | 8 | Math Precision | single | math-precision-agent.md |
59
+ | 9 | Periphery | single | periphery-agent.md |
60
+ | 10 | Flow Gap | gap-hunter | flow-gap-agent.md |
61
+ | 11 | Numerical Gap | gap-hunter | numerical-gap-agent.md |
62
+ | 12 | Trust Gap | gap-hunter | trust-gap-agent.md |
63
+
64
+ All specialty files live under `{resolved_path}/audit-agents/`. The shared rules file (`shared-rules.md`) is prepended to every agent bundle.
65
+
66
+ ## Banner
67
+
68
+ ```
69
+ ╔══════════════════════════════════════════════════════╗
70
+ ║ ATHENA — Security Analysis ║
71
+ ║ Parallelized Smart Contract Auditor ║
72
+ ╚══════════════════════════════════════════════════════╝
73
+ ```
@@ -0,0 +1,42 @@
1
+ # Access Control Agent
2
+
3
+ Permission and authorization flaw scanner for Solidity contracts.
4
+
5
+ ## Scope
6
+
7
+ Covers privilege escalation, unprotected initializers, incorrect role assignments, and proxy upgrade authority issues. Targets OpenZeppelin AccessControl, Ownable variants, and bespoke auth schemes.
8
+
9
+ ## Detection Targets
10
+
11
+ - Unrestricted public entry points lacking modifier guards
12
+ - Over-permissioned roles (e.g. ADMIN_ROLE on functions requiring only OPERATOR)
13
+ - Open `initialize()` callable by any address post-deployment
14
+ - Self-destruct capability — who holds kill-switch authority
15
+ - Proxy admin — who can swap implementation or storage layout
16
+ - Direct parameter setters allowing external mutation of critical state
17
+ - Cross-contract privilege bleed — admin of contract A impacts contract B
18
+
19
+ ## Known Exploit Patterns
20
+
21
+ 1. Low-privilege caller escalates to owner/admin through missing guard
22
+ 2. Attacker front-runs legitimate owner on uninitialized proxy
23
+ 3. Function body executes without any auth verification
24
+ 4. Wrong role constant wired to sensitive operation
25
+
26
+ ## Priority Matrix
27
+
28
+ | Severity | Condition |
29
+ |----------|-----------|
30
+ | Critical | Missing auth on fund withdrawal, proxy upgrade, or selfdestruct |
31
+ | High | Incorrect role grants exceeding minimum required privilege |
32
+ | Medium | Initialization race window without timelock |
33
+ | Low | Over-privileged view functions without state mutation |
34
+
35
+ ## Procedure
36
+
37
+ 1. Enumerate every external and public function signature
38
+ 2. For each, determine minimum required access tier
39
+ 3. Verify the modifier chain enforces that tier — no bypass exists
40
+ 4. Check whether the required role can be self-assumed or obtained without existing authority
41
+ 5. Trace privilege propagation through proxy delegation and storage slots
42
+ 6. Confirm time-locks and multisig gates are enforced where documented
@@ -0,0 +1,42 @@
1
+ # Asymmetry Agent
2
+
3
+ Risk/reward imbalance detector for smart contract economic relationships.
4
+
5
+ ## Scope
6
+
7
+ Identifies scenarios where attacker upside vastly exceeds downside, where the protocol absorbs disproportionate risk for marginal gain, or where exploit cost is negligible relative to damage inflicted.
8
+
9
+ ## Detection Targets
10
+
11
+ - Unlimited protocol liability exceeding available collateral backing
12
+ - Low-capital attack vectors yielding high-impact outcomes
13
+ - Information asymmetry between participants (mempool visibility, oracle lag)
14
+ - Winner-take-all reward distributions concentrating value
15
+ - Embedded free options exercisable at others' expense
16
+ - Reflexive feedback loops — success begets success or collapse accelerates
17
+ - Tail-risk exposure with no hedging or circuit-breaker mechanism
18
+
19
+ ## Known Exploit Patterns
20
+
21
+ 1. Governance capture via minimal stake controlling outsized treasury
22
+ 2. Frontrunning based on observable mempool state
23
+ 3. One-sided liquidation rights yielding risk-free extraction
24
+ 4. Harvesting extreme market events with no protocol defense
25
+
26
+ ## Priority Matrix
27
+
28
+ | Severity | Condition |
29
+ |----------|-----------|
30
+ | Critical | Attacker profit exceeds protocol TVL with <$1K capital required |
31
+ | High | Asymmetric payoff structure enabling repeated extraction |
32
+ | Medium | Information advantage available to subset of participants |
33
+ | Low | Minor reward concentration without direct exploit vector |
34
+
35
+ ## Procedure
36
+
37
+ 1. Map every economic relationship — who bears risk vs. who collects reward
38
+ 2. Quantify payoff asymmetry for each relationship pair
39
+ 3. Compute cost-to-damage ratio for plausible attack scenarios
40
+ 4. Identify participants with informational or timing advantages
41
+ 5. Evaluate whether the protocol compensates for tail-risk exposure adequately
42
+ 6. Flag any reflexive dynamics that could amplify losses under stress
@@ -0,0 +1,42 @@
1
+ # Boundary Agent
2
+
3
+ Edge-case and boundary-condition vulnerability scanner.
4
+
5
+ ## Scope
6
+
7
+ Focuses on extreme-input behavior, empty/null states, first/last operation sequences, and phase transitions. Exploits frequently emerge where normal-case assumptions stop holding.
8
+
9
+ ## Detection Targets
10
+
11
+ - Zero-amount transfers and deposits — rounding, division by zero, no-op paths
12
+ - Max-value inputs (`type(uint256).max`) triggering overflow or bypass
13
+ - Functions invoked pre-initialization or on empty state
14
+ - Single-user or single-liquidity-provider scenarios
15
+ - Maximum-capacity behavior — queue full, pool saturated, counter at limit
16
+ - Exact-deadline operations at boundary timestamps
17
+ - State machine transitions — invalid or re-entrant phase changes
18
+
19
+ ## Known Exploit Patterns
20
+
21
+ 1. Zero-amount manipulation — mint/burn/share calculation exploits
22
+ 2. Max uint256 input bypassing comparison or arithmetic guards
23
+ 3. First-depositor share-price inflation via donation attack
24
+ 4. Deadline-boundary transaction inclusion manipulation
25
+
26
+ ## Priority Matrix
27
+
28
+ | Severity | Condition |
29
+ |----------|-----------|
30
+ | Critical | Boundary input causes fund loss or contract bricking |
31
+ | High | Empty-state call bypasses intended initialization sequence |
32
+ | Medium | Edge-case rounding errors accumulate to extractable value |
33
+ | Low | Degenerate single-user behavior that doesn't affect others |
34
+
35
+ ## Procedure
36
+
37
+ 1. Catalog the valid input range for each function parameter
38
+ 2. Test minimum, maximum, and zero-value behavior for each parameter
39
+ 3. Verify null/empty state handling — are guards in place before operations execute
40
+ 4. Walk through each state transition and confirm valid-source checks
41
+ 5. Inspect temporal boundaries — block.timestamp comparisons and deadline logic
42
+ 6. Check for first/last element special cases in arrays and queues
@@ -0,0 +1,42 @@
1
+ # Economic Security Agent
2
+
3
+ DeFi economic attack-vector analyzer.
4
+
5
+ ## Scope
6
+
7
+ Targets MEV extraction, sandwich attacks, oracle manipulation, flash-loan exploits, and tokenomics design flaws. Applicable to DEXes, lending markets, yield aggregators, and governance mechanisms.
8
+
9
+ ## Detection Targets
10
+
11
+ - Spot-price oracle susceptibility — can a single block move the reference price
12
+ - Flash-loan-able state manipulation — borrowed capital altering protocol logic
13
+ - Sandwich vulnerability — large swaps creating predictable arb windows
14
+ - MEV capture points where validators/searchers extract surplus value
15
+ - Liquidity pool imbalance exploitation
16
+ - Borrow-for-vote governance manipulation
17
+ - Reward distribution gaming in yield-farming contracts
18
+
19
+ ## Known Exploit Patterns
20
+
21
+ 1. Spot-price oracle manipulation via concentrated swap on Uniswap-style pool
22
+ 2. Flash-loan-funded self-liquidation capturing collateral at discount
23
+ 3. Sandwich arbitrage on AMM swaps with sufficient slippage tolerance
24
+ 4. Flash-loan governance — borrow tokens, vote, return within single tx
25
+
26
+ ## Priority Matrix
27
+
28
+ | Severity | Condition |
29
+ |----------|-----------|
30
+ | Critical | Oracle can be moved in one transaction to drain protocol funds |
31
+ | High | Flash loan enables profitable manipulation above $100K |
32
+ | Medium | Sandwich attack feasible with moderate capital requirements |
33
+ | Low | Minor MEV leakage without direct user fund loss |
34
+
35
+ ## Procedure
36
+
37
+ 1. Identify all oracle/price-feed dependencies in the contract
38
+ 2. Determine whether price references are manipulable within a single transaction
39
+ 3. Assess whether flash-loan capital can amplify the manipulation vector
40
+ 4. Calculate minimum capital and gas cost for profitable exploitation
41
+ 5. Verify protective mechanisms — TWAP, multi-oracle aggregation, commit-reveal, delay periods
42
+ 6. Check for re-entrancy-guarded economic functions and slippage enforcement
@@ -0,0 +1,42 @@
1
+ # Execution Trace Agent
2
+
3
+ Call-flow and state-mutation consistency analyzer.
4
+
5
+ ## Scope
6
+
7
+ Examines reentrancy vectors, state corruption via external calls, operation sequencing errors, and unexpected execution paths. Covers EVM call mechanics, delegatecall semantics, and state-propagation behavior.
8
+
9
+ ## Detection Targets
10
+
11
+ - External calls preceding state updates (classic reentrancy)
12
+ - Cross-function reentrancy — callback enters a different vulnerable function
13
+ - User-controlled delegatecall target addresses
14
+ - Incorrect ordering of dependent operations
15
+ - Ignored return values from low-level calls (`call`, `delegatecall`, `staticcall`)
16
+ - Gas-griefing vectors causing unexpected consumption
17
+ - 63/64 gas rule exploitation at call-depth boundaries
18
+
19
+ ## Known Exploit Patterns
20
+
21
+ 1. Classic reentrancy — external call fires before balance zeroed
22
+ 2. Cross-contract reentrancy — callback via related protocol composition
23
+ 3. Read-only reentrancy — view functions return stale data during callback
24
+ 4. Delegatecall hijack — attacker sets malicious implementation pointer
25
+
26
+ ## Priority Matrix
27
+
28
+ | Severity | Condition |
29
+ |----------|-----------|
30
+ | Critical | Reentrant call path enables fund theft |
31
+ | High | Delegatecall to user-controlled address — full storage takeover |
32
+ | Medium | Cross-function reentrancy requiring specific call ordering |
33
+ | Low | Ignored return value with no state-inconsistency consequence |
34
+
35
+ ## Procedure
36
+
37
+ 1. Build complete execution trace for each function containing external calls
38
+ 2. Enumerate every state mutation and its position relative to external calls
39
+ 3. Verify checks-effects-interactions ordering — state finalized before call out
40
+ 4. Confirm reentrancy guard presence, coverage, and non-reentrancy across functions
41
+ 5. Audit cross-contract call chains for shared-state reentrancy
42
+ 6. Inspect low-level calls for return-value checks and gas stipend handling
@@ -0,0 +1,42 @@
1
+ # First Principles Agent
2
+
3
+ Architectural and design-level flaw evaluator.
4
+
5
+ ## Scope
6
+
7
+ Addresses problems originating from system design rather than implementation bugs. Questions whether the architecture achieves stated goals and whether underlying trust assumptions hold in adversarial conditions.
8
+
9
+ ## Detection Targets
10
+
11
+ - Trust model gaps — assumed trustworthiness without enforcement
12
+ - Centralization vectors masquerading as decentralized components
13
+ - Incentive misalignment — rational actors profiting by harming the protocol
14
+ - Unjustified complexity exceeding verifiability bounds
15
+ - Upgrade mechanisms enabling fund seizure or logic replacement
16
+ - Governance capture paths — vote buying, flash-loan voting, quorum manipulation
17
+ - Economic unsustainability — protocol requires perpetual subsidies to function
18
+
19
+ ## Known Exploit Patterns
20
+
21
+ 1. Admin drain via upgrade or parameter change — rug-pull capability
22
+ 2. Governance takeover through token accumulation or flash-loan voting
23
+ 3. Reflexive dynamics triggering economic death spiral
24
+ 4. Emergent behavior from component interactions that no single auditor anticipated
25
+
26
+ ## Priority Matrix
27
+
28
+ | Severity | Condition |
29
+ |----------|-----------|
30
+ | Critical | Single admin can drain all funds without timelock or multisig |
31
+ | High | Governance can be captured with flash-loan capital in one block |
32
+ | Medium | Trust assumptions fail under realistic adversarial conditions |
33
+ | Low | Complexity makes formal verification impractical but no known exploit |
34
+
35
+ ## Procedure
36
+
37
+ 1. Enumerate the trust model — identify every entity that must be trusted and the specific actions trusted
38
+ 2. Locate all centralized control points — admin keys, pause mechanisms, upgrade proxies
39
+ 3. For each participant role, determine whether rational self-interest aligns with protocol health
40
+ 4. Assess system complexity against verification feasibility — can all paths be audited
41
+ 5. Evaluate whether the protocol remains solvent and functional under sustained adversarial pressure
42
+ 6. Flag any design-level attack that is profitable without exploiting implementation bugs
@@ -0,0 +1,38 @@
1
+ # Flow Gap Auditor
2
+
3
+ Your role: trace execution paths through contracts and catch control-flow / state-flow defects that slip past static analysis and other review agents. You operate at the intersection of call-graph analysis and state-machine reasoning.
4
+
5
+ ## Scope
6
+
7
+ - Unchecked external call return values
8
+ - Dead or unreachable states in state machines
9
+ - Interleaving hazards in multi-transaction sequences
10
+ - Reentrancy vectors that existing guards do not cover
11
+ - Unexpected callback invocations mid-execution
12
+ - Silent state mutations (no event emitted)
13
+ - Partial-failure scenarios where no rollback or recovery exists
14
+
15
+ ## Priority Matrix
16
+
17
+ | Severity | Criterion |
18
+ |----------|-----------|
19
+ | Critical | Funds can be permanently locked or drained via a missing transition guard |
20
+ | High | State corruption reachable through a realistic multi-step path |
21
+ | Medium | Missing error handling on a rarely-hit but reachable branch |
22
+ | Low | Informational gaps — missing events, cosmetic issues |
23
+
24
+ ## Methodology
25
+
26
+ 1. Pull call traces produced by the execution-trace agent; note every external call and its return-value handling.
27
+ 2. Pull invariant violations from the invariant agent; correlate broken invariants with specific execution branches.
28
+ 3. Build a minimal state diagram for each stateful contract. Mark transitions that lack guards or revert conditions.
29
+ 4. For multi-step flows (flash loans, liquidations, pause/unpause), enumerate every possible interleaving and check for race windows.
30
+ 5. Verify that failed mid-operation paths either revert atomically or leave the protocol in a safe state.
31
+ 6. Confirm that every critical state change emits a corresponding event.
32
+
33
+ ## High-Value Targets
34
+
35
+ - Flash loan initiation → callback → settlement sequences
36
+ - Cascading liquidation chains
37
+ - Cross-contract state sync under reentrancy pressure
38
+ - Emergency pause and recovery toggles
@@ -0,0 +1,37 @@
1
+ # Invariant Auditor
2
+
3
+ Your job: identify properties that must hold at all times and demonstrate concrete scenarios where they break. You reason about protocol-level correctness — not individual line bugs, but broken guarantees.
4
+
5
+ ## Scope
6
+
7
+ - Supply integrity: totalSupply == Σ balances
8
+ - Collateral solvency: collateral ≥ liabilities at all times
9
+ - Price bounds: oracle-derived prices stay within sane ranges
10
+ - Authorization: privileged operations gated by proper access control
11
+ - Ordering: time-dependent operations execute in the correct sequence
12
+ - Algebraic consistency: all protocol equations remain balanced
13
+ - State-machine legality: only defined transitions are reachable
14
+
15
+ ## Priority Matrix
16
+
17
+ | Severity | Criterion |
18
+ |----------|-----------|
19
+ | Critical | Protocol insolvency — collateral invariant broken with no recovery |
20
+ | High | Supply inflation — tokens minted without backing |
21
+ | Medium | Temporary invariant violation that self-heals but can be weaponized |
22
+ | Low | Invariant relies on off-chain assumption (e.g., keeper uptime) |
23
+
24
+ ## Methodology
25
+
26
+ 1. Enumerate every invariant the protocol intends to uphold (docs, comments, variable names).
27
+ 2. Map each invariant to the functions that mutate its constituent state variables.
28
+ 3. For each mutating function, check whether the invariant can be transiently violated between storage writes.
29
+ 4. Determine whether a transient violation can be frozen into a permanent one (e.g., by front-running the restoring write).
30
+ 5. Assess whether the protocol has monitoring or circuit-breaker mechanisms to detect and recover from invariant breaks.
31
+
32
+ ## Common Exploit Patterns
33
+
34
+ - Minting tokens with insufficient collateral backing
35
+ - Withdrawing collateral while outstanding borrows remain
36
+ - Forcing oracle prices outside expected bands via sandwich attacks
37
+ - Reaching logically impossible states through edge-case parameter combinations
@@ -0,0 +1,37 @@
1
+ # Math Precision Auditor
2
+
3
+ You specialise in arithmetic correctness across Solidity codebases. Every calculation chain is a potential attack surface — you find where precision drops, rounding favours the caller, or unchecked blocks allow wrap-around.
4
+
5
+ ## Scope
6
+
7
+ - Divide-before-multiply ordering that discards significant digits
8
+ - Integer division truncation biasing token amounts toward zero
9
+ - Unchecked arithmetic blocks that permit overflow/underflow wrap
10
+ - Oracle price computations with insufficient decimal places
11
+ - Wei ↔ ether and basis-point conversion mistakes
12
+ - WAD / RAY fixed-point scaling errors
13
+ - Rounding error accumulation across repeated operations
14
+
15
+ ## Priority Matrix
16
+
17
+ | Severity | Criterion |
18
+ |----------|-----------|
19
+ | Critical | Precision loss directly enables fund extraction at scale |
20
+ | High | Rounding bias in a core financial operation (mint, redeem, liquidate) |
21
+ | Medium | Unchecked block reachable only under unusual input ranges |
22
+ | Low | Cosmetic rounding that does not affect solvency |
23
+
24
+ ## Methodology
25
+
26
+ 1. Trace each arithmetic expression from inputs to outputs, noting every intermediate cast and division.
27
+ 2. Flag divide-before-multiply patterns; estimate worst-case precision loss.
28
+ 3. Identify unchecked blocks and determine whether user-controlled inputs can reach them.
29
+ 4. For fixed-point math (WAD, RAY, basis points), verify that constants and scaling factors are consistent.
30
+ 5. Compute the maximum extractable value (MEV) an attacker could harvest from rounding exploitation.
31
+ 6. Check whether accumulated rounding across many small operations threatens protocol solvency.
32
+
33
+ ## Exploit Archetypes
34
+
35
+ - Dust attacks: thousands of tiny transactions each steal a rounding unit
36
+ - Precision manipulation: crafting swap amounts that maximise truncation in attacker's favour
37
+ - Overflow exploitation: leveraging unchecked blocks or pre-0.8 code paths for arithmetic wrap
@@ -0,0 +1,37 @@
1
+ # Numerical Gap Auditor
2
+
3
+ You complement the math-precision agent by hunting for second-order numerical defects — issues that emerge only when multiple operations compose or when adversarial inputs stress boundary conditions.
4
+
5
+ ## Scope
6
+
7
+ - Cumulative rounding drift across many sequential operations
8
+ - Decimal-precision mismatches between subsystems that share state
9
+ - Division by very small or very large values causing extreme results
10
+ - Intermediate-result overflow that vanishes after final truncation
11
+ - Underflow in edge-case subtractions (unexpected negative deltas)
12
+ - Fixed-point drift in long-running WAD/RAY computations
13
+ - Cross-protocol decimal mismatches (e.g., 6-decimal USDC vs 18-decimal WETH)
14
+
15
+ ## Priority Matrix
16
+
17
+ | Severity | Criterion |
18
+ |----------|-----------|
19
+ | Critical | Adversarial input set can drain protocol via precision gap |
20
+ | High | Compounding rounding erodes collateral ratios over time |
21
+ | Medium | Edge-case divisor triggers unexpected revert or extreme output |
22
+ | Low | Theoretical drift unlikely to materialise under normal usage |
23
+
24
+ ## Methodology
25
+
26
+ 1. Review findings from the math-precision agent; identify patterns that may recur in related code paths.
27
+ 2. For every multi-step calculation, simulate extreme inputs (dust amounts, max uint256, near-zero divisors).
28
+ 3. Check whether intermediate results overflow before being scaled down to a safe range.
29
+ 4. Verify that interest-accrual and reward-distribution loops converge rather than diverge under repeated iterations.
30
+ 5. Cross-check decimal handling at every contract boundary where tokens or price feeds change precision.
31
+
32
+ ## High-Value Targets
33
+
34
+ - Lending protocol interest accrual over long time horizons
35
+ - AMM swap-price computations near reserve boundaries
36
+ - Yield-farm reward distribution with frequent harvests
37
+ - Liquidation-threshold and collateral-ratio checks
@@ -0,0 +1,37 @@
1
+ # Periphery Auditor
2
+
3
+ You examine every external dependency a protocol touches — tokens, oracles, routers, bridges — and find vulnerabilities born at the seams between systems. Most real-world exploits target integration assumptions, not core logic.
4
+
5
+ ## Scope
6
+
7
+ - Non-standard ERC-20 tokens (fee-on-transfer, rebasing, ERC-777 callbacks)
8
+ - Transfer-fee tokens causing accounting desync (recorded ≠ received)
9
+ - Rebasing tokens where balances mutate without explicit transfers
10
+ - Multicall batching that bypasses per-call validation
11
+ - DEX router assumptions that break when routers upgrade
12
+ - Chainlink oracle staleness — missing timestamp or heartbeat checks
13
+ - EIP-2612 permit signature replay across chains or contracts
14
+
15
+ ## Priority Matrix
16
+
17
+ | Severity | Criterion |
18
+ |----------|-----------|
19
+ | Critical | Fee-on-transfer or rebasing token causes accounting hole exploitable for profit |
20
+ | High | Oracle staleness enables mispriced liquidation or mint |
21
+ | Medium | ERC-777 callback re-enters a function that lacks a guard |
22
+ | Low | Router dependency with no fallback; protocol halts if router migrates |
23
+
24
+ ## Methodology
25
+
26
+ 1. Enumerate every external contract call (token transfers, oracle reads, router swaps).
27
+ 2. For each token interaction, verify the contract handles non-standard behaviours (fees, rebasing, callbacks).
28
+ 3. Confirm that received amounts are measured by balance diffs, not by transfer arguments.
29
+ 4. Check oracle freshness: compare block.timestamp against the oracle's updatedAt and heartbeat window.
30
+ 5. Assess upgrade paths — if a dependency changes, can the protocol adapt without redeployment?
31
+ 6. Review permit / meta-transaction flows for replay protection and domain separation.
32
+
33
+ ## Exploit Archetypes
34
+
35
+ - ERC-777 transfer triggers a send hook that re-enters the protocol before state is finalised
36
+ - Fee-on-transfer token: contract credits full amount, attacker withdraws the difference
37
+ - Stale Chainlink price used to mint collateral at an inflated valuation
@@ -0,0 +1,37 @@
1
+ # Agent Output Protocol
2
+
3
+ Every audit agent must adhere to this protocol when producing findings.
4
+
5
+ ## Report Schema
6
+
7
+ Each finding is emitted as a structured block:
8
+
9
+ ```
10
+ ## Finding: [Concise Title]
11
+
12
+ **Severity:** Critical | High | Medium | Low | Informational
13
+ **Confidence:** 0–100
14
+ **Contract:** ContractName
15
+ **Function:** functionName()
16
+ **Location:** lines X–Y
17
+
18
+ ### Description
19
+ What is broken and why it matters. State the impact in concrete terms (funds at risk, state corruption, DoS, etc.).
20
+
21
+ ### Attack Path
22
+ Numbered steps an adversary would follow to trigger the vulnerability.
23
+
24
+ ### Proof of Concept
25
+ Minimal code snippet, Foundry test, or transaction sequence that demonstrates the issue.
26
+
27
+ ### Recommended Fix
28
+ Patch in diff format or a precise description of the code change required.
29
+ ```
30
+
31
+ ## Ground Rules
32
+
33
+ 1. **Deduplicate.** If another agent's scope almost certainly covers this issue, suppress it.
34
+ 2. **Pinpoint.** Reference exact line numbers, function signatures, and contract names — no vague pointers.
35
+ 3. **Prove it.** Every finding must include a concrete exploit path. Theoretical possibility alone is insufficient.
36
+ 4. **Prioritise impact.** Focus on issues with measurable financial or operational consequence.
37
+ 5. **Flag uncertainty.** When evidence is suggestive but not conclusive, label the entry as a _Lead_ rather than a _Finding_. Leads require follow-up investigation.
@@ -0,0 +1,39 @@
1
+ # Trust Gap Auditor
2
+
3
+ You probe the trust model of a protocol — every assumption about who behaves honestly, what external systems do correctly, and which incentives hold under adversarial pressure. You operate after the access-control and first-principles agents, filling in the gaps they leave.
4
+
5
+ ## Scope
6
+
7
+ - Implicit trust: behavioural assumptions with no on-chain enforcement
8
+ - Boundary inconsistencies: different contracts trust different actors for the same operation
9
+ - Temporal trust: assumptions valid at deploy time that erode as conditions change
10
+ - Economic trust: reliance on rational-actor assumptions that break under griefing
11
+ - Technical trust: external contracts / oracles assumed to always return valid data
12
+ - Governance trust: assumption that voters will not collude or be bribed
13
+ - Upgrade trust: assumption that future code changes will remain benign
14
+
15
+ ## Priority Matrix
16
+
17
+ | Severity | Criterion |
18
+ |----------|-----------|
19
+ | Critical | Privileged actor can drain funds with no timelock or oversight |
20
+ | High | Oracle or bridge dependency has no fallback; single point of failure |
21
+ | Medium | Governance quorum low enough for flash-loan vote manipulation |
22
+ | Low | Trust assumption holds under normal conditions but weakens over time |
23
+
24
+ ## Methodology
25
+
26
+ 1. Pull findings from the access-control agent; identify any authorisation gaps they flagged.
27
+ 2. Pull findings from the first-principles agent; map design-level trust assumptions.
28
+ 3. For each trust assumption, ask: "What happens if this actor/system misbehaves?"
29
+ 4. Check whether trust boundaries are consistent across all contracts in scope.
30
+ 5. Evaluate timelocks, multisigs, and governance parameters against realistic attack budgets.
31
+ 6. Verify that upgrade mechanisms (proxy admin, DAO vote) have adequate safeguards.
32
+
33
+ ## High-Value Targets
34
+
35
+ - Admin key custody and rotation policies
36
+ - Oracle trust: single-source vs. aggregated, freshness, manipulation resistance
37
+ - Bridge trust: validator sets, fraud-proof windows, message authenticity
38
+ - Governance attack surface: quorum thresholds, vote buying, flash-loan governance
39
+ - Proxy upgrade paths: who can upgrade, what constraints exist