solidity-argus 0.3.7 → 0.5.7
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/AGENTS.md +13 -6
- package/README.md +24 -12
- package/package.json +7 -3
- package/skills/checklists/cyfrin-best-practices-runtime/SKILL.md +1 -0
- package/skills/checklists/cyfrin-best-practices-upgrades/SKILL.md +1 -0
- package/skills/checklists/cyfrin-defi-core/SKILL.md +1 -0
- package/skills/checklists/cyfrin-defi-integrations/SKILL.md +1 -0
- package/skills/checklists/cyfrin-gas/SKILL.md +1 -0
- package/skills/checklists/general-audit/SKILL.md +1 -0
- package/skills/methodology/audit-workflow/SKILL.md +1 -0
- package/skills/methodology/report-template/SKILL.md +1 -0
- package/skills/methodology/severity-classification/SKILL.md +1 -0
- package/skills/protocol-patterns/amm-dex/SKILL.md +1 -0
- package/skills/protocol-patterns/bridges-cross-chain/SKILL.md +1 -0
- package/skills/protocol-patterns/dao-governance/SKILL.md +1 -0
- package/skills/protocol-patterns/lending-borrowing/SKILL.md +1 -0
- package/skills/protocol-patterns/staking-vesting/SKILL.md +1 -0
- package/skills/vulnerability-patterns/flash-loan-attacks/SKILL.md +0 -50
- package/skills/vulnerability-patterns/oracle-manipulation/SKILL.md +0 -63
- package/src/agents/argus-prompt.ts +98 -33
- package/src/agents/pythia-prompt.ts +24 -2
- package/src/agents/scribe-prompt.ts +34 -10
- package/src/agents/sentinel-prompt.ts +19 -0
- package/src/agents/themis-prompt.ts +110 -0
- package/src/cli/commands/doctor.ts +29 -17
- package/src/cli/commands/install.ts +74 -33
- package/src/config/loader.ts +29 -5
- package/src/config/schema.ts +45 -45
- package/src/constants/defaults.ts +1 -0
- package/src/create-hooks.ts +806 -173
- package/src/create-managers.ts +4 -2
- package/src/create-tools.ts +5 -1
- package/src/features/audit-enforcer/audit-enforcer.ts +1 -11
- package/src/features/background-agent/background-manager.ts +32 -5
- package/src/features/error-recovery/tool-error-recovery.ts +1 -0
- package/src/features/persistent-state/audit-state-manager.ts +272 -29
- package/src/features/persistent-state/event-sink.ts +96 -25
- package/src/features/persistent-state/findings-materializer.ts +68 -2
- package/src/features/persistent-state/global-run-index.ts +86 -8
- package/src/features/persistent-state/index.ts +7 -1
- package/src/features/persistent-state/run-finalizer.ts +116 -7
- package/src/features/persistent-state/run-pruner.ts +93 -0
- package/src/hooks/agent-tracker.ts +14 -2
- package/src/hooks/compaction-hook.ts +7 -16
- package/src/hooks/config-handler.ts +83 -29
- package/src/hooks/context-budget.ts +4 -5
- package/src/hooks/event-hook.ts +213 -57
- package/src/hooks/knowledge-sync-hook.ts +2 -3
- package/src/hooks/safe-create-hook.ts +13 -1
- package/src/hooks/system-prompt-hook.ts +20 -39
- package/src/hooks/tool-tracking-hook.ts +602 -323
- package/src/index.ts +15 -1
- package/src/knowledge/scvd-client.ts +2 -4
- package/src/knowledge/scvd-errors.ts +25 -2
- package/src/knowledge/scvd-index.ts +7 -5
- package/src/knowledge/scvd-sync.ts +6 -6
- package/src/managers/types.ts +20 -2
- package/src/shared/agent-names.ts +23 -0
- package/src/shared/audit-artifact-resolver.ts +8 -3
- package/src/shared/audit-phases.ts +12 -0
- package/src/shared/cache-paths.ts +41 -0
- package/src/shared/drop-diagnostics.ts +2 -2
- package/src/shared/forge-errors.ts +31 -0
- package/src/shared/forge-runner.ts +30 -0
- package/src/shared/format-error.ts +3 -0
- package/src/shared/index.ts +9 -0
- package/src/shared/key-tools.ts +39 -0
- package/src/shared/logger.ts +7 -7
- package/src/shared/path-containment.ts +25 -0
- package/src/shared/path-utils.ts +11 -0
- package/src/shared/report-path-resolver.ts +4 -2
- package/src/shared/safe-emit.ts +24 -0
- package/src/shared/token-utils.ts +5 -0
- package/src/shared/type-guards.ts +8 -0
- package/src/shared/validation-constants.ts +52 -0
- package/src/skills/analysis/cluster.ts +1 -114
- package/src/skills/analysis/normalize.ts +2 -114
- package/src/skills/analysis/stopwords.ts +109 -0
- package/src/skills/argus-skill-resolver.ts +6 -3
- package/src/solodit-lifecycle.ts +153 -37
- package/src/state/adapters.ts +60 -66
- package/src/state/finding-aggregation.ts +6 -8
- package/src/state/finding-fingerprint.ts +1 -1
- package/src/state/finding-store.ts +31 -9
- package/src/state/index.ts +1 -1
- package/src/state/projectors.ts +27 -19
- package/src/state/schemas.ts +8 -32
- package/src/state/types.ts +3 -0
- package/src/tools/contract-analyzer-tool.ts +4 -6
- package/src/tools/forge-coverage-tool.ts +10 -35
- package/src/tools/forge-fuzz-tool.ts +21 -51
- package/src/tools/forge-test-tool.ts +25 -47
- package/src/tools/gas-analysis-tool.ts +12 -41
- package/src/tools/pattern-checker-tool.ts +37 -15
- package/src/tools/pattern-loader.ts +18 -4
- package/src/tools/persist-deduped-tool.ts +94 -0
- package/src/tools/proxy-detection-tool.ts +35 -34
- package/src/tools/read-findings-tool.ts +390 -0
- package/src/tools/record-finding-tool.ts +130 -25
- package/src/tools/report-generator-tool.ts +475 -327
- package/src/tools/report-preflight.ts +5 -1
- package/src/tools/slither-tool.ts +55 -16
- package/src/tools/solodit-search-tool.ts +260 -112
- package/src/tools/sync-knowledge-tool.ts +2 -3
- package/src/utils/solidity-parser.ts +39 -24
- package/src/features/migration/index.ts +0 -14
- package/src/features/migration/migration-adapter.ts +0 -151
- package/src/features/migration/parity-telemetry.ts +0 -133
package/AGENTS.md
CHANGED
|
@@ -11,27 +11,34 @@ CLI: `argus doctor`, `argus init`, `argus install`.
|
|
|
11
11
|
## argus
|
|
12
12
|
|
|
13
13
|
**Role**: Primary security audit orchestrator
|
|
14
|
-
**Description**: Argus Panoptes, the All-Seeing Guardian. Coordinates full Solidity security audits by dispatching Sentinel (analysis), Pythia (research),
|
|
14
|
+
**Description**: Argus Panoptes, the All-Seeing Guardian. Coordinates full Solidity security audits by dispatching Sentinel (analysis), Pythia (research), Scribe (reporting), and Themis (validation). Follows a rigorous 7-step methodology: Reconnaissance, Automated Scanning, Manual Review, Attack Surface Mapping, Vulnerability Research, Testing & Verification, and Reporting.
|
|
15
15
|
**Model**: anthropic/claude-opus-4-6
|
|
16
|
-
**Tools**:
|
|
16
|
+
**Tools**: 14 orchestrator-accessible argus_* tools (argus_slither_analyze, argus_analyze_contract, argus_check_patterns, argus_proxy_detection, argus_solodit_search, argus_forge_test, argus_gas_analysis, argus_forge_fuzz, argus_forge_coverage, argus_skill_load, argus_generate_report, argus_record_finding, argus_read_findings, argus_sync_knowledge). `argus_persist_deduped` is reserved for Scribe.
|
|
17
17
|
|
|
18
18
|
## sentinel
|
|
19
19
|
|
|
20
20
|
**Role**: Static analysis and testing specialist
|
|
21
21
|
**Description**: Finds vulnerabilities through Slither static analysis, Foundry testing, fuzzing, and pattern matching. The tactical executor — runs tools, writes PoC tests, and verifies findings. Dispatched by Argus during Automated Scanning and Testing & Verification phases.
|
|
22
22
|
**Model**: anthropic/claude-sonnet-4-6
|
|
23
|
-
**Tools**: argus_slither_analyze, argus_forge_test, argus_gas_analysis, argus_forge_fuzz, argus_forge_coverage, argus_analyze_contract, argus_check_patterns, argus_proxy_detection, skill
|
|
23
|
+
**Tools**: argus_slither_analyze, argus_forge_test, argus_gas_analysis, argus_forge_fuzz, argus_forge_coverage, argus_analyze_contract, argus_check_patterns, argus_proxy_detection, argus_record_finding, skill
|
|
24
24
|
|
|
25
25
|
## pythia
|
|
26
26
|
|
|
27
27
|
**Role**: Vulnerability researcher
|
|
28
|
-
**Description**: Consults Solodit, SCVD, and the knowledge base to find historical precedents and known attack vectors. Searches 7,769+ real-world audit findings and
|
|
28
|
+
**Description**: Consults Solodit, SCVD, and the knowledge base to find historical precedents and known attack vectors. Searches 7,769+ real-world audit findings and 51 curated vulnerability pattern files. Dispatched by Argus during Vulnerability Research phase.
|
|
29
29
|
**Model**: anthropic/claude-sonnet-4-6
|
|
30
|
-
**Tools**: argus_solodit_search, argus_check_patterns, skill
|
|
30
|
+
**Tools**: argus_solodit_search, argus_check_patterns, argus_record_finding, skill
|
|
31
31
|
|
|
32
32
|
## scribe
|
|
33
33
|
|
|
34
34
|
**Role**: Audit report writer
|
|
35
35
|
**Description**: Transforms raw findings into professional markdown audit reports. Produces structured output with severity classifications (Critical/High/Medium/Low/Informational), impact assessments, proof-of-concept steps, and actionable recommendations. Dispatched by Argus only after all analysis is complete.
|
|
36
36
|
**Model**: anthropic/claude-sonnet-4-6
|
|
37
|
-
**Tools**: argus_generate_report, skill
|
|
37
|
+
**Tools**: argus_read_findings, argus_persist_deduped, argus_generate_report, skill
|
|
38
|
+
|
|
39
|
+
## themis
|
|
40
|
+
|
|
41
|
+
**Role**: Audit quality gate
|
|
42
|
+
**Description**: Independent cross-validation agent running on GPT-5.4 (different LLM provider for reasoning diversity). Validates pipeline integrity: compares raw findings against Scribe's deduped output and the final report. Performs second-opinion research via Solodit and vulnerability skill checklists. Returns a structured verdict to Argus who makes the final decision. Dispatched by Argus after Scribe completes.
|
|
43
|
+
**Model**: openai/gpt-5.4
|
|
44
|
+
**Tools**: argus_read_findings, argus_solodit_search, argus_check_patterns, argus_skill_load, skill
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
**solidity-argus** is a security auditing plugin for [OpenCode](https://opencode.ai) that brings professional-grade Solidity smart contract auditing directly into your AI coding workflow.
|
|
12
12
|
|
|
13
|
-
Argus Panoptes — the mythological all-seeing giant — orchestrates a team of
|
|
13
|
+
Argus Panoptes — the mythological all-seeing giant — orchestrates a team of 5 specialized AI agents to conduct comprehensive security audits: static analysis, vulnerability research, dynamic testing, professional report generation, and independent validation.
|
|
14
14
|
|
|
15
15
|
**What it does:**
|
|
16
16
|
- Runs Slither static analysis and Foundry tests automatically
|
|
@@ -42,6 +42,8 @@ Or install via npm/bun:
|
|
|
42
42
|
bun add solidity-argus
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
`solidity-argus` is Bun/OpenCode-native. The package entrypoints and CLI bins intentionally point at TypeScript source executed by Bun/OpenCode, so use `bun` or `bunx` for CLI commands rather than Node-only runners.
|
|
46
|
+
|
|
45
47
|
---
|
|
46
48
|
|
|
47
49
|
## Quick Start
|
|
@@ -67,9 +69,10 @@ Argus will automatically:
|
|
|
67
69
|
| `@sentinel` | Static analysis & testing specialist | claude-sonnet-4-6 |
|
|
68
70
|
| `@pythia` | Vulnerability researcher | claude-sonnet-4-6 |
|
|
69
71
|
| `@scribe` | Audit report writer | claude-sonnet-4-6 |
|
|
72
|
+
| `@themis` | Independent audit quality gate | gpt-5.4 |
|
|
70
73
|
|
|
71
74
|
### @argus — The Orchestrator
|
|
72
|
-
Argus Panoptes is the lead auditor. It follows a 7-step methodology (Reconnaissance, Automated Scanning, Manual Review, Attack Surface Mapping, Vulnerability Research, Testing & Verification, Reporting) and delegates to Sentinel, Pythia, and
|
|
75
|
+
Argus Panoptes is the lead auditor. It follows a 7-step methodology (Reconnaissance, Automated Scanning, Manual Review, Attack Surface Mapping, Vulnerability Research, Testing & Verification, Reporting) and delegates to Sentinel, Pythia, Scribe, and Themis as needed.
|
|
73
76
|
|
|
74
77
|
### @sentinel — The Executor
|
|
75
78
|
Runs Slither, writes and executes Foundry tests, performs fuzz testing. Your tactical executor for all dynamic and static analysis tasks.
|
|
@@ -80,6 +83,9 @@ Searches Solodit and SCVD for historical exploits, checks vulnerability pattern
|
|
|
80
83
|
### @scribe — The Reporter
|
|
81
84
|
Transforms raw findings into professional, structured markdown audit reports with severity classifications, impact assessments, and actionable recommendations.
|
|
82
85
|
|
|
86
|
+
### @themis — The Quality Gate
|
|
87
|
+
Validates the completed audit by comparing raw findings, deduped findings, and the generated report. Themis challenges false positives, severity choices, and dropped findings before final delivery.
|
|
88
|
+
|
|
83
89
|
---
|
|
84
90
|
|
|
85
91
|
## Tools
|
|
@@ -95,6 +101,10 @@ Transforms raw findings into professional, structured markdown audit reports wit
|
|
|
95
101
|
| `argus_gas_analysis` | Sentinel | Runs forge gas report analysis, parses per-function gas metrics, and identifies high-gas hotspots above configurable threshold |
|
|
96
102
|
| `argus_forge_fuzz` | Sentinel | Fuzzes specific functions with random inputs to find edge cases and invariant violations |
|
|
97
103
|
| `argus_forge_coverage` | Sentinel | Runs forge coverage analysis and returns structured per-file coverage metrics (lines, statements, branches, functions) |
|
|
104
|
+
| `argus_skill_load` | Pythia, Themis | Loads curated SKILL.md knowledge files on demand for vulnerability patterns, protocol guidance, methodology, and case studies |
|
|
105
|
+
| `argus_record_finding` | Sentinel, Pythia | Records verified manual, static-analysis, research, or testing findings into durable audit state |
|
|
106
|
+
| `argus_read_findings` | Scribe, Themis | Reads persisted findings and audit artifacts for report generation and validation |
|
|
107
|
+
| `argus_persist_deduped` | Scribe | Persists deduplicated findings before final report generation and validation |
|
|
98
108
|
| `argus_generate_report` | Scribe | Generates the final structured audit report in professional markdown format |
|
|
99
109
|
| `argus_sync_knowledge` | Argus | Syncs the local vulnerability database from SCVD (api.scvd.dev) |
|
|
100
110
|
|
|
@@ -260,7 +270,7 @@ Argus supports three distinct knowledge ingestion patterns:
|
|
|
260
270
|
**Sources:** SCVD local index, Trail of Bits companion skills
|
|
261
271
|
|
|
262
272
|
- Local index synced periodically via `argus_sync_knowledge`
|
|
263
|
-
- Cached locally in `~/.cache/solidity-argus/scvd-index.json`
|
|
273
|
+
- Cached locally in `ARGUS_CACHE_DIR` (default: `~/.cache/solidity-argus/scvd-index.json`)
|
|
264
274
|
- Refreshed on-demand when `knowledge.autoSync: true`
|
|
265
275
|
- Trail of Bits skills git-cloned on install and updated via companion plugin
|
|
266
276
|
- Example: SCVD findings indexed locally, queried without network latency
|
|
@@ -269,7 +279,7 @@ Argus supports three distinct knowledge ingestion patterns:
|
|
|
269
279
|
|
|
270
280
|
## Configuration
|
|
271
281
|
|
|
272
|
-
Create `.
|
|
282
|
+
Create `.argus/solidity-argus.jsonc` in your project root. `.opencode/solidity-argus.jsonc` remains supported as a project-level compatibility fallback:
|
|
273
283
|
|
|
274
284
|
```jsonc
|
|
275
285
|
{
|
|
@@ -277,7 +287,8 @@ Create `.opencode/solidity-argus.jsonc` in your project root:
|
|
|
277
287
|
"argus": { "model": "anthropic/claude-opus-4-6" },
|
|
278
288
|
"sentinel": { "model": "anthropic/claude-sonnet-4-6" },
|
|
279
289
|
"pythia": { "model": "anthropic/claude-sonnet-4-6" },
|
|
280
|
-
"scribe": { "model": "anthropic/claude-sonnet-4-6" }
|
|
290
|
+
"scribe": { "model": "anthropic/claude-sonnet-4-6" },
|
|
291
|
+
"themis": { "model": "openai/gpt-5.4" }
|
|
281
292
|
},
|
|
282
293
|
|
|
283
294
|
"tools": {
|
|
@@ -300,7 +311,7 @@ Create `.opencode/solidity-argus.jsonc` in your project root:
|
|
|
300
311
|
|
|
301
312
|
"solodit": {
|
|
302
313
|
"enabled": true,
|
|
303
|
-
"port":
|
|
314
|
+
"port": 54173
|
|
304
315
|
},
|
|
305
316
|
|
|
306
317
|
"disabled_hooks": [],
|
|
@@ -327,12 +338,13 @@ Argus uses a **three-channel context delivery system** to inject dynamic audit s
|
|
|
327
338
|
|
|
328
339
|
### Prompt Channel (Static Identity)
|
|
329
340
|
|
|
330
|
-
Each of the
|
|
341
|
+
Each of the 5 Argus agents has a static prompt file defining its role, methodology, and tool instructions:
|
|
331
342
|
|
|
332
343
|
- `src/agents/argus-prompt.ts` — Orchestrator methodology (7-step audit framework)
|
|
333
344
|
- `src/agents/sentinel-prompt.ts` — Static analysis & testing instructions
|
|
334
345
|
- `src/agents/pythia-prompt.ts` — Vulnerability research methodology
|
|
335
346
|
- `src/agents/scribe-prompt.ts` — Report generation format and structure
|
|
347
|
+
- `src/agents/themis-prompt.ts` — Independent validation and quality gate logic
|
|
336
348
|
|
|
337
349
|
These prompts **never change at runtime** and establish the agent's core identity and decision-making framework.
|
|
338
350
|
|
|
@@ -345,7 +357,7 @@ The `experimental.chat.system.transform` hook injects dynamic audit state into t
|
|
|
345
357
|
- Tools executed and their results
|
|
346
358
|
- Session-specific audit state (contract under review, scope, etc.)
|
|
347
359
|
|
|
348
|
-
**Critical Rule:** This hook is **Argus-family gated**. Only agents in `{argus, sentinel, pythia, scribe}` receive injected context. All other agents receive `undefined` (no injection).
|
|
360
|
+
**Critical Rule:** This hook is **Argus-family gated**. Only agents in `{argus, sentinel, pythia, scribe, themis}` receive injected context. All other agents receive `undefined` (no injection).
|
|
349
361
|
|
|
350
362
|
**Session→Agent Mapping Pattern:**
|
|
351
363
|
1. `chat.params` hook captures `(sessionID, agentName)` pairs during each turn
|
|
@@ -370,7 +382,7 @@ This channel is **lazy-loaded** — agents request skills only when needed, redu
|
|
|
370
382
|
|
|
371
383
|
- **Dynamic injection:** `system.transform` uses agent-gated dynamic audit state injection via `createSystemPromptHook` (see `src/create-hooks.ts`).
|
|
372
384
|
- **Global transforms forbidden:** No global system context injection unless agent-gated and minimal. Prevents context window overflow.
|
|
373
|
-
- **Audit state persistence:**
|
|
385
|
+
- **Audit state persistence:** Active session state is stored under `.argus/sessions/state-{sessionId}.json` and archived to `.argus/archives/argus-state.{timestamp}.json` on teardown (see `Persistent Audit State` section).
|
|
374
386
|
|
|
375
387
|
---
|
|
376
388
|
|
|
@@ -386,7 +398,7 @@ Run diagnostics and setup from the command line:
|
|
|
386
398
|
# Check that Slither, Foundry, and SCVD are available
|
|
387
399
|
argus doctor
|
|
388
400
|
|
|
389
|
-
# Generate a starter .
|
|
401
|
+
# Generate a starter .argus/solidity-argus.json config
|
|
390
402
|
argus init
|
|
391
403
|
|
|
392
404
|
# Validate SKILL.md files against schema
|
|
@@ -412,7 +424,7 @@ Config is resolved by merging three layers (last wins):
|
|
|
412
424
|
|
|
413
425
|
1. **Defaults** — Built-in sensible defaults
|
|
414
426
|
2. **User-level** — `~/.config/opencode/solidity-argus.jsonc`
|
|
415
|
-
3. **Project-level** — `.opencode/solidity-argus.jsonc`
|
|
427
|
+
3. **Project-level** — `.argus/solidity-argus.jsonc` (preferred) or `.opencode/solidity-argus.jsonc` (compatibility fallback)
|
|
416
428
|
|
|
417
429
|
### Background Agent Management
|
|
418
430
|
|
|
@@ -428,7 +440,7 @@ Background tasks (knowledge sync, long-running analysis) are tracked with config
|
|
|
428
440
|
|
|
429
441
|
### Persistent Audit State
|
|
430
442
|
|
|
431
|
-
Audit progress survives session restarts.
|
|
443
|
+
Audit progress survives session restarts. Active runs persist to `.argus/sessions/state-{sessionId}.json` and teardown snapshots are archived to `.argus/archives/argus-state.{timestamp}.json`. `.opencode` remains a read fallback during migration.
|
|
432
444
|
|
|
433
445
|
### Error Recovery
|
|
434
446
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solidity-argus",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Solidity smart contract security auditing plugin for OpenCode —
|
|
3
|
+
"version": "0.5.7",
|
|
4
|
+
"description": "Solidity smart contract security auditing plugin for OpenCode — 5 specialized agents, 15 tools (14 core + optional Solodit), and a curated vulnerability knowledge base",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"solidity",
|
|
7
7
|
"security",
|
|
@@ -21,7 +21,11 @@
|
|
|
21
21
|
"module": "./src/index.ts",
|
|
22
22
|
"types": "./src/index.ts",
|
|
23
23
|
"exports": {
|
|
24
|
-
".":
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./src/index.ts",
|
|
26
|
+
"bun": "./src/index.ts",
|
|
27
|
+
"default": "./src/index.ts"
|
|
28
|
+
},
|
|
25
29
|
"./package.json": "./package.json"
|
|
26
30
|
},
|
|
27
31
|
"bin": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cyfrin-best-practices-runtime
|
|
3
3
|
description: Cyfrin best-practice checklist focused on runtime heuristics, cross-chain concerns, and timelock controls
|
|
4
|
+
category: checklist
|
|
4
5
|
---
|
|
5
6
|
<!-- Source: Cyfrin/audit-checklist -->
|
|
6
7
|
<!-- Auto-generated from https://github.com/Cyfrin/audit-checklist -->
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cyfrin-best-practices-upgrades
|
|
3
3
|
description: Cyfrin best-practice checklist focused on proxy, upgradeability, and versioning concerns
|
|
4
|
+
category: checklist
|
|
4
5
|
---
|
|
5
6
|
<!-- Source: Cyfrin/audit-checklist -->
|
|
6
7
|
<!-- Auto-generated from https://github.com/Cyfrin/audit-checklist -->
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cyfrin-defi-core
|
|
3
3
|
description: Cyfrin DeFi checklist covering attacker mindset and protocol-level DeFi primitives
|
|
4
|
+
category: checklist
|
|
4
5
|
source_url: https://github.com/Cyfrin/audit-checklist
|
|
5
6
|
source_license: unspecified
|
|
6
7
|
imported_at: "2025-01-15T00:00:00Z"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cyfrin-defi-integrations
|
|
3
3
|
description: Cyfrin DeFi checklist covering integrations, token standards, and ecosystem-specific risks
|
|
4
|
+
category: checklist
|
|
4
5
|
---
|
|
5
6
|
<!-- Source: Cyfrin/audit-checklist -->
|
|
6
7
|
<!-- Auto-generated from https://github.com/Cyfrin/audit-checklist -->
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cyfrin-gas
|
|
3
3
|
description: Cyfrin audit checklist — gas optimization and efficiency items for Solidity smart contracts
|
|
4
|
+
category: checklist
|
|
4
5
|
---
|
|
5
6
|
<!-- Source: Cyfrin/audit-checklist -->
|
|
6
7
|
<!-- Auto-generated from https://github.com/Cyfrin/audit-checklist -->
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: audit-workflow
|
|
3
3
|
description: Five-phase Solidity audit workflow covering recon, static analysis, manual review, verification, and reporting.
|
|
4
|
+
category: methodology
|
|
4
5
|
source_url: https://github.com/DeFiFoFum/fofum-solidity-skills
|
|
5
6
|
source_license: MIT
|
|
6
7
|
imported_at: "2025-01-15T00:00:00Z"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: amm-dex
|
|
3
3
|
description: AMM and DEX security patterns covering pricing, LP accounting, MEV, and swap invariants.
|
|
4
|
+
category: protocol-pattern
|
|
4
5
|
source_url: https://github.com/DeFiFoFum/fofum-solidity-skills
|
|
5
6
|
source_license: MIT
|
|
6
7
|
imported_at: "2025-01-15T00:00:00Z"
|
|
@@ -210,53 +210,3 @@ modifier noFlashLoan() {
|
|
|
210
210
|
- [Flash Loan Attack Taxonomy (Arxiv)](https://arxiv.org/abs/2003.03810)
|
|
211
211
|
- [Beanstalk Exploit Analysis](https://rekt.news/beanstalk-rekt/)
|
|
212
212
|
- [Euler Exploit (BlockSec)](https://blocksec.com/blog/how-the-200m-euler-exploit-worked)
|
|
213
|
-
|
|
214
|
-
## Supplemental Heuristics (kadenzipfel)
|
|
215
|
-
|
|
216
|
-
## Preconditions
|
|
217
|
-
- Contract uses `block.timestamp` (or the deprecated `now` alias) for security-sensitive logic
|
|
218
|
-
- The outcome of that logic can be influenced by a timestamp shift within the manipulation window (~15s on PoW chains, slot-fixed on PoS Ethereum but variable on L2s/sidechains)
|
|
219
|
-
- OR: `block.number` is used as a proxy for elapsed time
|
|
220
|
-
|
|
221
|
-
## Vulnerable Pattern
|
|
222
|
-
```solidity
|
|
223
|
-
// Timestamp as sole randomness source
|
|
224
|
-
function roll() external {
|
|
225
|
-
// Validator can manipulate block.timestamp to bias outcome
|
|
226
|
-
uint256 result = uint256(keccak256(abi.encodePacked(block.timestamp))) % 6;
|
|
227
|
-
if (result == 0) {
|
|
228
|
-
_payWinner(msg.sender);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Tight time window vulnerable to manipulation
|
|
233
|
-
function claimBonus() external {
|
|
234
|
-
// 15-second window — validator can push timestamp to include/exclude
|
|
235
|
-
require(block.timestamp >= deadline && block.timestamp <= deadline + 15);
|
|
236
|
-
_sendBonus(msg.sender);
|
|
237
|
-
}
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
## Detection Heuristics
|
|
241
|
-
1. Search for `block.timestamp` and `now` (deprecated alias) usage
|
|
242
|
-
2. If used for randomness (e.g., fed into `keccak256` for a random value), flag immediately — this is always exploitable
|
|
243
|
-
3. If used in conditional logic, check the time window: can a ~15-second manipulation affect the outcome?
|
|
244
|
-
4. Search for `block.number` used as a time proxy (e.g., `block.number * 12` for seconds) — flag as fragile since block times change
|
|
245
|
-
5. For L2/sidechain deployments, check chain-specific timestamp guarantees — some have weaker constraints than mainnet PoS
|
|
246
|
-
|
|
247
|
-
## False Positives
|
|
248
|
-
- `block.timestamp` used only for logging or non-critical display purposes
|
|
249
|
-
- Time windows are large enough (hours/days) that a 15-second manipulation is irrelevant
|
|
250
|
-
- On PoS Ethereum mainnet, timestamps are fixed per 12-second slots — validator manipulation is constrained to slot boundaries, not arbitrary values
|
|
251
|
-
- `block.timestamp` used with a commit-reveal scheme where the timestamp alone doesn't determine the outcome
|
|
252
|
-
|
|
253
|
-
## Remediation
|
|
254
|
-
- Never use `block.timestamp` for randomness — use Chainlink VRF or another verifiable randomness oracle
|
|
255
|
-
- For time-dependent logic, ensure the acceptable window is significantly larger than the manipulation range
|
|
256
|
-
- Avoid `block.number` as a time proxy; use `block.timestamp` with appropriate tolerance
|
|
257
|
-
- On L2s/sidechains, verify chain-specific timestamp constraints before relying on `block.timestamp`
|
|
258
|
-
```solidity
|
|
259
|
-
// Safe: large time window where 15s manipulation is irrelevant
|
|
260
|
-
require(block.timestamp >= vestingEnd, "still vesting");
|
|
261
|
-
// vestingEnd is months/years away — manipulation doesn't matter
|
|
262
|
-
```
|
|
@@ -209,66 +209,3 @@ function getPriceWithCircuitBreaker() external returns (uint256) {
|
|
|
209
209
|
- [samczsun: Taking undercollateralized loans](https://samczsun.com/taking-undercollateralized-loans-for-fun-and-for-profit/)
|
|
210
210
|
- [Chainlink Best Practices](https://docs.chain.link/data-feeds/selecting-data-feeds)
|
|
211
211
|
- [Euler Oracle Manipulation (Omniscia)](https://omniscia.io/reports/euler-finance-oracle-manipulation/)
|
|
212
|
-
|
|
213
|
-
## Supplemental Heuristics (kadenzipfel)
|
|
214
|
-
|
|
215
|
-
## Preconditions
|
|
216
|
-
- Transaction inputs are visible in the public mempool before block inclusion
|
|
217
|
-
- The outcome of the function depends on transaction ordering
|
|
218
|
-
- An attacker can profit by observing and front-running (or sandwiching) the victim's transaction
|
|
219
|
-
|
|
220
|
-
## Vulnerable Pattern
|
|
221
|
-
```solidity
|
|
222
|
-
// DEX swap without slippage protection
|
|
223
|
-
function swap(address tokenIn, address tokenOut, uint256 amountIn) external {
|
|
224
|
-
// No minimum output amount — attacker sandwiches:
|
|
225
|
-
// 1. Front-run: buy tokenOut (price goes up)
|
|
226
|
-
// 2. Victim's swap executes at worse price
|
|
227
|
-
// 3. Back-run: sell tokenOut (profit from price impact)
|
|
228
|
-
uint256 amountOut = getAmountOut(amountIn);
|
|
229
|
-
IERC20(tokenIn).transferFrom(msg.sender, address(this), amountIn);
|
|
230
|
-
IERC20(tokenOut).transfer(msg.sender, amountOut);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// On-chain secret submission
|
|
234
|
-
function submitAnswer(bytes32 answer) external {
|
|
235
|
-
// Answer visible in mempool — anyone can copy it
|
|
236
|
-
require(keccak256(abi.encodePacked(answer)) == targetHash);
|
|
237
|
-
_reward(msg.sender);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// ERC20 approval race condition
|
|
241
|
-
// User approves 100, wants to change to 50
|
|
242
|
-
// Attacker sees approve(50) in mempool, spends 100, then spends 50 = 150 total
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
## Detection Heuristics
|
|
246
|
-
1. Search for DEX/swap functions: check for slippage protection (`minAmountOut` parameter) and deadline parameters — flag if absent
|
|
247
|
-
2. Search for on-chain submissions of secrets, answers, or bids — these are observable in the mempool
|
|
248
|
-
3. Search for ERC20 `approve` patterns: check if the contract sets allowance to zero before setting a new value
|
|
249
|
-
4. Look for auction/bidding logic where observing others' bids provides an advantage
|
|
250
|
-
5. Identify any function where the order of execution matters and inputs are publicly visible before inclusion
|
|
251
|
-
|
|
252
|
-
## False Positives
|
|
253
|
-
- Transaction is submitted via a private mempool (Flashbots Protect, MEV Blocker)
|
|
254
|
-
- Commit-reveal scheme is used: commitment hash submitted first, reveal in a later block
|
|
255
|
-
- Slippage protection with `minAmountOut` and `deadline` parameters are present
|
|
256
|
-
- The function's outcome is order-independent (e.g., simple deposit into a vault at a fixed rate)
|
|
257
|
-
|
|
258
|
-
## Remediation
|
|
259
|
-
- For DEX operations: require `minAmountOut` and `deadline` parameters for slippage protection
|
|
260
|
-
- For secret submissions: use commit-reveal schemes (hash commitment first, reveal later)
|
|
261
|
-
- For ERC20 approvals: use `increaseAllowance`/`decreaseAllowance` or set to zero first
|
|
262
|
-
- Consider Flashbots or private transaction relays for MEV-sensitive operations
|
|
263
|
-
```solidity
|
|
264
|
-
function swap(
|
|
265
|
-
address tokenIn, address tokenOut, uint256 amountIn,
|
|
266
|
-
uint256 minAmountOut, // Slippage protection
|
|
267
|
-
uint256 deadline // Time protection
|
|
268
|
-
) external {
|
|
269
|
-
require(block.timestamp <= deadline, "expired");
|
|
270
|
-
uint256 amountOut = getAmountOut(amountIn);
|
|
271
|
-
require(amountOut >= minAmountOut, "slippage");
|
|
272
|
-
// ... execute swap
|
|
273
|
-
}
|
|
274
|
-
```
|