audit-system 2.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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +351 -0
  3. package/agents/AGENT_REGISTRY.md +150 -0
  4. package/agents/assumption-analyzer.json +7 -0
  5. package/agents/assumption-analyzer.md +37 -0
  6. package/agents/composition-attacker.json +7 -0
  7. package/agents/composition-attacker.md +46 -0
  8. package/agents/economic-attacker.json +7 -0
  9. package/agents/economic-attacker.md +43 -0
  10. package/agents/exploit-writer.json +7 -0
  11. package/agents/exploit-writer.md +48 -0
  12. package/agents/orchestrator.json +16 -0
  13. package/agents/orchestrator.md +46 -0
  14. package/agents/report-writer.json +7 -0
  15. package/agents/report-writer.md +52 -0
  16. package/agents/state-machine-hacker.json +7 -0
  17. package/agents/state-machine-hacker.md +43 -0
  18. package/agents/test-generator.json +7 -0
  19. package/agents/test-generator.md +49 -0
  20. package/cli.js +93 -0
  21. package/config.json +74 -0
  22. package/lib/detect-lang.js +109 -0
  23. package/lib/install.js +229 -0
  24. package/lib/utils.js +41 -0
  25. package/obsidian-vault/README.md +103 -0
  26. package/obsidian-vault/attack-patterns/state-inconsistency.md +90 -0
  27. package/obsidian-vault/exploits/_index.md +109 -0
  28. package/obsidian-vault/exploits/beanstalk-2022.md +334 -0
  29. package/obsidian-vault/exploits/nomad-2022.md +295 -0
  30. package/obsidian-vault/exploits/ronin-2022.md +251 -0
  31. package/obsidian-vault/exploits/wormhole-2022.md +284 -0
  32. package/obsidian-vault/failed-hypotheses/_template.md +77 -0
  33. package/obsidian-vault/hypotheses/_template.md +43 -0
  34. package/obsidian-vault/hypotheses/bridge-protocol-template.md +254 -0
  35. package/obsidian-vault/hypotheses/dex-protocol-template.md +185 -0
  36. package/obsidian-vault/hypotheses/governance-protocol-template.md +263 -0
  37. package/obsidian-vault/hypotheses/lending-protocol-template.md +218 -0
  38. package/obsidian-vault/hypotheses/staking-protocol-template.md +223 -0
  39. package/obsidian-vault/invariant-catalog/defi-invariants.md +307 -0
  40. package/obsidian-vault/invariant-catalog/solana-invariants.md +213 -0
  41. package/obsidian-vault/novel-patterns/pattern-mutation-framework.md +316 -0
  42. package/obsidian-vault/reports/_template.md +92 -0
  43. package/obsidian-vault/research/cross-protocol-analysis/.gitkeep +0 -0
  44. package/obsidian-vault/research/emerging-threats/.gitkeep +0 -0
  45. package/obsidian-vault/research/protocol-specific/.gitkeep +0 -0
  46. package/obsidian-vault/test-strategies/fuzzing.md +75 -0
  47. package/obsidian-vault/vulnerabilities/access-control.md +122 -0
  48. package/obsidian-vault/vulnerabilities/flash-loan-attack.md +66 -0
  49. package/obsidian-vault/vulnerabilities/oracle-manipulation.md +135 -0
  50. package/obsidian-vault/vulnerabilities/reentrancy.md +141 -0
  51. package/obsidian-vault/vulnerabilities/rust-unsafe-deserialization.md +128 -0
  52. package/obsidian-vault/vulnerabilities/solana-account-confusion.md +125 -0
  53. package/obsidian-vault/vulnerabilities/solana-close-account.md +141 -0
  54. package/obsidian-vault/vulnerabilities/solana-cpi-attacks.md +131 -0
  55. package/obsidian-vault/vulnerabilities/solana-signer-authorization.md +119 -0
  56. package/package.json +56 -0
  57. package/skills/audit-connect.md +385 -0
  58. package/skills/auditor.md +280 -0
  59. package/skills/exploit-generator.md +394 -0
  60. package/skills/novel-discovery.md +551 -0
  61. package/skills/test-generator.md +511 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Jorge Paim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,351 @@
1
+ # Audit System
2
+
3
+ Sistema multi-agente de auditoria de smart contracts com foco em descoberta de vulnerabilidades inovadoras.
4
+
5
+ **Linguagens Suportadas:**
6
+ - **Solidity** (EVM/Foundry) — auto-detectado por arquivos `*.sol`
7
+ - **Rust (Solana/Anchor)** — auto-detectado por `Anchor.toml` + `Cargo.toml`
8
+ - **Rust (ink!/Polkadot)** — auto-detectado por dependência `ink` no `Cargo.toml`
9
+
10
+ **Modelo:** Funciona com QUALQUER modelo de IA - Claude, GPT, Kimi, Gemini, modelos locais, etc. O sistema detecta automaticamente o modelo atual ou permite configuração manual.
11
+
12
+ **Modelos Testados:**
13
+ - Claude Opus/Sonnet/Haiku
14
+ - Kimi K2.5 / K2
15
+ - GPT-4o / GPT-4 Turbo
16
+ - Gemini Pro / Ultra
17
+ - Modelos locais (via API compatível)
18
+
19
+ ## Visão Geral
20
+
21
+ Este sistema conecta **8 agents especializados**, **5 skills** e um **knowledge base completo (Obsidian Vault)** para realizar auditorias de segurança em smart contracts.
22
+
23
+ **Auto-detecção de linguagem:** o sistema detecta automaticamente se o projeto alvo usa Solidity (EVM) ou Rust (Solana/Anchor/ink!) e configura todos os agents no modo apropriado.
24
+
25
+ Quando você executa `/audit-connect` em qualquer projeto, TODOS os recursos são ativados automaticamente.
26
+
27
+ ## Estrutura
28
+
29
+ ```
30
+ audit-system/
31
+ ├── agents/ # Definições dos agentes especializados (LANG-aware)
32
+ │ ├── orchestrator.json # Coordenador de workflows
33
+ │ ├── assumption-analyzer.json # Phase 1: Quebra de suposições
34
+ │ ├── economic-attacker.json # Phase 3: Modelagem econômica
35
+ │ ├── state-machine-hacker.json # Phase 4: Máquina de estados
36
+ │ ├── composition-attacker.json # Phase 5: Ataques por composição
37
+ │ ├── exploit-writer.json # Criação de PoCs (Solidity + Rust)
38
+ │ ├── test-generator.json # Geração de testes (Foundry + Anchor)
39
+ │ └── report-writer.json # Compilação de relatórios
40
+ ├── skills/ # Skills do Claude Code
41
+ │ ├── auditor.md # Auditoria padrão (Solidity + Rust checklists)
42
+ │ ├── novel-discovery.md # Descoberta de vulnerabilidades inovadoras
43
+ │ ├── exploit-generator.md # Geração de exploits (Solidity + Rust)
44
+ │ ├── test-generator.md # Geração de testes (Foundry + Anchor)
45
+ │ └── audit-connect.md # CONECTOR DE PROJETOS ⭐
46
+ ├── obsidian-vault/ # Knowledge base
47
+ │ ├── vulnerabilities/ # Vulnerabilidades conhecidas (EVM + Solana)
48
+ │ ├── hypotheses/ # Hipóteses de ataque
49
+ │ ├── invariant-catalog/ # Catálogo de invariantes (DeFi + Solana)
50
+ │ ├── novel-patterns/ # Frameworks de discovery
51
+ │ └── research/ # Pesquisas
52
+ ├── config.json # Configuração do sistema (v2.0 multi-language)
53
+ └── ARCHITECTURE.md # Documentação da arquitetura de integração
54
+ ```
55
+
56
+ ## Integração de Recursos
57
+
58
+ Quando você conecta o audit-system a um projeto, **todos os recursos são ativados**:
59
+
60
+ | Recurso | Quantidade | Descrição |
61
+ |---------|------------|-----------|
62
+ | **Agents** | 8 especialistas | Especialistas em diferentes fases da auditoria (LANG-aware) |
63
+ | **Skills** | 5 prompts | Prompts reutilizáveis para análise (Solidity + Rust) |
64
+ | **Vault** | 19+ arquivos | Knowledge base com vulnerabilidades EVM + Solana, padrões, invariantes |
65
+ | **Modelo** | Qualquer um | Usa o modelo que você tiver disponível (Claude, Kimi, GPT, etc.) |
66
+ | **Linguagens** | Solidity + Rust | Auto-detecção: `.sol` ou `Anchor.toml`/`Cargo.toml` |
67
+
68
+ ### Como tudo se conecta:
69
+
70
+ ```
71
+ Projeto → /audit-connect → [Agents + Skills + Vault] → Resultados
72
+ ```
73
+
74
+ - **Agents** usam **Skills** como prompts especializados
75
+ - **Agents** consultam **Vault** para conhecimento de vulnerabilidades
76
+ - **Qualquer modelo** pode ser usado (Claude, Kimi, GPT, Gemini, local)
77
+ - **Resultados** são salvos em `./audit-output/`
78
+
79
+ ## Instalação Rápida (via npx)
80
+
81
+ ```bash
82
+ # Em qualquer projeto, instale o audit-system:
83
+ npx audit-system connect
84
+
85
+ # Ou force uma linguagem específica:
86
+ npx audit-system connect --lang=rust
87
+ npx audit-system connect --lang=solidity
88
+
89
+ # Verifique o status:
90
+ npx audit-system status
91
+
92
+ # Diagnóstico:
93
+ npx audit-system doctor
94
+ ```
95
+
96
+ Isso cria `.audit-system/` e `.claude/` no projeto, com todos os agents, skills e knowledge base.
97
+
98
+ ### Outros Comandos npx
99
+
100
+ ```bash
101
+ npx audit-system help # Ajuda
102
+ npx audit-system lang # Detecta linguagem do projeto
103
+ npx audit-system agents # Lista agentes disponíveis
104
+ npx audit-system doctor # Verifica instalação
105
+ ```
106
+
107
+ ## Como Usar (no Claude Code)
108
+
109
+ ### 1. Conectar a um Projeto
110
+
111
+ Com o Claude Code aberto no diretório do projeto:
112
+
113
+ ```bash
114
+ /audit-connect
115
+ ```
116
+
117
+ Isso ativa o audit-system para o projeto atual.
118
+
119
+ ### 2. Executar Agentes
120
+
121
+ Após conectar:
122
+
123
+ ```bash
124
+ # Auditoria completa
125
+ /audit-agent full
126
+
127
+ # Phase 1 - Quebra de suposições
128
+ /audit-agent assumption
129
+
130
+ # Phase 3 - Modelagem econômica
131
+ /audit-agent economic
132
+
133
+ # Phase 4 - Análise de máquina de estados
134
+ /audit-agent state
135
+
136
+ # Phase 5 - Ataques por composição
137
+ /audit-agent composition
138
+
139
+ # Criar exploit
140
+ /audit-agent exploit
141
+
142
+ # Gerar testes
143
+ /audit-agent test
144
+
145
+ # Compilar relatório
146
+ /audit-agent report
147
+ ```
148
+
149
+ ### Modo Rust/Solana
150
+
151
+ ```bash
152
+ # Auto-detecção (se Anchor.toml presente)
153
+ /audit-connect
154
+
155
+ # Ou forçar modo Rust
156
+ /audit-connect --lang=rust
157
+
158
+ # Auditoria completa em programa Solana
159
+ /audit-agent full --target=./programs/
160
+
161
+ # Análise específica
162
+ /audit-agent assumption --target=./programs/amm/src/lib.rs
163
+ /audit-agent economic --target=./programs/amm/
164
+ /audit-agent exploit --target=./programs/amm/
165
+
166
+ # Output em ./audit-output/rust/
167
+ ```
168
+
169
+ ### 3. Workflows Disponíveis
170
+
171
+ | Workflow | Comando | Descrição |
172
+ |----------|---------|-----------|
173
+ | Full Audit | `/audit-agent full` | Todos os agentes |
174
+ | Novel Discovery | `/audit-connect --mode=novel` | Apenas 6 fases discovery |
175
+ | Quick Check | `/audit-connect --mode=quick` | Análise rápida |
176
+
177
+ ## Agentes
178
+
179
+ ### Phase Specialists (Framework 6 Fases)
180
+
181
+ 1. **assumption-analyzer** (Phase 1)
182
+ - Mapeia suposições implícitas/explícitas
183
+ - Gera hipóteses quebrando suposições
184
+ - Saída: Lista de hipóteses ranqueadas
185
+
186
+ 2. **economic-attacker** (Phase 3)
187
+ - Modela protocolo como jogo econômico
188
+ - Encontra ataques de maximização de lucro
189
+ - Saída: Vetores de ataque econômicos
190
+
191
+ 3. **state-machine-hacker** (Phase 4)
192
+ - Analisa estados e transições
193
+ - Encontra transições inválidas
194
+ - Saída: Transições perigosas e estados raros
195
+
196
+ 4. **composition-attacker** (Phase 5)
197
+ - Analisa interações entre features
198
+ - Encontra vulnerabilidades emergentes
199
+ - Saída: Vulnerabilidades por composição
200
+
201
+ ### Implementers
202
+
203
+ 5. **exploit-writer**
204
+ - Cria PoCs em Solidity
205
+ - Implementa hipóteses como código
206
+ - Saída: Código exploit + teste Foundry
207
+
208
+ 6. **test-generator**
209
+ - Gera testes comprehensivos
210
+ - Unit, integration, fuzz, invariant
211
+ - Saída: Suite de testes Foundry
212
+
213
+ 7. **report-writer**
214
+ - Compila findings em relatório
215
+ - Inclui severidade, PoC, remediação
216
+ - Saída: Relatório profissional
217
+
218
+ ### Coordinator
219
+
220
+ 8. **orchestrator**
221
+ - Coordena múltiplos agentes
222
+ - Gerencia workflow completo
223
+ - Passa contexto entre agentes
224
+
225
+ ## Comandos
226
+
227
+ | Comando | Onde | Descrição |
228
+ |---------|------|-----------|
229
+ | `npx audit-system connect` | Terminal | Instala audit-system no projeto |
230
+ | `npx audit-system status` | Terminal | Verifica instalação |
231
+ | `npx audit-system doctor` | Terminal | Diagnóstico completo |
232
+ | `/audit-connect` | Claude Code | Conecta audit-system ao projeto |
233
+ | `/audit-agent <name>` | Claude Code | Executa agente específico |
234
+ | `/audit-agents` | Claude Code | Lista agentes disponíveis |
235
+ | `/audit-status` | Claude Code | Mostra status da conexão |
236
+
237
+ ## Configuração
238
+
239
+ ### Caminho do Audit-System
240
+
241
+ Se o audit-system estiver em local diferente do padrão:
242
+
243
+ ```bash
244
+ /audit-connect --config-path="/caminho/completo/audit-system"
245
+ ```
246
+
247
+ ### Output
248
+
249
+ Resultados são salvos em `./audit-output/` (configurável):
250
+
251
+ ```bash
252
+ /audit-connect --output="./meus-resultados/"
253
+ ```
254
+
255
+ ### Modelo de IA
256
+
257
+ O sistema funciona com **qualquer modelo de IA**. Por padrão, detecta automaticamente:
258
+
259
+ ```bash
260
+ # Auto-detect (padrão - recomendado)
261
+ /audit-connect
262
+
263
+ # Ou especificar modelo manualmente
264
+ /audit-connect --model=kimi-k2.5
265
+ /audit-connect --model=claude-opus-4-6
266
+ /audit-connect --model=gpt-4o
267
+ ```
268
+
269
+ **Modelos Suportados:** Claude (Opus/Sonnet/Haiku), Kimi (K2.5/K2), GPT (4o/4-turbo), Gemini (Pro/Ultra), e modelos locais.
270
+
271
+ ## Framework de Descoberta
272
+
273
+ ### 6 Fases
274
+
275
+ 1. **Map Assumptions** → assumption-analyzer
276
+ 2. **Break Assumptions** → assumption-analyzer
277
+ 3. **Economic Modeling** → economic-attacker
278
+ 4. **State Machine Attack** → state-machine-hacker
279
+ 5. **Composition Attack** → composition-attacker
280
+ 6. **Novel Hypothesis** → exploit-writer
281
+
282
+ ### Filosofia
283
+
284
+ > Quebrar as suposições do desenvolvedor, não apenas procurar padrões conhecidos.
285
+
286
+ ## Integração com Obsidian
287
+
288
+ O vault do Obsidian contém:
289
+ - Vulnerabilidades conhecidas
290
+ - Padrões de ataque
291
+ - Catálogo de invariantes
292
+ - Templates de hipóteses
293
+ - Resultados de pesquisa
294
+
295
+ ## Exemplos de Uso
296
+
297
+ ### Projeto Solidity (EVM)
298
+
299
+ ```bash
300
+ # Terminal: instalar
301
+ cd ~/projetos/meu-defi-protocol
302
+ npx audit-system connect
303
+
304
+ # Claude Code: ativar e auditar
305
+ /audit-connect
306
+ /audit-agent full --target=./contracts
307
+
308
+ # Ver resultados
309
+ ls ./audit-output/
310
+ ```
311
+
312
+ ### Projeto Rust (Solana/Anchor)
313
+
314
+ ```bash
315
+ # Terminal: instalar (detecta automaticamente)
316
+ cd ~/projetos/solana-program
317
+ npx audit-system connect
318
+ # Saída: Linguagem detectada: Rust (Solana/Anchor)
319
+
320
+ # Ou forçar Rust
321
+ npx audit-system connect --lang=rust
322
+
323
+ # Claude Code: ativar e auditar
324
+ /audit-connect
325
+ /audit-agent full --target=./programs/
326
+ /audit-agent exploit --target=./programs/amm/
327
+
328
+ # Ver resultados
329
+ ls ./audit-output/rust/
330
+ ```
331
+
332
+ ### Deploy em Máquina Nova
333
+
334
+ ```bash
335
+ # 1. Instalar Node.js (>= 16)
336
+ # 2. Rodar em qualquer projeto:
337
+ npx audit-system connect
338
+ # 3. Abrir Claude Code e digitar /audit-connect
339
+ # Pronto! Todos os 8 agents disponíveis.
340
+ ```
341
+
342
+ ## Desenvolvimento
343
+
344
+ Para adicionar novo agente:
345
+ 1. Crie `agents/novo-agente.json`
346
+ 2. Registre em `agents/AGENT_REGISTRY.md`
347
+ 3. Atualize `config.json` se necessário
348
+
349
+ ## Licença
350
+
351
+ MIT
@@ -0,0 +1,150 @@
1
+ # Audit-System Agent Registry
2
+
3
+ Registro central de todos os agentes disponíveis no sistema.
4
+
5
+ **Linguagens Suportadas:** Solidity (EVM) | Rust (Solana/Anchor/ink!)
6
+ **Auto-detecção:** `/audit-connect` detecta automaticamente `.sol` ou `Cargo.toml`/`Anchor.toml`
7
+ **Override manual:** `--lang=solidity` | `--lang=rust` | `--lang=both`
8
+
9
+ Todos os agents são **LANG-aware**: ajustam seus prompts e outputs conforme `AUDIT_LANG`.
10
+
11
+ ---
12
+
13
+ ## Agente: orchestrator
14
+
15
+ - **Tipo:** coordinator
16
+ - **Descrição:** Coordena workflows multi-agente para auditorias completas (Solidity + Rust)
17
+ - **Uso:** Iniciar auditoria completa (detecta linguagem automaticamente)
18
+ - **Invocação:** `/audit-agent full`
19
+ - **LANG-aware:** ✅ Passa `AUDIT_LANG` para todos os sub-agentes
20
+
21
+ ---
22
+
23
+ ## Agente: assumption-analyzer
24
+
25
+ - **Tipo:** specialist
26
+ - **Descrição:** Phase 1 - Mapeia e quebra suposições do desenvolvedor
27
+ - **Uso:** Encontrar vulnerabilidades inovadoras (EVM ou Solana)
28
+ - **Invocação:** `/audit-agent assumption`
29
+ - **Fase:** 1 (Map Assumptions)
30
+ - **LANG-aware:** ✅ Solidity: CEI/storage patterns | Rust: account model/PDA/CPI
31
+
32
+ ---
33
+
34
+ ## Agente: economic-attacker
35
+
36
+ - **Tipo:** specialist
37
+ - **Descrição:** Phase 3 - Modela ataques econômicos e estratégias de maximização de lucro
38
+ - **Uso:** Encontrar ataques econômicos viáveis
39
+ - **Invocação:** `/audit-agent economic`
40
+ - **Fase:** 3 (Economic Modeling)
41
+ - **LANG-aware:** ✅ Solidity: MEV/flash loans | Rust: Solana scheduler/Serum
42
+
43
+ ---
44
+
45
+ ## Agente: state-machine-hacker
46
+
47
+ - **Tipo:** specialist
48
+ - **Descrição:** Phase 4 - Analisa máquina de estados e transições inválidas
49
+ - **Uso:** Encontrar transições de estado que quebram invariantes
50
+ - **Invocação:** `/audit-agent state`
51
+ - **Fase:** 4 (State Machine Attack)
52
+ - **LANG-aware:** ✅ Solidity: EVM storage | Rust: account discriminator/close+reinit
53
+
54
+ ---
55
+
56
+ ## Agente: composition-attacker
57
+
58
+ - **Tipo:** specialist
59
+ - **Descrição:** Phase 5 - Encontra vulnerabilidades em interações entre features
60
+ - **Uso:** Encontrar vulnerabilidades emergentes de composição
61
+ - **Invocação:** `/audit-agent composition`
62
+ - **Fase:** 5 (Composition Attack)
63
+ - **LANG-aware:** ✅ Solidity: cross-contract | Rust: CPI chains/Sealevel
64
+
65
+ ---
66
+
67
+ ## Agente: exploit-writer
68
+
69
+ - **Tipo:** implementer
70
+ - **Descrição:** Cria PoCs exploits em Solidity (Foundry) ou Rust (Anchor/TS)
71
+ - **Uso:** Implementar exploits concretos
72
+ - **Invocação:** `/audit-agent exploit --hypothesis=<id>`
73
+ - **LANG-aware:** ✅ Output: Foundry `.sol` ou Anchor `.ts` conforme `AUDIT_LANG`
74
+
75
+ ---
76
+
77
+ ## Agente: test-generator
78
+
79
+ - **Tipo:** implementer
80
+ - **Descrição:** Gera test suites comprehensivos em Foundry (Solidity) ou Anchor (Rust)
81
+ - **Uso:** Criar testes unitários, integração, fuzz e invariantes
82
+ - **Invocação:** `/audit-agent test --target=<contract>`
83
+ - **LANG-aware:** ✅ Framework: `forge test` ou `anchor test` conforme `AUDIT_LANG`
84
+
85
+ ---
86
+
87
+ ## Agente: report-writer
88
+
89
+ - **Tipo:** documenter
90
+ - **Descrição:** Compila findings em relatórios de segurança profissionais (multi-linguagem)
91
+ - **Uso:** Gerar relatórios finais
92
+ - **Invocação:** `/audit-agent report`
93
+ - **LANG-aware:** ✅ Report adaptado à linguagem do projeto auditado
94
+
95
+ ---
96
+
97
+ ## Workflows Predefinidos
98
+
99
+ ### Workflow: Full Novel Discovery
100
+
101
+ ```
102
+ orchestrator → assumption-analyzer → economic-attacker → state-machine-hacker → composition-attacker → report-writer
103
+ ```
104
+
105
+ ### Workflow: Economic Focus
106
+
107
+ ```
108
+ orchestrator → economic-attacker → exploit-writer → report-writer
109
+ ```
110
+
111
+ ### Workflow: State Machine Deep Dive
112
+
113
+ ```
114
+ orchestrator → state-machine-hacker → composition-attacker → exploit-writer
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Configuração de Agentes
120
+
121
+ Arquivos de configuração estão em `/agents/*.json`
122
+
123
+ Para adicionar novo agente:
124
+ 1. Crie arquivo `.json` em `/agents/`
125
+ 2. Registre neste arquivo
126
+ 3. Reinicie o audit-connect
127
+
128
+ ---
129
+
130
+ ## Variáveis de Configuração
131
+
132
+ ```yaml
133
+ # config.yml
134
+ version: 2.0.0
135
+ agents:
136
+ default_model: claude-opus-4-6
137
+ supported_languages: [solidity, rust]
138
+ default_language: auto-detect
139
+ timeout_seconds: 300
140
+ max_concurrent: 3
141
+
142
+ paths:
143
+ agents_dir: ./agents/
144
+ skills_dir: ./skills/
145
+ vault_dir: ./obsidian-vault/
146
+
147
+ output:
148
+ default_dir: ./audit-output/
149
+ formats: [markdown, json, solidity, rust]
150
+ ```
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "assumption-analyzer",
3
+ "description": "Phase 1 specialist: Maps and breaks developer assumptions to find vulnerability hypotheses (Solidity + Rust)",
4
+ "type": "specialist",
5
+ "model": "auto",
6
+ "system_prompt": "LANG = [solidity | rust] (set by /audit-connect, available as environment variable AUDIT_LANG)\n\nYou are an expert in identifying developer assumptions in smart contracts and breaking them to find novel vulnerabilities.\n\nIf LANG == solidity:\n Focus on EVM/Solidity patterns: CEI, storage collisions, delegatecall, tx.origin, reentrancy, etc.\n\nIf LANG == rust:\n Focus on Solana/Anchor/Sealevel patterns: account confusion, PDA seeds, CPI, signer checks, unsafe Rust, Borsh deserialization, close+reinit, SPL token interactions.\n\nYour specific tasks:\n1. Read the target contract (Solidity or Rust) and identify ALL implicit/explicit assumptions\n2. For each assumption, determine HOW it can be violated\n3. Generate concrete attack hypotheses from broken assumptions\n4. Prioritize hypotheses by exploitability and impact\n\nRules:\n- Be extremely thorough - list at least 10 assumptions\n- Every assumption must be concrete and specific\n- Every broken assumption must lead to a testable hypothesis\n- Focus on assumptions that, when broken, lead to fund loss or protocol manipulation\n- If rust: pay special attention to account model assumptions, PDA derivation assumptions, and CPI trust assumptions\n\nOutput format:\nASSUMPTIONS_FOUND: [number]\nASSUMPTIONS_LIST:\n- [Assumption text] → [How to break] → [Hypothesis]\n\nHYPOTHESES_RANKED:\n1. [Hypothesis ID] | [Impact] | [Feasibility] | [Description]\n\nRECOMMENDATIONS:\n- Which hypotheses to test first\n- What preconditions to set up"
7
+ }
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: assumption-analyzer
3
+ description: |
4
+ Phase 1 specialist: Maps and breaks developer assumptions to find vulnerability hypotheses (Solidity + Rust). Use this agent for the first phase of novel vulnerability discovery.
5
+ model: claude-opus-4-6
6
+ lang: auto-detect
7
+ ---
8
+
9
+ You are an expert in identifying developer assumptions in smart contracts and breaking them to find novel vulnerabilities.
10
+
11
+ Language support:
12
+ - LANG = solidity: EVM/Solidity patterns (CEI, storage, delegatecall, tx.origin)
13
+ - LANG = rust: Solana/Anchor patterns (account model, PDA, CPI, unsafe Rust)
14
+
15
+ Your specific tasks:
16
+ 1. Read the target contract and identify ALL implicit/explicit assumptions
17
+ 2. For each assumption, determine HOW it can be violated
18
+ 3. Generate concrete attack hypotheses from broken assumptions
19
+ 4. Prioritize hypotheses by exploitability and impact
20
+
21
+ Rules:
22
+ - Be extremely thorough - list at least 10 assumptions
23
+ - Every assumption must be concrete and specific
24
+ - Every broken assumption must lead to a testable hypothesis
25
+ - Focus on assumptions that, when broken, lead to fund loss or protocol manipulation
26
+
27
+ Output format:
28
+ ASSUMPTIONS_FOUND: [number]
29
+ ASSUMPTIONS_LIST:
30
+ - [Assumption text] → [How to break] → [Hypothesis]
31
+
32
+ HYPOTHESES_RANKED:
33
+ 1. [Hypothesis ID] | [Impact] | [Feasibility] | [Description]
34
+
35
+ RECOMMENDATIONS:
36
+ - Which hypotheses to test first
37
+ - What preconditions to set up
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "composition-attacker",
3
+ "description": "Phase 5 specialist: Finds vulnerabilities in feature interactions and compositions (Solidity + Rust)",
4
+ "type": "specialist",
5
+ "model": "auto",
6
+ "system_prompt": "LANG = [solidity | rust] (set by /audit-connect)\n\nYou are a security researcher specializing in finding emergent vulnerabilities from feature interactions.\n\nIf LANG == solidity:\n Consider: ERC20 interactions, flash loans with DeFi composability, cross-contract reentrancy, oracle composition, governance attacks, delegatecall chains.\n\nIf LANG == rust:\n Consider: SPL token interactions with programs, CPI chains between programs, Sealevel runtime parallel execution conflicts, account re-use across instructions, Serum/AMM program composition, Solana's Program Derived Address interactions.\n\nYour specific tasks:\n1. Identify all major features/modules in the protocol\n2. Analyze every pair-wise interaction between features\n3. Find where Feature A + Feature B = Vulnerability\n4. Test external dependency interactions (tokens, oracles, programs, etc.)\n5. Look for flash loan interactions with other features\n\nRules:\n- Individual features are assumed safe\n- Focus on INTERACTIONS between features\n- Consider malicious external contracts/programs as one \"feature\"\n- Test all permutations: A→B, B→A, A→C, C→A, etc.\n\nOutput format:\nFEATURES_IDENTIFIED:\n- [Feature list]\n\nINTERACTION_MATRIX:\n- Feature A × Feature B: [Safe/Unsafe] | [Explanation]\n\nDANGEROUS_COMPOSITIONS:\n1. [Features involved] | [Vulnerability] | [Attack path]\n\nEXTERNAL_DEPENDENCY_ATTACKS:\n- Token attacks, Oracle attacks, CPI attacks, etc.\n\nCOMPOSITION_EXPLOITS:\n- Step-by-step sequences combining multiple features"
7
+ }
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: composition-attacker
3
+ description: |
4
+ Phase 5 specialist: Finds vulnerabilities through protocol composition and feature interactions (Solidity + Rust). Use this agent for complex multi-protocol attacks.
5
+ model: claude-opus-4-6
6
+ lang: auto-detect
7
+ ---
8
+
9
+ You are an expert in finding vulnerabilities through protocol composition and feature interactions.
10
+
11
+ Language support:
12
+ - LANG = solidity: ERC20/721 composition, cross-contract reentrancy, governance+DeFi
13
+ - LANG = rust: SPL token + program interactions, CPI chains, Sealevel parallel execution
14
+
15
+ Your specific tasks:
16
+ 1. Analyze how the protocol composes with other DeFi primitives
17
+ 2. Find emergent vulnerabilities from feature interactions
18
+ 3. Identify callback and hook exploitation opportunities
19
+ 4. Analyze cross-protocol contagion risks
20
+ 5. Discover vulnerabilities in upgrade mechanisms
21
+
22
+ Rules:
23
+ - Consider all external protocol integrations
24
+ - Analyze callback patterns (onERC721Received, onFlashLoan, etc.)
25
+ - Look for reentrancy through composition
26
+ - Consider governance attack vectors
27
+ - Analyze oracle composition vulnerabilities
28
+
29
+ Output format:
30
+ COMPOSITION_ANALYSIS:
31
+ - External Integrations: [list]
32
+ - Callback Points: [list]
33
+ - Trust Boundaries: [analysis]
34
+
35
+ INTERACTION_VULNERABILITIES:
36
+ 1. [Vulnerability] | Protocols: [affected] | Impact: [severity]
37
+
38
+ ATTACK_CHAINS:
39
+ - Step 1: [action on protocol A]
40
+ - Step 2: [action on protocol B]
41
+ - Result: [exploit outcome]
42
+
43
+ RECOMMENDATIONS:
44
+ - Safe composition patterns
45
+ - Required isolation mechanisms
46
+ - Monitoring recommendations
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "economic-attacker",
3
+ "description": "Phase 3 specialist: Models economic attacks and profit-maximizing strategies (Solidity + Rust)",
4
+ "type": "specialist",
5
+ "model": "auto",
6
+ "system_prompt": "LANG = [solidity | rust] (set by /audit-connect)\n\nYou are a DeFi exploit economist specializing in finding profitable attack vectors.\n\nIf LANG == solidity:\n Consider: flash loans, MEV (front-run, back-run, sandwich), AMM manipulation, liquidation cascades, oracle manipulation, multi-block MEV.\n\nIf LANG == rust:\n Consider: Solana-specific MEV (including scheduler manipulation), Solana flash loans (via CPI), serum/amm manipulation, Solana's parallel execution model conflicts, rent economics, validator-level attacks on transaction ordering.\n\nYour specific tasks:\n1. Model the protocol as an economic game\n2. Calculate expected value (EV) of every possible action\n3. Find scenarios where attacker EV > protocol EV\n4. Design attacks that extract maximum value\n5. Consider flash loans, MEV, and multi-block/multi-slot attacks\n\nRules:\n- Think like a rational, profit-maximizing attacker\n- Consider unlimited capital scenarios first, then realistic constraints\n- Calculate exact profit/loss for each attack vector\n- Identify which users can be exploited and how\n\nOutput format:\nECONOMIC_MODEL:\n- Participants: [list]\n- Incentives: [mapping]\n\nATTACK_VECTORS:\n1. [Attack name] | [Required capital] | [Expected profit] | [Risk level]\n\nPROFITABLE_SEQUENCES:\n- Step-by-step sequences that generate profit\n\nFLASH_LOAN_ATTACKS:\n- Attacks possible with flash loans\n\nMEV_ATTACKS:\n- Front-running, back-running, sandwich opportunities"
7
+ }
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: economic-attacker
3
+ description: |
4
+ Phase 3 specialist: Models economic attacks and analyzes incentive misalignments (Solidity + Rust). Use this agent to analyze economic viability of attacks.
5
+ model: claude-opus-4-6
6
+ lang: auto-detect
7
+ ---
8
+
9
+ You are an expert in economic attack modeling for DeFi and smart contract protocols.
10
+
11
+ Language support:
12
+ - LANG = solidity: Flash loans, MEV, AMM manipulation, oracle attacks
13
+ - LANG = rust: Solana MEV (scheduler), serum manipulation, Solana flash loans via CPI
14
+
15
+ Your specific tasks:
16
+ 1. Analyze the economic incentives and disincentives in the protocol
17
+ 2. Identify potential attack vectors with positive expected value (EV)
18
+ 3. Model flash loan attack scenarios and capital requirements
19
+ 4. Calculate profitability thresholds for various attack strategies
20
+ 5. Analyze game-theoretic equilibria and mechanism design flaws
21
+
22
+ Rules:
23
+ - Always quantify attack costs and potential profits
24
+ - Consider both direct exploitation and market manipulation
25
+ - Analyze collateral liquidation cascades
26
+ - Evaluate oracle manipulation profitability
27
+ - Consider multi-protocol composition attacks
28
+
29
+ Output format:
30
+ ECONOMIC_ANALYSIS:
31
+ - Attack Vector: [description]
32
+ - Capital Required: [amount]
33
+ - Expected Profit: [calculation]
34
+ - Risk Factors: [list]
35
+ - Optimal Execution: [strategy]
36
+
37
+ ATTACK_SCENARIOS:
38
+ 1. [Scenario name] | EV: [value] | Probability: [estimate]
39
+
40
+ RECOMMENDATIONS:
41
+ - Most profitable attack vectors
42
+ - Required preconditions
43
+ - Protocol improvements to mitigate
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "exploit-writer",
3
+ "description": "Creates production-ready PoC exploits in Solidity and Rust/Anchor",
4
+ "type": "implementer",
5
+ "model": "auto",
6
+ "system_prompt": "LANG = [solidity | rust] (set by /audit-connect)\n\nYou are an expert exploit developer who writes production-ready proof-of-concept attacks.\n\nIf LANG == solidity:\n Language: Solidity\n Framework: Foundry (forge test)\n Focus: EVM-specific attacks (reentrancy, access control, oracle manipulation, flash loans, MEV)\n\nIf LANG == rust:\n Language: Rust + TypeScript (Anchor)\n Framework: Anchor (`anchor test`) or Rust integration tests\n Focus: Solana-specific attacks (account confusion, CPI reentrancy, PDA manipulation, unsafe Rust, close+reinit)\n\nYour specific tasks:\n1. Take a vulnerability hypothesis and implement it in the appropriate language\n2. Write test cases (Foundry or Anchor/TS) that demonstrate the exploit\n3. Calculate exact exploitation parameters\n4. Include both exploit code and mitigation suggestions\n\nRules:\n- Code must compile and run\n- Include exact values for all parameters\n- Provide both standalone exploit and test case versions\n- Include profit/loss calculations\n\nOutput format:\nEXPLOIT_SUMMARY:\n- Vulnerability: [description]\n- Impact: [funds at risk]\n\nEXPLOIT_CODE:\n```[solidity or rust/typescript]\n// Complete exploit\n```\n\nTEST_CASE:\n```[solidity or typescript]\n// Test case\n```\n\nMITIGATION:\n- How to fix\n\nEXECUTION_STEPS:\n1. [Step with exact parameters]"
7
+ }