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.
- package/LICENSE +21 -0
- package/README.md +351 -0
- package/agents/AGENT_REGISTRY.md +150 -0
- package/agents/assumption-analyzer.json +7 -0
- package/agents/assumption-analyzer.md +37 -0
- package/agents/composition-attacker.json +7 -0
- package/agents/composition-attacker.md +46 -0
- package/agents/economic-attacker.json +7 -0
- package/agents/economic-attacker.md +43 -0
- package/agents/exploit-writer.json +7 -0
- package/agents/exploit-writer.md +48 -0
- package/agents/orchestrator.json +16 -0
- package/agents/orchestrator.md +46 -0
- package/agents/report-writer.json +7 -0
- package/agents/report-writer.md +52 -0
- package/agents/state-machine-hacker.json +7 -0
- package/agents/state-machine-hacker.md +43 -0
- package/agents/test-generator.json +7 -0
- package/agents/test-generator.md +49 -0
- package/cli.js +93 -0
- package/config.json +74 -0
- package/lib/detect-lang.js +109 -0
- package/lib/install.js +229 -0
- package/lib/utils.js +41 -0
- package/obsidian-vault/README.md +103 -0
- package/obsidian-vault/attack-patterns/state-inconsistency.md +90 -0
- package/obsidian-vault/exploits/_index.md +109 -0
- package/obsidian-vault/exploits/beanstalk-2022.md +334 -0
- package/obsidian-vault/exploits/nomad-2022.md +295 -0
- package/obsidian-vault/exploits/ronin-2022.md +251 -0
- package/obsidian-vault/exploits/wormhole-2022.md +284 -0
- package/obsidian-vault/failed-hypotheses/_template.md +77 -0
- package/obsidian-vault/hypotheses/_template.md +43 -0
- package/obsidian-vault/hypotheses/bridge-protocol-template.md +254 -0
- package/obsidian-vault/hypotheses/dex-protocol-template.md +185 -0
- package/obsidian-vault/hypotheses/governance-protocol-template.md +263 -0
- package/obsidian-vault/hypotheses/lending-protocol-template.md +218 -0
- package/obsidian-vault/hypotheses/staking-protocol-template.md +223 -0
- package/obsidian-vault/invariant-catalog/defi-invariants.md +307 -0
- package/obsidian-vault/invariant-catalog/solana-invariants.md +213 -0
- package/obsidian-vault/novel-patterns/pattern-mutation-framework.md +316 -0
- package/obsidian-vault/reports/_template.md +92 -0
- package/obsidian-vault/research/cross-protocol-analysis/.gitkeep +0 -0
- package/obsidian-vault/research/emerging-threats/.gitkeep +0 -0
- package/obsidian-vault/research/protocol-specific/.gitkeep +0 -0
- package/obsidian-vault/test-strategies/fuzzing.md +75 -0
- package/obsidian-vault/vulnerabilities/access-control.md +122 -0
- package/obsidian-vault/vulnerabilities/flash-loan-attack.md +66 -0
- package/obsidian-vault/vulnerabilities/oracle-manipulation.md +135 -0
- package/obsidian-vault/vulnerabilities/reentrancy.md +141 -0
- package/obsidian-vault/vulnerabilities/rust-unsafe-deserialization.md +128 -0
- package/obsidian-vault/vulnerabilities/solana-account-confusion.md +125 -0
- package/obsidian-vault/vulnerabilities/solana-close-account.md +141 -0
- package/obsidian-vault/vulnerabilities/solana-cpi-attacks.md +131 -0
- package/obsidian-vault/vulnerabilities/solana-signer-authorization.md +119 -0
- package/package.json +56 -0
- package/skills/audit-connect.md +385 -0
- package/skills/auditor.md +280 -0
- package/skills/exploit-generator.md +394 -0
- package/skills/novel-discovery.md +551 -0
- package/skills/test-generator.md +511 -0
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
# Novel Vulnerability Discovery Skill
|
|
2
|
+
|
|
3
|
+
description: Discover unknown vulnerability classes by breaking developer assumptions through systematic 6-phase adversarial analysis
|
|
4
|
+
type: skill
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Role
|
|
8
|
+
Smart Contract Security Researcher specializing in discovering previously unknown vulnerability classes and attack vectors through systematic assumption breaking and creative reasoning.
|
|
9
|
+
|
|
10
|
+
**Línguas Suportadas:** Solidity (EVM) e Rust (Solana/Anchor, ink!/Substrate)
|
|
11
|
+
|
|
12
|
+
## Objective
|
|
13
|
+
Go beyond known vulnerability patterns to discover novel attack vectors that automated scanners and checklists miss. **DESTROY the developer's assumptions.**
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Filosofia Central
|
|
18
|
+
|
|
19
|
+
> Auditores que apenas procuram padrões conhecidos encontram bugs que qualquer scanner automatizado já encontraria.
|
|
20
|
+
> Auditores que vencem Code4rena fazem algo diferente: **quebram as suposições do desenvolvedor**.
|
|
21
|
+
>
|
|
22
|
+
> Todo contrato foi escrito por alguém que acreditava em certas verdades.
|
|
23
|
+
> A vulnerabilidade vive exatamente onde essa crença está errada.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## O Prompt Principal (copie e use direto)
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
You are an adversarial smart contract researcher.
|
|
31
|
+
Your goal is NOT to find known vulnerability patterns.
|
|
32
|
+
Your goal is to DESTROY the developer's assumptions.
|
|
33
|
+
|
|
34
|
+
CONTRACT:
|
|
35
|
+
[PASTE CONTRACT]
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
PHASE 1 — MAP DEVELOPER ASSUMPTIONS
|
|
40
|
+
|
|
41
|
+
List every implicit assumption the developer made:
|
|
42
|
+
- About who calls each function (and when)
|
|
43
|
+
- About the order operations happen in
|
|
44
|
+
- About what external contracts do
|
|
45
|
+
- About token behavior (fees? rebasing? pausing?)
|
|
46
|
+
- About economic rationality of users
|
|
47
|
+
- About what values are possible (min, max, zero)
|
|
48
|
+
- About what happens at state transitions
|
|
49
|
+
- About time (block.timestamp manipulation, delays)
|
|
50
|
+
- About atomicity (what can be front-run or sandwiched?)
|
|
51
|
+
|
|
52
|
+
For each assumption, write:
|
|
53
|
+
ASSUMPTION: [developer believes X]
|
|
54
|
+
REALITY: [X can be violated because Y]
|
|
55
|
+
HYPOTHESIS: [IF we violate X, THEN consequence Z happens]
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
PHASE 2 — BREAK EACH ASSUMPTION
|
|
60
|
+
|
|
61
|
+
For every assumption identified, ask:
|
|
62
|
+
1. Can this be violated in a SINGLE transaction?
|
|
63
|
+
2. Can this be violated across MULTIPLE transactions?
|
|
64
|
+
3. Can this be violated with a FLASH LOAN?
|
|
65
|
+
4. Can this be violated by a MALICIOUS CONTRACT as caller?
|
|
66
|
+
5. Can this be violated by FRONT-RUNNING this transaction?
|
|
67
|
+
6. Can this be violated by GRIEFING (denying service)?
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
PHASE 3 — ECONOMIC ADVERSARIAL MODELING
|
|
72
|
+
|
|
73
|
+
Imagine a purely rational, profit-maximizing attacker.
|
|
74
|
+
They have unlimited capital (flash loans), unlimited block space knowledge (MEV), and will run any sequence of operations.
|
|
75
|
+
|
|
76
|
+
For each external-facing function:
|
|
77
|
+
- What is the WORST CASE if someone calls this with maximum adversarial intent?
|
|
78
|
+
- Can this function be used to extract value from OTHER users?
|
|
79
|
+
- Can this function be used to manipulate state in a way that benefits the caller at the expense of the protocol?
|
|
80
|
+
- Is there a sequence of calls that extracts more than was deposited?
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
PHASE 4 — STATE MACHINE ATTACK
|
|
85
|
+
|
|
86
|
+
Draw the complete state machine of this contract.
|
|
87
|
+
Every variable that changes is a state dimension.
|
|
88
|
+
|
|
89
|
+
For each pair of functions (A, B):
|
|
90
|
+
- What is the state after A() then B()?
|
|
91
|
+
- What is the state after B() then A()?
|
|
92
|
+
- Are these the same? Should they be?
|
|
93
|
+
- Is there any state where B() should be unreachable but isn't?
|
|
94
|
+
- Can A() be called twice before B() processes the first call?
|
|
95
|
+
|
|
96
|
+
Identify the RAREST STATE — the combination of variable values least tested.
|
|
97
|
+
Generate an attack that reaches that state.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
PHASE 5 — COMPOSITION ATTACK
|
|
102
|
+
|
|
103
|
+
This contract does not exist in isolation.
|
|
104
|
+
It interacts with tokens, oracles, other protocols.
|
|
105
|
+
|
|
106
|
+
For each external dependency:
|
|
107
|
+
- What if this dependency LIES? (malicious token, fake oracle)
|
|
108
|
+
- What if this dependency FAILS SILENTLY? (return false instead of reverting)
|
|
109
|
+
- What if this dependency BEHAVES UNEXPECTEDLY? (fee-on-transfer, rebasing, blacklisting)
|
|
110
|
+
- What if this dependency is CONTROLLED BY THE ATTACKER? (custom ERC20 with callback)
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
PHASE 6 — NOVEL HYPOTHESIS OUTPUT
|
|
115
|
+
|
|
116
|
+
For each broken assumption, generate a hypothesis in this format:
|
|
117
|
+
|
|
118
|
+
HYPOTHESIS ID: H-[N]
|
|
119
|
+
ASSUMPTION BROKEN: [what the developer believed]
|
|
120
|
+
VIOLATION METHOD: [how to break it]
|
|
121
|
+
PRECONDITIONS: [what must be true before attack]
|
|
122
|
+
ATTACK SEQUENCE:
|
|
123
|
+
1. [step]
|
|
124
|
+
2. [step]
|
|
125
|
+
3. [step]
|
|
126
|
+
SUCCESS CONDITION: [how to know it worked]
|
|
127
|
+
ESTIMATED IMPACT: [funds at risk / protocol damage]
|
|
128
|
+
NOVELTY: [why this is NOT a standard known pattern]
|
|
129
|
+
FOUNDRY TEST SKETCH:
|
|
130
|
+
function test_H[N]_hypothesis() public {
|
|
131
|
+
// setup preconditions
|
|
132
|
+
// execute violation
|
|
133
|
+
// assert success condition
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
IMPORTANT CONSTRAINTS:
|
|
139
|
+
- Do NOT just list reentrancy, overflow, access control as findings
|
|
140
|
+
- Every hypothesis must explain WHY it's specific to THIS contract
|
|
141
|
+
- Every hypothesis must have a concrete, testable attack path
|
|
142
|
+
- Prioritize hypotheses that would NOT be found by Slither or Mythril
|
|
143
|
+
- Think like someone who has never seen this contract type before
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Prompts Especializados por Dimensão
|
|
149
|
+
|
|
150
|
+
### 1. Quebra de Suposições Econômicas
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
You are a DeFi exploit economist.
|
|
154
|
+
|
|
155
|
+
Given this contract, model the following scenario:
|
|
156
|
+
- 10 users interact with this contract optimally
|
|
157
|
+
- 1 of those users is a rational adversary with 1000x more capital
|
|
158
|
+
- The adversary can observe all pending transactions
|
|
159
|
+
|
|
160
|
+
Question: How does the adversary extract value from the other 9 users?
|
|
161
|
+
|
|
162
|
+
Focus on:
|
|
163
|
+
- Sandwich attacks
|
|
164
|
+
- Liquidity manipulation
|
|
165
|
+
- Reward dilution attacks
|
|
166
|
+
- Governance capture
|
|
167
|
+
- Price impact exploitation
|
|
168
|
+
|
|
169
|
+
Contract: [PASTE]
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
### 2. Ataque por Sequenciamento Adversarial
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
You are a transaction ordering specialist.
|
|
178
|
+
|
|
179
|
+
Given these functions in the contract:
|
|
180
|
+
[LIST ALL PUBLIC/EXTERNAL FUNCTIONS]
|
|
181
|
+
|
|
182
|
+
Generate ALL meaningful permutations of calling these functions:
|
|
183
|
+
- Which orderings create unexpected state?
|
|
184
|
+
- Which orderings allow extraction of value?
|
|
185
|
+
- Which orderings permanently break the protocol?
|
|
186
|
+
|
|
187
|
+
For each dangerous ordering, write the exact call sequence and the resulting damage.
|
|
188
|
+
|
|
189
|
+
Contract: [PASTE]
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
### 3. Ataque por Contrato Malicioso como Caller
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
You are building a malicious contract to attack this protocol.
|
|
198
|
+
|
|
199
|
+
Your malicious contract will:
|
|
200
|
+
1. Implement any interface the target expects
|
|
201
|
+
2. Use callbacks (receive, fallback, onERC721Received, etc.) maliciously
|
|
202
|
+
3. Return unexpected values from any function
|
|
203
|
+
4. Selectively revert or succeed based on conditions
|
|
204
|
+
|
|
205
|
+
Design the malicious contract that causes maximum damage.
|
|
206
|
+
Show the exact Solidity code for the attacker contract.
|
|
207
|
+
Show the attack sequence.
|
|
208
|
+
|
|
209
|
+
Target contract: [PASTE]
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
### 4. Análise de Invariantes Quebráveis
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
You are a formal verification researcher.
|
|
218
|
+
|
|
219
|
+
Identify 10 invariants that SHOULD hold in this contract.
|
|
220
|
+
Express each as: "It should NEVER be possible that [X]"
|
|
221
|
+
|
|
222
|
+
Then, for each invariant, attempt to find a sequence of valid transactions that VIOLATES it.
|
|
223
|
+
|
|
224
|
+
If you find a violation, it's a vulnerability.
|
|
225
|
+
If you can't find one, explain WHY the invariant actually holds.
|
|
226
|
+
|
|
227
|
+
Contract: [PASTE]
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
### 5. Engenharia Reversa das Suposições de Tempo
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
You are a MEV researcher.
|
|
236
|
+
|
|
237
|
+
Analyze this contract for time-dependent vulnerabilities:
|
|
238
|
+
|
|
239
|
+
1. BLOCK MANIPULATION: What can a miner/validator do by controlling block.timestamp?
|
|
240
|
+
2. FRONT-RUNNING: What transactions, if seen in mempool, can be profitably front-run?
|
|
241
|
+
3. SANDWICH: What user transactions can be sandwiched for profit?
|
|
242
|
+
4. DELAY ATTACKS: What happens if an expected transaction is delayed by N blocks?
|
|
243
|
+
5. DEADLINE GAMING: Are there deadlines that can be hit exactly to extract value?
|
|
244
|
+
6. MULTI-BLOCK: What attack requires seeing state across multiple blocks?
|
|
245
|
+
|
|
246
|
+
Contract: [PASTE]
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
### 6. Ataque por Token Malicioso
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
You are designing a malicious ERC20 to attack this protocol.
|
|
255
|
+
|
|
256
|
+
The protocol accepts user-provided tokens. Design a malicious token that:
|
|
257
|
+
|
|
258
|
+
Option A: Fee-on-transfer token
|
|
259
|
+
- Transfer sends less than expected
|
|
260
|
+
- Protocol accounting breaks
|
|
261
|
+
|
|
262
|
+
Option B: Reentrant token
|
|
263
|
+
- transfer() calls back into the protocol
|
|
264
|
+
- State is inconsistent during callback
|
|
265
|
+
|
|
266
|
+
Option C: Blacklisting token
|
|
267
|
+
- Selectively reverts transfers
|
|
268
|
+
- Causes denial of service
|
|
269
|
+
|
|
270
|
+
Option D: Rebasing token
|
|
271
|
+
- Balance changes without transfer
|
|
272
|
+
- Accounting mismatch over time
|
|
273
|
+
|
|
274
|
+
Option E: Pausable token
|
|
275
|
+
- Transfers pause mid-operation
|
|
276
|
+
- Funds locked
|
|
277
|
+
|
|
278
|
+
For each option, show exactly how the protocol breaks.
|
|
279
|
+
|
|
280
|
+
Target contract: [PASTE]
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
### 7. Ataque por Account Confusion (Rust/Solana)
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
You are a Solana security researcher specializing in account confusion vulnerabilities.
|
|
289
|
+
|
|
290
|
+
The Solana account model requires the program to validate every account passed.
|
|
291
|
+
Unlike EVM where storage is internal, Solana accounts are passed as inputs.
|
|
292
|
+
|
|
293
|
+
For this Anchor/Solana program:
|
|
294
|
+
|
|
295
|
+
1. ACCOUNT MAPPING: List every account expected by each instruction
|
|
296
|
+
2. TYPE CONFUSION: Which accounts could be swapped with another of the same type?
|
|
297
|
+
3. OWNER CHECK: Which accounts miss owner validation?
|
|
298
|
+
4. SIGNER CHECK: Which accounts should be signers but aren't checked?
|
|
299
|
+
5. WRITABLE CHECK: Which accounts should be writable but aren't?
|
|
300
|
+
6. PDA CONFUSION: Where could a user-controlled account be passed instead of a PDA?
|
|
301
|
+
|
|
302
|
+
For each finding:
|
|
303
|
+
CONFUSION: [what the developer assumed would be passed]
|
|
304
|
+
ATTACK: [what the attacker actually passes instead]
|
|
305
|
+
IMPACT: [what breaks as a result]
|
|
306
|
+
|
|
307
|
+
Target program: [PASTE RUST PROGRAM]
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
### 8. Ataque por CPI Malicioso (Rust/Solana)
|
|
313
|
+
|
|
314
|
+
```
|
|
315
|
+
You are a Solana CPI exploitation specialist.
|
|
316
|
+
|
|
317
|
+
Cross-Program Invocation (CPI) allows programs to call other programs.
|
|
318
|
+
This creates trust assumptions that can be exploited.
|
|
319
|
+
|
|
320
|
+
Analyze each CPI call in this program:
|
|
321
|
+
|
|
322
|
+
1. CPI TARGET: What program is being called?
|
|
323
|
+
2. TRUST MODEL: Why does the caller trust this program?
|
|
324
|
+
3. UNCHECKED CPI: Can the attacker control WHICH program is called?
|
|
325
|
+
4. CPI REENTRANCY: Can the called program call back into this one?
|
|
326
|
+
5. PDA SIGNING: Are PDA seeds passed correctly for signing?
|
|
327
|
+
6. RETURN VALUE: Is the CPI return checked?
|
|
328
|
+
|
|
329
|
+
For each dangerous CPI:
|
|
330
|
+
CPI_SITE: [line number and function]
|
|
331
|
+
ATTACK: [how to exploit this CPI]
|
|
332
|
+
MIGATION: [how to fix]
|
|
333
|
+
|
|
334
|
+
Target program: [PASTE RUST PROGRAM]
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
### 9. Ataque por Unsafe Rust (Rust/Solana/ink!)
|
|
340
|
+
|
|
341
|
+
```
|
|
342
|
+
You are a Rust unsafe code security auditor.
|
|
343
|
+
|
|
344
|
+
Smart contracts in Rust (Solana, ink!) sometimes use unsafe Rust
|
|
345
|
+
for performance, bypassing safety guarantees.
|
|
346
|
+
|
|
347
|
+
Analyze every `unsafe` block:
|
|
348
|
+
|
|
349
|
+
1. POINTER ARITHMETIC: Is raw pointer math bounded?
|
|
350
|
+
2. TRANSMUTE: Is std::mem::transmute safe for the types involved?
|
|
351
|
+
3. UNION: Are union fields accessed correctly?
|
|
352
|
+
4. BORSH CUSTOM: Is custom pack/unpack safe?
|
|
353
|
+
5. DEREF: Is unsafe dereference bounded?
|
|
354
|
+
6. MEMORY: Could crafted input cause undefined behavior?
|
|
355
|
+
|
|
356
|
+
For each unsafe block:
|
|
357
|
+
UNSAFE_LOCATION: [file:line]
|
|
358
|
+
RISK: [what can go wrong]
|
|
359
|
+
EXPLOITABILITY: [can an attacker trigger this?]
|
|
360
|
+
SAFE_ALTERNATIVE: [how to avoid unsafe]
|
|
361
|
+
|
|
362
|
+
Target program: [PASTE RUST PROGRAM]
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
### 10. Ataque por Reinitialization (Rust/Solana)
|
|
368
|
+
|
|
369
|
+
```
|
|
370
|
+
You are a Solana security researcher.
|
|
371
|
+
|
|
372
|
+
Solana accounts can be reused after closing. If a program
|
|
373
|
+
doesn't check if an account is already initialized, an attacker
|
|
374
|
+
can reinitialize a closed account to gain unauthorized access.
|
|
375
|
+
|
|
376
|
+
Check for:
|
|
377
|
+
1. DISCRIMINATOR CHECK: Does every instruction verify the account discriminator?
|
|
378
|
+
2. INITIALIZED FLAG: Is there a boolean `initialized` field?
|
|
379
|
+
3. ACCOUNT SIZE: Can closing and reopening change account interpretation?
|
|
380
|
+
4. VERSION CHECK: Is there a version field that prevents downgrade?
|
|
381
|
+
|
|
382
|
+
Output format:
|
|
383
|
+
REINIT_VECTORS:
|
|
384
|
+
- [Instruction] | [Account] | [Attack] | [Severity]
|
|
385
|
+
|
|
386
|
+
Target program: [PASTE RUST PROGRAM]
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Como Usar Este Sistema para Encontrar o que Outros Não Encontram
|
|
392
|
+
|
|
393
|
+
### Regra 1: Comece pelo que o desenvolvedor QUIS proteger
|
|
394
|
+
|
|
395
|
+
```
|
|
396
|
+
Pergunta: O que este contrato tenta garantir acima de tudo?
|
|
397
|
+
Resposta: [invariante principal]
|
|
398
|
+
Ataque: Como eu quebraria exatamente essa garantia?
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### Regra 2: Encontre o estado mais improvável
|
|
402
|
+
|
|
403
|
+
```
|
|
404
|
+
Pergunta: Qual combinação de variáveis o desenvolvedor NUNCA esperou ver?
|
|
405
|
+
Resposta: [estado extremo]
|
|
406
|
+
Ataque: Como eu chegaria a esse estado?
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Regra 3: Modele o usuário como adversário perfeito
|
|
410
|
+
|
|
411
|
+
```
|
|
412
|
+
Pergunta: Se eu soubesse TUDO sobre este contrato e quisesse extrair o máximo,
|
|
413
|
+
o que eu faria?
|
|
414
|
+
Resposta: [sequência de ações]
|
|
415
|
+
Verificação: Isso é possível? Quais precondições?
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Regra 4: Pergunte "e se o externo mentir?"
|
|
419
|
+
|
|
420
|
+
```
|
|
421
|
+
Para cada dependência externa:
|
|
422
|
+
- E se o token não transferir o que disse?
|
|
423
|
+
- E se o oracle retornar um preço fabricado?
|
|
424
|
+
- E se o contrato chamado fizer reentrância?
|
|
425
|
+
- E se o contrato chamado reverter na hora errada?
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### Regra 5: Force as transições de estado inválidas
|
|
429
|
+
|
|
430
|
+
```
|
|
431
|
+
Para cada estado S e função F:
|
|
432
|
+
- F deveria ser inválida em S?
|
|
433
|
+
- Mas é possível chamar F em S?
|
|
434
|
+
- O que acontece se for?
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
## Estrutura de Hipótese para Salvar no Obsidian
|
|
440
|
+
|
|
441
|
+
```markdown
|
|
442
|
+
# Hypothesis: [título descritivo]
|
|
443
|
+
|
|
444
|
+
## Contract
|
|
445
|
+
[nome e contexto]
|
|
446
|
+
|
|
447
|
+
## Assumption Broken
|
|
448
|
+
[o que o desenvolvedor acreditava que era verdade]
|
|
449
|
+
|
|
450
|
+
## Why It's Wrong
|
|
451
|
+
[por que essa suposição pode ser violada]
|
|
452
|
+
|
|
453
|
+
## Preconditions
|
|
454
|
+
- [ ] condition 1
|
|
455
|
+
- [ ] condition 2
|
|
456
|
+
|
|
457
|
+
## Attack Path
|
|
458
|
+
1.
|
|
459
|
+
2.
|
|
460
|
+
3.
|
|
461
|
+
|
|
462
|
+
## Success Condition
|
|
463
|
+
[como saber que funcionou]
|
|
464
|
+
|
|
465
|
+
## Impact
|
|
466
|
+
[o que o atacante ganha]
|
|
467
|
+
|
|
468
|
+
## Novelty
|
|
469
|
+
[por que isso NÃO seria encontrado por Slither/Mythril]
|
|
470
|
+
|
|
471
|
+
## Test Result
|
|
472
|
+
- [ ] Confirmed
|
|
473
|
+
- [ ] Refuted
|
|
474
|
+
- [ ] Partial
|
|
475
|
+
|
|
476
|
+
## Notes
|
|
477
|
+
[observações durante o teste]
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## Prompt de Meta-Raciocínio (o mais poderoso)
|
|
483
|
+
|
|
484
|
+
Use este quando os outros não encontrarem nada óbvio:
|
|
485
|
+
|
|
486
|
+
```
|
|
487
|
+
You have fully analyzed this contract and found no obvious vulnerabilities.
|
|
488
|
+
|
|
489
|
+
Now I want you to think differently.
|
|
490
|
+
|
|
491
|
+
Forget everything you know about smart contract security patterns.
|
|
492
|
+
Pretend you are a developer who built this contract.
|
|
493
|
+
You are proud of it. You believe it is secure.
|
|
494
|
+
|
|
495
|
+
Now: what would EMBARRASS you the most?
|
|
496
|
+
What would make you say "I can't believe I didn't think of that"?
|
|
497
|
+
What is the most creative, unexpected way this could be broken?
|
|
498
|
+
|
|
499
|
+
Think about:
|
|
500
|
+
- What you ASSUMED users would do vs what they COULD do
|
|
501
|
+
- What you ASSUMED about external systems vs what they MIGHT do
|
|
502
|
+
- What you assumed about TIMING that an adversary could violate
|
|
503
|
+
- What ECONOMIC behavior you didn't model
|
|
504
|
+
|
|
505
|
+
Give me 3 hypotheses that would embarrass the developer.
|
|
506
|
+
Make them specific, testable, and creative.
|
|
507
|
+
|
|
508
|
+
Contract: [PASTE]
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
---
|
|
512
|
+
|
|
513
|
+
## Usage Instructions
|
|
514
|
+
|
|
515
|
+
### When to Use Novel Discovery
|
|
516
|
+
- After standard vulnerability checks find nothing
|
|
517
|
+
- When auditing novel protocol designs
|
|
518
|
+
- When high security is critical (treasury, governance)
|
|
519
|
+
- During bug bounty triage for complex reports
|
|
520
|
+
|
|
521
|
+
### Workflow Integration
|
|
522
|
+
```
|
|
523
|
+
Standard Audit Pass
|
|
524
|
+
↓ (if nothing found OR for high-security targets)
|
|
525
|
+
Novel Discovery Pass
|
|
526
|
+
↓
|
|
527
|
+
Apply 6-Phase Framework
|
|
528
|
+
↓
|
|
529
|
+
Generate Hypotheses
|
|
530
|
+
↓
|
|
531
|
+
Rank by Feasibility
|
|
532
|
+
↓
|
|
533
|
+
Test Top 3
|
|
534
|
+
↓
|
|
535
|
+
Document Results in obsidian-vault/hypotheses/
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
### Success Metrics
|
|
539
|
+
- **Discovery Rate:** At least 1 novel hypothesis per complex contract
|
|
540
|
+
- **Validation Rate:** 20% of hypotheses should be exploitable
|
|
541
|
+
- **Novelty Score:** Hypothesis should not match known CVEs
|
|
542
|
+
- **Impact:** Exploitable hypotheses should have HIGH or CRITICAL impact
|
|
543
|
+
|
|
544
|
+
---
|
|
545
|
+
|
|
546
|
+
## Related Resources
|
|
547
|
+
|
|
548
|
+
- [[../obsidian-vault/invariant-catalog/defi-invariants]] — Common invariants to test
|
|
549
|
+
- [[../obsidian-vault/novel-patterns/pattern-mutation-framework]] — Pattern mutation strategies
|
|
550
|
+
- [[../obsidian-vault/hypotheses/_template]] — Hypothesis documentation template
|
|
551
|
+
- [[../obsidian-vault/failed-hypotheses/_template]] — Learn from failed attempts
|