Skip to content

Commit d197f79

Browse files
committed
main skill saves findings
1 parent 482964b commit d197f79

File tree

1 file changed

+27
-25
lines changed
  • plugins/building-secure-contracts/skills/cosmos-vulnerability-scanner

1 file changed

+27
-25
lines changed

plugins/building-secure-contracts/skills/cosmos-vulnerability-scanner/SKILL.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ description: "Scans Cosmos SDK blockchain modules and CosmWasm contracts for con
77

88
## Purpose
99

10-
Scan Cosmos SDK modules and CosmWasm contracts for vulnerabilities that cause chain halts, consensus failures, or fund loss. Spawns parallel scanning agents — each specializing in a vulnerability category — that write findings as individual markdown files to an output directory.
10+
Scan Cosmos SDK modules and CosmWasm contracts for vulnerabilities that cause chain halts, consensus failures, or fund loss. Spawns parallel scanning agents — each specializing in a vulnerability category — that return findings to the main skill, which then writes them as individual markdown files to an output directory.
1111

12-
**Output directory**: defaults to `.bughunt_cosmos/`. If the user specifies a different directory in their prompt, use that instead and pass it to all subagents.
12+
**Output directory**: defaults to `.bughunt_cosmos/`. If the user specifies a different directory in their prompt, use that instead.
1313

1414
## When to Use
1515

@@ -40,10 +40,10 @@ Scan Cosmos SDK modules and CosmWasm contracts for vulnerabilities that cause ch
4040

4141
**Entry**: Target codebase path provided by user. Codebase contains Go source (e.g., `x/` modules, `go.mod`) or Rust contracts with `cosmwasm_std`.
4242

43-
Run a **synchronous subagent** (Agent tool, `subagent_type: general-purpose`) with the full contents of [DISCOVERY.md](resources/DISCOVERY.md) as its prompt. The agent must:
43+
Run a **synchronous subagent** (Agent tool) with the full contents of [DISCOVERY.md](resources/DISCOVERY.md) as its prompt. The agent must:
4444

4545
1. Follow the Discovery workflow to explore the target codebase
46-
2. Write a `CLAUDE.md` at the target repo root with the technical inventory and threat model
46+
2. Return the full CLAUDE.md content (the technical inventory and threat model) in its response
4747
3. Return a structured summary with exactly these fields:
4848

4949
```
@@ -54,13 +54,13 @@ IBC_GO_VERSION: <version from go.mod, or "n/a">
5454
CUSTOM_MODULES: <comma-separated list of x/* modules>
5555
```
5656

57-
Save the returned values and the path to the written CLAUDE.md — these feed into Phase 2.
57+
After the subagent returns, **you** (the main skill) Write the CLAUDE.md to the target repo root. Save its path and the discovery values — these feed into Phase 2.
5858

59-
**Exit**: CLAUDE.md written. PLATFORM, IBC_ENABLED, SDK_VERSION, IBC_GO_VERSION, and CUSTOM_MODULES captured.
59+
**Exit**: CLAUDE.md written by main skill. PLATFORM, IBC_ENABLED, SDK_VERSION, IBC_GO_VERSION, and CUSTOM_MODULES captured.
6060

6161
### Phase 2: Parallel Vulnerability Scan
6262

63-
Spawn scanning agents **in a single message** for maximum parallelism. Use the Agent Prompt Template below, filling in the reference file for each agent.
63+
Spawn scanning agents **in a single message** for maximum parallelism. Use the Agent Prompt Template below, filling in the reference file for each agent. Subagents only need read access (Grep, Glob, Read) — they return findings in their response and the main skill writes the files.
6464

6565
**Always spawn these 3 agents:**
6666

@@ -78,11 +78,9 @@ Spawn scanning agents **in a single message** for maximum parallelism. Use the A
7878
| `ibc-scanner` | IBC_ENABLED is `true` | `IBC_VULNERABILITY_PATTERNS.md` |
7979
| `cosmwasm-scanner` | PLATFORM includes `wasm` | `COSMWASM_VULNERABILITY_PATTERNS.md` |
8080

81-
All scanning agents use `subagent_type: general-purpose` (need Write for finding files).
82-
8381
#### Agent Prompt Template
8482

85-
Construct each agent's prompt by replacing `{REFERENCE_FILE_PATH}` with the full path to the reference file (under `{baseDir}/resources/`), `{CLAUDE_MD_PATH}` with the path to the CLAUDE.md written in Phase 1, and `{OUTPUT_DIR}` with the output directory (default `.bughunt_cosmos`):
83+
Construct each agent's prompt by replacing `{REFERENCE_FILE_PATH}` with the full path to the reference file (under `{baseDir}/resources/`) and `{CLAUDE_MD_PATH}` with the path to the CLAUDE.md written in Phase 1:
8684

8785
~~~
8886
Perform a very thorough security scan of a Cosmos SDK codebase for specific vulnerability patterns.
@@ -116,13 +114,16 @@ SEVERITY:
116114
- Medium (DoS): unbounded pagination, tx replay, missing validation, governance spam, rate limiting, circuit breaker bypass, storage key collisions
117115
- Low (logic): rounding errors, stub handlers, event override, module ordering
118116
119-
OUTPUT — WRITING FINDINGS TO FILES:
120-
For each finding, Write a markdown file to `{OUTPUT_DIR}/` using this naming convention:
121-
`{OUTPUT_DIR}/{SEVERITY}-s{SECTION_NUM}-{kebab-description}.md`
122-
Examples: `{OUTPUT_DIR}/CRITICAL-s05-signer-mismatch-x-dex.md`, `{OUTPUT_DIR}/HIGH-s01-map-iteration-x-rewards-endblock.md`
117+
OUTPUT — RETURN FORMAT:
118+
Do NOT write any files. Return ALL findings and the summary in your response.
119+
120+
For each pattern, return one of:
121+
§NUM PATTERN_NAME: Not applicable — [one-line reason]
122+
§NUM PATTERN_NAME: FINDING (followed by the finding block below)
123123
124-
Each finding file must follow this template:
124+
For each finding, include the full content using this template:
125125
126+
FINDING_FILE: {SEVERITY}-s{SECTION_NUM}-{kebab-description}.md
126127
## [SEVERITY] Title
127128
**Location**: `file:line`
128129
**Description**: What the bug is and why it matters
@@ -131,23 +132,24 @@ Each finding file must follow this template:
131132
**Recommendation**: How to fix
132133
**References**: [links to relevant advisories or building-secure-contracts]
133134
134-
OUTPUT — RETURN VALUE:
135-
Return ONLY a summary table — one line per pattern. Do NOT include finding details in your response.
136-
Format:
137-
§NUM PATTERN_NAME: {OUTPUT_DIR}/FILENAME.md
138-
§NUM PATTERN_NAME: Not applicable — [one-line reason]
139-
If a pattern has multiple findings, use one line per finding.
140-
141135
You MUST report on ALL patterns in the reference file — do not skip any.
142136
~~~
143137

144138
**Exit**: All scanning agents returned. Each reported on every pattern in their reference file.
145139

146-
### Phase 3: Verify Completeness
140+
### Phase 3: Write Findings
141+
142+
After all scanning agents return, write finding files to the output directory (default `.bughunt_cosmos/`):
143+
144+
1. Parse each agent's response for `FINDING_FILE:` blocks
145+
2. For each finding, Write the content to `{OUTPUT_DIR}/{filename}` using the filename from `FINDING_FILE:`
146+
3. Create the output directory first if it doesn't exist
147+
148+
### Phase 4: Verify Completeness
147149

148-
After all scanning agents return, verify every pattern was assessed:
150+
After writing all findings, verify every pattern was assessed:
149151

150-
1. Collect the summary tables returned by each agent
152+
1. Collect the summary lines (§NUM entries) returned by each agent
151153
2. Check pattern counts against expected totals:
152154
- `core-scanner`: 8 patterns (§1-9, excluding §8 legacy-only)
153155
- `state-scanner`: 13 patterns (§11-23)

0 commit comments

Comments
 (0)