@bgicli/bgicli 2.2.8 → 2.2.10
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/data/skills/anthropic-algorithmic-art/SKILL.md +405 -0
- package/data/skills/anthropic-canvas-design/SKILL.md +130 -0
- package/data/skills/anthropic-claude-api/SKILL.md +243 -0
- package/data/skills/anthropic-doc-coauthoring/SKILL.md +375 -0
- package/data/skills/anthropic-docx/SKILL.md +590 -0
- package/data/skills/anthropic-frontend-design/SKILL.md +42 -0
- package/data/skills/anthropic-internal-comms/SKILL.md +32 -0
- package/data/skills/anthropic-mcp-builder/SKILL.md +236 -0
- package/data/skills/anthropic-pdf/SKILL.md +314 -0
- package/data/skills/anthropic-pptx/SKILL.md +232 -0
- package/data/skills/anthropic-skill-creator/SKILL.md +485 -0
- package/data/skills/anthropic-webapp-testing/SKILL.md +96 -0
- package/data/skills/anthropic-xlsx/SKILL.md +292 -0
- package/data/skills/arxiv-database/SKILL.md +362 -0
- package/data/skills/astropy/SKILL.md +329 -0
- package/data/skills/ctx-advanced-evaluation/SKILL.md +402 -0
- package/data/skills/ctx-bdi-mental-states/SKILL.md +311 -0
- package/data/skills/ctx-context-compression/SKILL.md +272 -0
- package/data/skills/ctx-context-degradation/SKILL.md +206 -0
- package/data/skills/ctx-context-fundamentals/SKILL.md +201 -0
- package/data/skills/ctx-context-optimization/SKILL.md +195 -0
- package/data/skills/ctx-evaluation/SKILL.md +251 -0
- package/data/skills/ctx-filesystem-context/SKILL.md +287 -0
- package/data/skills/ctx-hosted-agents/SKILL.md +260 -0
- package/data/skills/ctx-memory-systems/SKILL.md +225 -0
- package/data/skills/ctx-multi-agent-patterns/SKILL.md +257 -0
- package/data/skills/ctx-project-development/SKILL.md +291 -0
- package/data/skills/ctx-tool-design/SKILL.md +271 -0
- package/data/skills/dhdna-profiler/SKILL.md +162 -0
- package/data/skills/generate-image/SKILL.md +183 -0
- package/data/skills/geomaster/SKILL.md +365 -0
- package/data/skills/get-available-resources/SKILL.md +275 -0
- package/data/skills/hamelsmu-build-review-interface/SKILL.md +96 -0
- package/data/skills/hamelsmu-error-analysis/SKILL.md +164 -0
- package/data/skills/hamelsmu-eval-audit/SKILL.md +183 -0
- package/data/skills/hamelsmu-evaluate-rag/SKILL.md +177 -0
- package/data/skills/hamelsmu-generate-synthetic-data/SKILL.md +131 -0
- package/data/skills/hamelsmu-validate-evaluator/SKILL.md +212 -0
- package/data/skills/hamelsmu-write-judge-prompt/SKILL.md +144 -0
- package/data/skills/hf-cli/SKILL.md +174 -0
- package/data/skills/hf-mcp/SKILL.md +178 -0
- package/data/skills/hugging-face-dataset-viewer/SKILL.md +121 -0
- package/data/skills/hugging-face-datasets/SKILL.md +542 -0
- package/data/skills/hugging-face-evaluation/SKILL.md +651 -0
- package/data/skills/hugging-face-jobs/SKILL.md +1042 -0
- package/data/skills/hugging-face-model-trainer/SKILL.md +717 -0
- package/data/skills/hugging-face-paper-pages/SKILL.md +239 -0
- package/data/skills/hugging-face-paper-publisher/SKILL.md +624 -0
- package/data/skills/hugging-face-tool-builder/SKILL.md +110 -0
- package/data/skills/hugging-face-trackio/SKILL.md +115 -0
- package/data/skills/hugging-face-vision-trainer/SKILL.md +593 -0
- package/data/skills/huggingface-gradio/SKILL.md +245 -0
- package/data/skills/matlab/SKILL.md +376 -0
- package/data/skills/modal/SKILL.md +381 -0
- package/data/skills/openai-cloudflare-deploy/SKILL.md +224 -0
- package/data/skills/openai-develop-web-game/SKILL.md +149 -0
- package/data/skills/openai-doc/SKILL.md +80 -0
- package/data/skills/openai-figma/SKILL.md +42 -0
- package/data/skills/openai-figma-implement-design/SKILL.md +264 -0
- package/data/skills/openai-gh-address-comments/SKILL.md +25 -0
- package/data/skills/openai-gh-fix-ci/SKILL.md +69 -0
- package/data/skills/openai-imagegen/SKILL.md +174 -0
- package/data/skills/openai-jupyter-notebook/SKILL.md +107 -0
- package/data/skills/openai-linear/SKILL.md +87 -0
- package/data/skills/openai-netlify-deploy/SKILL.md +247 -0
- package/data/skills/openai-notion-knowledge-capture/SKILL.md +56 -0
- package/data/skills/openai-notion-meeting-intelligence/SKILL.md +60 -0
- package/data/skills/openai-notion-research-documentation/SKILL.md +59 -0
- package/data/skills/openai-notion-spec-to-implementation/SKILL.md +58 -0
- package/data/skills/openai-openai-docs/SKILL.md +69 -0
- package/data/skills/openai-pdf/SKILL.md +67 -0
- package/data/skills/openai-playwright/SKILL.md +147 -0
- package/data/skills/openai-render-deploy/SKILL.md +479 -0
- package/data/skills/openai-screenshot/SKILL.md +267 -0
- package/data/skills/openai-security-best-practices/SKILL.md +86 -0
- package/data/skills/openai-security-ownership-map/SKILL.md +206 -0
- package/data/skills/openai-security-threat-model/SKILL.md +81 -0
- package/data/skills/openai-sentry/SKILL.md +123 -0
- package/data/skills/openai-sora/SKILL.md +178 -0
- package/data/skills/openai-speech/SKILL.md +144 -0
- package/data/skills/openai-spreadsheet/SKILL.md +145 -0
- package/data/skills/openai-transcribe/SKILL.md +81 -0
- package/data/skills/openai-vercel-deploy/SKILL.md +77 -0
- package/data/skills/openai-yeet/SKILL.md +28 -0
- package/data/skills/pennylane/SKILL.md +224 -0
- package/data/skills/polars-bio/SKILL.md +374 -0
- package/data/skills/primekg/SKILL.md +97 -0
- package/data/skills/pymatgen/SKILL.md +689 -0
- package/data/skills/qiskit/SKILL.md +273 -0
- package/data/skills/qutip/SKILL.md +316 -0
- package/data/skills/recursive-decomposition/SKILL.md +185 -0
- package/data/skills/rowan/SKILL.md +427 -0
- package/data/skills/scholar-evaluation/SKILL.md +298 -0
- package/data/skills/sentry-create-alert/SKILL.md +210 -0
- package/data/skills/sentry-fix-issues/SKILL.md +126 -0
- package/data/skills/sentry-pr-code-review/SKILL.md +105 -0
- package/data/skills/sentry-python-sdk/SKILL.md +317 -0
- package/data/skills/sentry-setup-ai-monitoring/SKILL.md +217 -0
- package/data/skills/stable-baselines3/SKILL.md +297 -0
- package/data/skills/sympy/SKILL.md +498 -0
- package/data/skills/trailofbits-ask-questions-if-underspecified/SKILL.md +85 -0
- package/data/skills/trailofbits-audit-context-building/SKILL.md +302 -0
- package/data/skills/trailofbits-differential-review/SKILL.md +220 -0
- package/data/skills/trailofbits-insecure-defaults/SKILL.md +117 -0
- package/data/skills/trailofbits-modern-python/SKILL.md +333 -0
- package/data/skills/trailofbits-property-based-testing/SKILL.md +123 -0
- package/data/skills/trailofbits-semgrep-rule-creator/SKILL.md +172 -0
- package/data/skills/trailofbits-sharp-edges/SKILL.md +292 -0
- package/data/skills/trailofbits-variant-analysis/SKILL.md +142 -0
- package/data/skills/transformers.js/SKILL.md +637 -0
- package/data/skills/writing/SKILL.md +419 -0
- package/dist/bgi.js +66 -2
- package/package.json +1 -1
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: audit-context-building
|
|
3
|
+
description: Enables ultra-granular, line-by-line code analysis to build deep architectural context before vulnerability or bug finding.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Deep Context Builder Skill (Ultra-Granular Pure Context Mode)
|
|
7
|
+
|
|
8
|
+
## 1. Purpose
|
|
9
|
+
|
|
10
|
+
This skill governs **how Claude thinks** during the context-building phase of an audit.
|
|
11
|
+
|
|
12
|
+
When active, Claude will:
|
|
13
|
+
- Perform **line-by-line / block-by-block** code analysis by default.
|
|
14
|
+
- Apply **First Principles**, **5 Whys**, and **5 Hows** at micro scale.
|
|
15
|
+
- Continuously link insights → functions → modules → entire system.
|
|
16
|
+
- Maintain a stable, explicit mental model that evolves with new evidence.
|
|
17
|
+
- Identify invariants, assumptions, flows, and reasoning hazards.
|
|
18
|
+
|
|
19
|
+
This skill defines a structured analysis format (see Example: Function Micro-Analysis below) and runs **before** the vulnerability-hunting phase.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. When to Use This Skill
|
|
24
|
+
|
|
25
|
+
Use when:
|
|
26
|
+
- Deep comprehension is needed before bug or vulnerability discovery.
|
|
27
|
+
- You want bottom-up understanding instead of high-level guessing.
|
|
28
|
+
- Reducing hallucinations, contradictions, and context loss is critical.
|
|
29
|
+
- Preparing for security auditing, architecture review, or threat modeling.
|
|
30
|
+
|
|
31
|
+
Do **not** use for:
|
|
32
|
+
- Vulnerability findings
|
|
33
|
+
- Fix recommendations
|
|
34
|
+
- Exploit reasoning
|
|
35
|
+
- Severity/impact rating
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 3. How This Skill Behaves
|
|
40
|
+
|
|
41
|
+
When active, Claude will:
|
|
42
|
+
- Default to **ultra-granular analysis** of each block and line.
|
|
43
|
+
- Apply micro-level First Principles, 5 Whys, and 5 Hows.
|
|
44
|
+
- Build and refine a persistent global mental model.
|
|
45
|
+
- Update earlier assumptions when contradicted ("Earlier I thought X; now Y.").
|
|
46
|
+
- Periodically anchor summaries to maintain stable context.
|
|
47
|
+
- Avoid speculation; express uncertainty explicitly when needed.
|
|
48
|
+
|
|
49
|
+
Goal: **deep, accurate understanding**, not conclusions.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Rationalizations (Do Not Skip)
|
|
54
|
+
|
|
55
|
+
| Rationalization | Why It's Wrong | Required Action |
|
|
56
|
+
|-----------------|----------------|-----------------|
|
|
57
|
+
| "I get the gist" | Gist-level understanding misses edge cases | Line-by-line analysis required |
|
|
58
|
+
| "This function is simple" | Simple functions compose into complex bugs | Apply 5 Whys anyway |
|
|
59
|
+
| "I'll remember this invariant" | You won't. Context degrades. | Write it down explicitly |
|
|
60
|
+
| "External call is probably fine" | External = adversarial until proven otherwise | Jump into code or model as hostile |
|
|
61
|
+
| "I can skip this helper" | Helpers contain assumptions that propagate | Trace the full call chain |
|
|
62
|
+
| "This is taking too long" | Rushed context = hallucinated vulnerabilities later | Slow is fast |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 4. Phase 1 — Initial Orientation (Bottom-Up Scan)
|
|
67
|
+
|
|
68
|
+
Before deep analysis, Claude performs a minimal mapping:
|
|
69
|
+
|
|
70
|
+
1. Identify major modules/files/contracts.
|
|
71
|
+
2. Note obvious public/external entrypoints.
|
|
72
|
+
3. Identify likely actors (users, owners, relayers, oracles, other contracts).
|
|
73
|
+
4. Identify important storage variables, dicts, state structs, or cells.
|
|
74
|
+
5. Build a preliminary structure without assuming behavior.
|
|
75
|
+
|
|
76
|
+
This establishes anchors for detailed analysis.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 5. Phase 2 — Ultra-Granular Function Analysis (Default Mode)
|
|
81
|
+
|
|
82
|
+
Every non-trivial function receives full micro analysis.
|
|
83
|
+
|
|
84
|
+
### 5.1 Per-Function Microstructure Checklist
|
|
85
|
+
|
|
86
|
+
For each function:
|
|
87
|
+
|
|
88
|
+
1. **Purpose**
|
|
89
|
+
- Why the function exists and its role in the system.
|
|
90
|
+
|
|
91
|
+
2. **Inputs & Assumptions**
|
|
92
|
+
- Parameters and implicit inputs (state, sender, env).
|
|
93
|
+
- Preconditions and constraints.
|
|
94
|
+
|
|
95
|
+
3. **Outputs & Effects**
|
|
96
|
+
- Return values.
|
|
97
|
+
- State/storage writes.
|
|
98
|
+
- Events/messages.
|
|
99
|
+
- External interactions.
|
|
100
|
+
|
|
101
|
+
4. **Block-by-Block / Line-by-Line Analysis**
|
|
102
|
+
For each logical block:
|
|
103
|
+
- What it does.
|
|
104
|
+
- Why it appears here (ordering logic).
|
|
105
|
+
- What assumptions it relies on.
|
|
106
|
+
- What invariants it establishes or maintains.
|
|
107
|
+
- What later logic depends on it.
|
|
108
|
+
|
|
109
|
+
Apply per-block:
|
|
110
|
+
- **First Principles**
|
|
111
|
+
- **5 Whys**
|
|
112
|
+
- **5 Hows**
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### 5.2 Cross-Function & External Flow Analysis
|
|
117
|
+
*(Full Integration of Jump-Into-External-Code Rule)*
|
|
118
|
+
|
|
119
|
+
When encountering calls, **continue the same micro-first analysis across boundaries.**
|
|
120
|
+
|
|
121
|
+
#### Internal Calls
|
|
122
|
+
- Jump into the callee immediately.
|
|
123
|
+
- Perform block-by-block analysis of relevant code.
|
|
124
|
+
- Track flow of data, assumptions, and invariants:
|
|
125
|
+
caller → callee → return → caller.
|
|
126
|
+
- Note if callee logic behaves differently in this specific call context.
|
|
127
|
+
|
|
128
|
+
#### External Calls — Two Cases
|
|
129
|
+
|
|
130
|
+
**Case A — External Call to a Contract Whose Code Exists in the Codebase**
|
|
131
|
+
Treat as an internal call:
|
|
132
|
+
- Jump into the target contract/function.
|
|
133
|
+
- Continue block-by-block micro-analysis.
|
|
134
|
+
- Propagate invariants and assumptions seamlessly.
|
|
135
|
+
- Consider edge cases based on the *actual* code, not a black-box guess.
|
|
136
|
+
|
|
137
|
+
**Case B — External Call Without Available Code (True External / Black Box)**
|
|
138
|
+
Analyze as adversarial:
|
|
139
|
+
- Describe payload/value/gas or parameters sent.
|
|
140
|
+
- Identify assumptions about the target.
|
|
141
|
+
- Consider all outcomes:
|
|
142
|
+
- revert
|
|
143
|
+
- incorrect/strange return values
|
|
144
|
+
- unexpected state changes
|
|
145
|
+
- misbehavior
|
|
146
|
+
- reentrancy (if applicable)
|
|
147
|
+
|
|
148
|
+
#### Continuity Rule
|
|
149
|
+
Treat the entire call chain as **one continuous execution flow**.
|
|
150
|
+
Never reset context.
|
|
151
|
+
All invariants, assumptions, and data dependencies must propagate across calls.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### 5.3 Complete Analysis Example
|
|
156
|
+
|
|
157
|
+
See [FUNCTION_MICRO_ANALYSIS_EXAMPLE.md](resources/FUNCTION_MICRO_ANALYSIS_EXAMPLE.md) for a complete walkthrough demonstrating:
|
|
158
|
+
- Full micro-analysis of a DEX swap function
|
|
159
|
+
- Application of First Principles, 5 Whys, and 5 Hows
|
|
160
|
+
- Block-by-block analysis with invariants and assumptions
|
|
161
|
+
- Cross-function dependency mapping
|
|
162
|
+
- Risk analysis for external interactions
|
|
163
|
+
|
|
164
|
+
This example demonstrates the level of depth and structure required for all analyzed functions.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### 5.4 Output Requirements
|
|
169
|
+
|
|
170
|
+
When performing ultra-granular analysis, Claude MUST structure output following the format defined in [OUTPUT_REQUIREMENTS.md](resources/OUTPUT_REQUIREMENTS.md).
|
|
171
|
+
|
|
172
|
+
Key requirements:
|
|
173
|
+
- **Purpose** (2-3 sentences minimum)
|
|
174
|
+
- **Inputs & Assumptions** (all parameters, preconditions, trust assumptions)
|
|
175
|
+
- **Outputs & Effects** (returns, state writes, external calls, events, postconditions)
|
|
176
|
+
- **Block-by-Block Analysis** (What, Why here, Assumptions, First Principles/5 Whys/5 Hows)
|
|
177
|
+
- **Cross-Function Dependencies** (internal calls, external calls with risk analysis, shared state)
|
|
178
|
+
|
|
179
|
+
Quality thresholds:
|
|
180
|
+
- Minimum 3 invariants per function
|
|
181
|
+
- Minimum 5 assumptions documented
|
|
182
|
+
- Minimum 3 risk considerations for external interactions
|
|
183
|
+
- At least 1 First Principles application
|
|
184
|
+
- At least 3 combined 5 Whys/5 Hows applications
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
### 5.5 Completeness Checklist
|
|
189
|
+
|
|
190
|
+
Before concluding micro-analysis of a function, verify against the [COMPLETENESS_CHECKLIST.md](resources/COMPLETENESS_CHECKLIST.md):
|
|
191
|
+
|
|
192
|
+
- **Structural Completeness**: All required sections present (Purpose, Inputs, Outputs, Block-by-Block, Dependencies)
|
|
193
|
+
- **Content Depth**: Minimum thresholds met (invariants, assumptions, risk analysis, First Principles)
|
|
194
|
+
- **Continuity & Integration**: Cross-references, propagated assumptions, invariant couplings
|
|
195
|
+
- **Anti-Hallucination**: Line number citations, no vague statements, evidence-based claims
|
|
196
|
+
|
|
197
|
+
Analysis is complete when all checklist items are satisfied and no unresolved "unclear" items remain.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## 6. Phase 3 — Global System Understanding
|
|
202
|
+
|
|
203
|
+
After sufficient micro-analysis:
|
|
204
|
+
|
|
205
|
+
1. **State & Invariant Reconstruction**
|
|
206
|
+
- Map reads/writes of each state variable.
|
|
207
|
+
- Derive multi-function and multi-module invariants.
|
|
208
|
+
|
|
209
|
+
2. **Workflow Reconstruction**
|
|
210
|
+
- Identify end-to-end flows (deposit, withdraw, lifecycle, upgrades).
|
|
211
|
+
- Track how state transforms across these flows.
|
|
212
|
+
- Record assumptions that persist across steps.
|
|
213
|
+
|
|
214
|
+
3. **Trust Boundary Mapping**
|
|
215
|
+
- Actor → entrypoint → behavior.
|
|
216
|
+
- Identify untrusted input paths.
|
|
217
|
+
- Privilege changes and implicit role expectations.
|
|
218
|
+
|
|
219
|
+
4. **Complexity & Fragility Clustering**
|
|
220
|
+
- Functions with many assumptions.
|
|
221
|
+
- High branching logic.
|
|
222
|
+
- Multi-step dependencies.
|
|
223
|
+
- Coupled state changes across modules.
|
|
224
|
+
|
|
225
|
+
These clusters help guide the vulnerability-hunting phase.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## 7. Stability & Consistency Rules
|
|
230
|
+
*(Anti-Hallucination, Anti-Contradiction)*
|
|
231
|
+
|
|
232
|
+
Claude must:
|
|
233
|
+
|
|
234
|
+
- **Never reshape evidence to fit earlier assumptions.**
|
|
235
|
+
When contradicted:
|
|
236
|
+
- Update the model.
|
|
237
|
+
- State the correction explicitly.
|
|
238
|
+
|
|
239
|
+
- **Periodically anchor key facts**
|
|
240
|
+
Summarize core:
|
|
241
|
+
- invariants
|
|
242
|
+
- state relationships
|
|
243
|
+
- actor roles
|
|
244
|
+
- workflows
|
|
245
|
+
|
|
246
|
+
- **Avoid vague guesses**
|
|
247
|
+
Use:
|
|
248
|
+
- "Unclear; need to inspect X."
|
|
249
|
+
instead of:
|
|
250
|
+
- "It probably…"
|
|
251
|
+
|
|
252
|
+
- **Cross-reference constantly**
|
|
253
|
+
Connect new insights to previous state, flows, and invariants to maintain global coherence.
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 8. Subagent Usage
|
|
258
|
+
|
|
259
|
+
Claude may spawn subagents for:
|
|
260
|
+
- Dense or complex functions.
|
|
261
|
+
- Long data-flow or control-flow chains.
|
|
262
|
+
- Cryptographic / mathematical logic.
|
|
263
|
+
- Complex state machines.
|
|
264
|
+
- Multi-module workflow reconstruction.
|
|
265
|
+
|
|
266
|
+
Use the **`function-analyzer`** agent for per-function deep analysis.
|
|
267
|
+
It follows the full microstructure checklist, cross-function flow
|
|
268
|
+
rules, and quality thresholds defined in this skill, and enforces
|
|
269
|
+
the pure-context-building constraint.
|
|
270
|
+
|
|
271
|
+
Subagents must:
|
|
272
|
+
- Follow the same micro-first rules.
|
|
273
|
+
- Return summaries that Claude integrates into its global model.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## 9. Relationship to Other Phases
|
|
278
|
+
|
|
279
|
+
This skill runs **before**:
|
|
280
|
+
- Vulnerability discovery
|
|
281
|
+
- Classification / triage
|
|
282
|
+
- Report writing
|
|
283
|
+
- Impact modeling
|
|
284
|
+
- Exploit reasoning
|
|
285
|
+
|
|
286
|
+
It exists solely to build:
|
|
287
|
+
- Deep understanding
|
|
288
|
+
- Stable context
|
|
289
|
+
- System-level clarity
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## 10. Non-Goals
|
|
294
|
+
|
|
295
|
+
While active, Claude should NOT:
|
|
296
|
+
- Identify vulnerabilities
|
|
297
|
+
- Propose fixes
|
|
298
|
+
- Generate proofs-of-concept
|
|
299
|
+
- Model exploits
|
|
300
|
+
- Assign severity or impact
|
|
301
|
+
|
|
302
|
+
This is **pure context building** only.
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: differential-review
|
|
3
|
+
description: >
|
|
4
|
+
Performs security-focused differential review of code changes (PRs, commits, diffs).
|
|
5
|
+
Adapts analysis depth to codebase size, uses git history for context, calculates
|
|
6
|
+
blast radius, checks test coverage, and generates comprehensive markdown reports.
|
|
7
|
+
Automatically detects and prevents security regressions.
|
|
8
|
+
allowed-tools:
|
|
9
|
+
- Read
|
|
10
|
+
- Write
|
|
11
|
+
- Grep
|
|
12
|
+
- Glob
|
|
13
|
+
- Bash
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Differential Security Review
|
|
17
|
+
|
|
18
|
+
Security-focused code review for PRs, commits, and diffs.
|
|
19
|
+
|
|
20
|
+
## Core Principles
|
|
21
|
+
|
|
22
|
+
1. **Risk-First**: Focus on auth, crypto, value transfer, external calls
|
|
23
|
+
2. **Evidence-Based**: Every finding backed by git history, line numbers, attack scenarios
|
|
24
|
+
3. **Adaptive**: Scale to codebase size (SMALL/MEDIUM/LARGE)
|
|
25
|
+
4. **Honest**: Explicitly state coverage limits and confidence level
|
|
26
|
+
5. **Output-Driven**: Always generate comprehensive markdown report file
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Rationalizations (Do Not Skip)
|
|
31
|
+
|
|
32
|
+
| Rationalization | Why It's Wrong | Required Action |
|
|
33
|
+
|-----------------|----------------|-----------------|
|
|
34
|
+
| "Small PR, quick review" | Heartbleed was 2 lines | Classify by RISK, not size |
|
|
35
|
+
| "I know this codebase" | Familiarity breeds blind spots | Build explicit baseline context |
|
|
36
|
+
| "Git history takes too long" | History reveals regressions | Never skip Phase 1 |
|
|
37
|
+
| "Blast radius is obvious" | You'll miss transitive callers | Calculate quantitatively |
|
|
38
|
+
| "No tests = not my problem" | Missing tests = elevated risk rating | Flag in report, elevate severity |
|
|
39
|
+
| "Just a refactor, no security impact" | Refactors break invariants | Analyze as HIGH until proven LOW |
|
|
40
|
+
| "I'll explain verbally" | No artifact = findings lost | Always write report |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Quick Reference
|
|
45
|
+
|
|
46
|
+
### Codebase Size Strategy
|
|
47
|
+
|
|
48
|
+
| Codebase Size | Strategy | Approach |
|
|
49
|
+
|---------------|----------|----------|
|
|
50
|
+
| SMALL (<20 files) | DEEP | Read all deps, full git blame |
|
|
51
|
+
| MEDIUM (20-200) | FOCUSED | 1-hop deps, priority files |
|
|
52
|
+
| LARGE (200+) | SURGICAL | Critical paths only |
|
|
53
|
+
|
|
54
|
+
### Risk Level Triggers
|
|
55
|
+
|
|
56
|
+
| Risk Level | Triggers |
|
|
57
|
+
|------------|----------|
|
|
58
|
+
| HIGH | Auth, crypto, external calls, value transfer, validation removal |
|
|
59
|
+
| MEDIUM | Business logic, state changes, new public APIs |
|
|
60
|
+
| LOW | Comments, tests, UI, logging |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Workflow Overview
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
Pre-Analysis → Phase 0: Triage → Phase 1: Code Analysis → Phase 2: Test Coverage
|
|
68
|
+
↓ ↓ ↓ ↓
|
|
69
|
+
Phase 3: Blast Radius → Phase 4: Deep Context → Phase 5: Adversarial → Phase 6: Report
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Decision Tree
|
|
75
|
+
|
|
76
|
+
**Starting a review?**
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
├─ Need detailed phase-by-phase methodology?
|
|
80
|
+
│ └─ Read: methodology.md
|
|
81
|
+
│ (Pre-Analysis + Phases 0-4: triage, code analysis, test coverage, blast radius)
|
|
82
|
+
│
|
|
83
|
+
├─ Analyzing HIGH RISK change?
|
|
84
|
+
│ └─ Read: adversarial.md
|
|
85
|
+
│ (Phase 5: Attacker modeling, exploit scenarios, exploitability rating)
|
|
86
|
+
│
|
|
87
|
+
├─ Writing the final report?
|
|
88
|
+
│ └─ Read: reporting.md
|
|
89
|
+
│ (Phase 6: Report structure, templates, formatting guidelines)
|
|
90
|
+
│
|
|
91
|
+
├─ Looking for specific vulnerability patterns?
|
|
92
|
+
│ └─ Read: patterns.md
|
|
93
|
+
│ (Regressions, reentrancy, access control, overflow, etc.)
|
|
94
|
+
│
|
|
95
|
+
└─ Quick triage only?
|
|
96
|
+
└─ Use Quick Reference above, skip detailed docs
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Quality Checklist
|
|
102
|
+
|
|
103
|
+
Before delivering:
|
|
104
|
+
|
|
105
|
+
- [ ] All changed files analyzed
|
|
106
|
+
- [ ] Git blame on removed security code
|
|
107
|
+
- [ ] Blast radius calculated for HIGH risk
|
|
108
|
+
- [ ] Attack scenarios are concrete (not generic)
|
|
109
|
+
- [ ] Findings reference specific line numbers + commits
|
|
110
|
+
- [ ] Report file generated
|
|
111
|
+
- [ ] User notified with summary
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Integration
|
|
116
|
+
|
|
117
|
+
**audit-context-building skill:**
|
|
118
|
+
- Pre-Analysis: Build baseline context
|
|
119
|
+
- Phase 4: Deep context on HIGH RISK changes
|
|
120
|
+
|
|
121
|
+
**issue-writer skill:**
|
|
122
|
+
- Transform findings into formal audit reports
|
|
123
|
+
- Command: `issue-writer --input DIFFERENTIAL_REVIEW_REPORT.md --format audit-report`
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Example Usage
|
|
128
|
+
|
|
129
|
+
### Quick Triage (Small PR)
|
|
130
|
+
```
|
|
131
|
+
Input: 5 file PR, 2 HIGH RISK files
|
|
132
|
+
Strategy: Use Quick Reference
|
|
133
|
+
1. Classify risk level per file (2 HIGH, 3 LOW)
|
|
134
|
+
2. Focus on 2 HIGH files only
|
|
135
|
+
3. Git blame removed code
|
|
136
|
+
4. Generate minimal report
|
|
137
|
+
Time: ~30 minutes
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Standard Review (Medium Codebase)
|
|
141
|
+
```
|
|
142
|
+
Input: 80 files, 12 HIGH RISK changes
|
|
143
|
+
Strategy: FOCUSED (see methodology.md)
|
|
144
|
+
1. Full workflow on HIGH RISK files
|
|
145
|
+
2. Surface scan on MEDIUM
|
|
146
|
+
3. Skip LOW risk files
|
|
147
|
+
4. Complete report with all sections
|
|
148
|
+
Time: ~3-4 hours
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Deep Audit (Large, Critical Change)
|
|
152
|
+
```
|
|
153
|
+
Input: 450 files, auth system rewrite
|
|
154
|
+
Strategy: SURGICAL + audit-context-building
|
|
155
|
+
1. Baseline context with audit-context-building
|
|
156
|
+
2. Deep analysis on auth changes only
|
|
157
|
+
3. Blast radius analysis
|
|
158
|
+
4. Adversarial modeling
|
|
159
|
+
5. Comprehensive report
|
|
160
|
+
Time: ~6-8 hours
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## When NOT to Use This Skill
|
|
166
|
+
|
|
167
|
+
- **Greenfield code** (no baseline to compare)
|
|
168
|
+
- **Documentation-only changes** (no security impact)
|
|
169
|
+
- **Formatting/linting** (cosmetic changes)
|
|
170
|
+
- **User explicitly requests quick summary only** (they accept risk)
|
|
171
|
+
|
|
172
|
+
For these cases, use standard code review instead.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Red Flags (Stop and Investigate)
|
|
177
|
+
|
|
178
|
+
**Immediate escalation triggers:**
|
|
179
|
+
- Removed code from "security", "CVE", or "fix" commits
|
|
180
|
+
- Access control modifiers removed (onlyOwner, internal → external)
|
|
181
|
+
- Validation removed without replacement
|
|
182
|
+
- External calls added without checks
|
|
183
|
+
- High blast radius (50+ callers) + HIGH risk change
|
|
184
|
+
|
|
185
|
+
These patterns require adversarial analysis even in quick triage.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Tips for Best Results
|
|
190
|
+
|
|
191
|
+
**Do:**
|
|
192
|
+
- Start with git blame for removed code
|
|
193
|
+
- Calculate blast radius early to prioritize
|
|
194
|
+
- Generate concrete attack scenarios
|
|
195
|
+
- Reference specific line numbers and commits
|
|
196
|
+
- Be honest about coverage limitations
|
|
197
|
+
- Always generate the output file
|
|
198
|
+
|
|
199
|
+
**Don't:**
|
|
200
|
+
- Skip git history analysis
|
|
201
|
+
- Make generic findings without evidence
|
|
202
|
+
- Claim full analysis when time-limited
|
|
203
|
+
- Forget to check test coverage
|
|
204
|
+
- Miss high blast radius changes
|
|
205
|
+
- Output report only to chat (file required)
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Supporting Documentation
|
|
210
|
+
|
|
211
|
+
- **[methodology.md](methodology.md)** - Detailed phase-by-phase workflow (Phases 0-4)
|
|
212
|
+
- **[adversarial.md](adversarial.md)** - Attacker modeling and exploit scenarios (Phase 5)
|
|
213
|
+
- **[reporting.md](reporting.md)** - Report structure and formatting (Phase 6)
|
|
214
|
+
- **[patterns.md](patterns.md)** - Common vulnerability patterns reference
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
**For first-time users:** Start with [methodology.md](methodology.md) to understand the complete workflow.
|
|
219
|
+
|
|
220
|
+
**For experienced users:** Use this page's Quick Reference and Decision Tree to navigate directly to needed content.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: insecure-defaults
|
|
3
|
+
description: "Detects fail-open insecure defaults (hardcoded secrets, weak auth, permissive security) that allow apps to run insecurely in production. Use when auditing security, reviewing config management, or analyzing environment variable handling."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- Read
|
|
6
|
+
- Grep
|
|
7
|
+
- Glob
|
|
8
|
+
- Bash
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Insecure Defaults Detection
|
|
12
|
+
|
|
13
|
+
Finds **fail-open** vulnerabilities where apps run insecurely with missing configuration. Distinguishes exploitable defaults from fail-secure patterns that crash safely.
|
|
14
|
+
|
|
15
|
+
- **Fail-open (CRITICAL):** `SECRET = env.get('KEY') or 'default'` → App runs with weak secret
|
|
16
|
+
- **Fail-secure (SAFE):** `SECRET = env['KEY']` → App crashes if missing
|
|
17
|
+
|
|
18
|
+
## When to Use
|
|
19
|
+
|
|
20
|
+
- **Security audits** of production applications (auth, crypto, API security)
|
|
21
|
+
- **Configuration review** of deployment files, IaC templates, Docker configs
|
|
22
|
+
- **Code review** of environment variable handling and secrets management
|
|
23
|
+
- **Pre-deployment checks** for hardcoded credentials or weak defaults
|
|
24
|
+
|
|
25
|
+
## When NOT to Use
|
|
26
|
+
|
|
27
|
+
Do not use this skill for:
|
|
28
|
+
- **Test fixtures** explicitly scoped to test environments (files in `test/`, `spec/`, `__tests__/`)
|
|
29
|
+
- **Example/template files** (`.example`, `.template`, `.sample` suffixes)
|
|
30
|
+
- **Development-only tools** (local Docker Compose for dev, debug scripts)
|
|
31
|
+
- **Documentation examples** in README.md or docs/ directories
|
|
32
|
+
- **Build-time configuration** that gets replaced during deployment
|
|
33
|
+
- **Crash-on-missing behavior** where app won't start without proper config (fail-secure)
|
|
34
|
+
|
|
35
|
+
When in doubt: trace the code path to determine if the app runs with the default or crashes.
|
|
36
|
+
|
|
37
|
+
## Rationalizations to Reject
|
|
38
|
+
|
|
39
|
+
- **"It's just a development default"** → If it reaches production code, it's a finding
|
|
40
|
+
- **"The production config overrides it"** → Verify prod config exists; code-level vulnerability remains if not
|
|
41
|
+
- **"This would never run without proper config"** → Prove it with code trace; many apps fail silently
|
|
42
|
+
- **"It's behind authentication"** → Defense in depth; compromised session still exploits weak defaults
|
|
43
|
+
- **"We'll fix it before release"** → Document now; "later" rarely comes
|
|
44
|
+
|
|
45
|
+
## Workflow
|
|
46
|
+
|
|
47
|
+
Follow this workflow for every potential finding:
|
|
48
|
+
|
|
49
|
+
### 1. SEARCH: Perform Project Discovery and Find Insecure Defaults
|
|
50
|
+
|
|
51
|
+
Determine language, framework, and project conventions. Use this information to further discover things like secret storage locations, secret usage patterns, credentialed third-party integrations, cryptography, and any other relevant configuration. Further use information to analyze insecure default configurations.
|
|
52
|
+
|
|
53
|
+
**Example**
|
|
54
|
+
Search for patterns in `**/config/`, `**/auth/`, `**/database/`, and env files:
|
|
55
|
+
- **Fallback secrets:** `getenv.*\) or ['"]`, `process\.env\.[A-Z_]+ \|\| ['"]`, `ENV\.fetch.*default:`
|
|
56
|
+
- **Hardcoded credentials:** `password.*=.*['"][^'"]{8,}['"]`, `api[_-]?key.*=.*['"][^'"]+['"]`
|
|
57
|
+
- **Weak defaults:** `DEBUG.*=.*true`, `AUTH.*=.*false`, `CORS.*=.*\*`
|
|
58
|
+
- **Crypto algorithms:** `MD5|SHA1|DES|RC4|ECB` in security contexts
|
|
59
|
+
|
|
60
|
+
Tailor search approach based on discovery results.
|
|
61
|
+
|
|
62
|
+
Focus on production-reachable code, not test fixtures or example files.
|
|
63
|
+
|
|
64
|
+
### 2. VERIFY: Actual Behavior
|
|
65
|
+
For each match, trace the code path to understand runtime behavior.
|
|
66
|
+
|
|
67
|
+
**Questions to answer:**
|
|
68
|
+
- When is this code executed? (Startup vs. runtime)
|
|
69
|
+
- What happens if a configuration variable is missing?
|
|
70
|
+
- Is there validation that enforces secure configuration?
|
|
71
|
+
|
|
72
|
+
### 3. CONFIRM: Production Impact
|
|
73
|
+
Determine if this issue reaches production:
|
|
74
|
+
|
|
75
|
+
If production config provides the variable → Lower severity (but still a code-level vulnerability)
|
|
76
|
+
If production config missing or uses default → CRITICAL
|
|
77
|
+
|
|
78
|
+
### 4. REPORT: with Evidence
|
|
79
|
+
|
|
80
|
+
**Example report:**
|
|
81
|
+
```
|
|
82
|
+
Finding: Hardcoded JWT Secret Fallback
|
|
83
|
+
Location: src/auth/jwt.ts:15
|
|
84
|
+
Pattern: const secret = process.env.JWT_SECRET || 'default';
|
|
85
|
+
|
|
86
|
+
Verification: App starts without JWT_SECRET; secret used in jwt.sign() at line 42
|
|
87
|
+
Production Impact: Dockerfile missing JWT_SECRET
|
|
88
|
+
Exploitation: Attacker forges JWTs using 'default', gains unauthorized access
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Quick Verification Checklist
|
|
92
|
+
|
|
93
|
+
**Fallback Secrets:** `SECRET = env.get(X) or Y`
|
|
94
|
+
→ Verify: App starts without env var? Secret used in crypto/auth?
|
|
95
|
+
→ Skip: Test fixtures, example files
|
|
96
|
+
|
|
97
|
+
**Default Credentials:** Hardcoded `username`/`password` pairs
|
|
98
|
+
→ Verify: Active in deployed config? No runtime override?
|
|
99
|
+
→ Skip: Disabled accounts, documentation examples
|
|
100
|
+
|
|
101
|
+
**Fail-Open Security:** `AUTH_REQUIRED = env.get(X, 'false')`
|
|
102
|
+
→ Verify: Default is insecure (false/disabled/permissive)?
|
|
103
|
+
→ Safe: App crashes or default is secure (true/enabled/restricted)
|
|
104
|
+
|
|
105
|
+
**Weak Crypto:** MD5/SHA1/DES/RC4/ECB in security contexts
|
|
106
|
+
→ Verify: Used for passwords, encryption, or tokens?
|
|
107
|
+
→ Skip: Checksums, non-security hashing
|
|
108
|
+
|
|
109
|
+
**Permissive Access:** CORS `*`, permissions `0777`, public-by-default
|
|
110
|
+
→ Verify: Default allows unauthorized access?
|
|
111
|
+
→ Skip: Explicitly configured permissiveness with justification
|
|
112
|
+
|
|
113
|
+
**Debug Features:** Stack traces, introspection, verbose errors
|
|
114
|
+
→ Verify: Enabled by default? Exposed in responses?
|
|
115
|
+
→ Skip: Logging-only, not user-facing
|
|
116
|
+
|
|
117
|
+
For detailed examples and counter-examples, see [examples.md](references/examples.md).
|