@kernel.chat/kbot 4.1.0 → 4.3.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/dist/adapters/agent-sdk/from-agent-sdk.d.ts +28 -0
- package/dist/adapters/agent-sdk/from-agent-sdk.js +107 -0
- package/dist/adapters/agent-sdk/index.d.ts +4 -0
- package/dist/adapters/agent-sdk/index.js +14 -0
- package/dist/adapters/agent-sdk/to-agent-sdk.d.ts +13 -0
- package/dist/adapters/agent-sdk/to-agent-sdk.js +73 -0
- package/dist/adapters/agent-sdk/types.d.ts +41 -0
- package/dist/adapters/agent-sdk/types.js +9 -0
- package/dist/cli.js +15 -1
- package/dist/permissions.d.ts +17 -0
- package/dist/permissions.js +48 -0
- package/dist/tool-pipeline.js +11 -0
- package/dist/tools/forecast-summary.d.ts +25 -0
- package/dist/tools/forecast-summary.js +204 -0
- package/dist/tools/security-audit-local.d.ts +47 -0
- package/dist/tools/security-audit-local.js +363 -0
- package/dist/tools/stream-overlay.d.ts +9 -0
- package/dist/tools/stream-overlay.js +167 -134
- package/dist/tools/stream-renderer.js +10 -1
- package/dist/tools/swarm-2026-04.js +4 -0
- package/package.json +1 -1
- package/skills/ai-engineering/full-stack-mastery/SKILL.md +174 -0
- package/skills/security-audit/dependency-audit/SKILL.md +102 -0
- package/skills/security-audit/local-vulnerability-hunt/SKILL.md +127 -0
- package/skills/security-audit/secrets-leak-scan/SKILL.md +109 -0
- package/skills/security-audit/threat-model-quickdraw/SKILL.md +107 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dependency-audit
|
|
3
|
+
description: Use when reviewing third-party dependencies for known CVEs, suspicious transitive packages, lockfile drift, or license risk. Pairs with local-vulnerability-hunt for full coverage.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: kbot
|
|
6
|
+
license: MIT
|
|
7
|
+
metadata:
|
|
8
|
+
kbot:
|
|
9
|
+
tags: [security, dependencies, supply-chain, npm, audit]
|
|
10
|
+
related_skills: [local-vulnerability-hunt, secrets-leak-scan, ship-pipeline]
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Dependency Audit
|
|
14
|
+
|
|
15
|
+
Most exploits in 2026 do not come from your code. They come from a package six links deep that someone trusted on a Tuesday.
|
|
16
|
+
|
|
17
|
+
## When to Use
|
|
18
|
+
|
|
19
|
+
- Any time you add or upgrade a dependency
|
|
20
|
+
- Before tagging a release
|
|
21
|
+
- After a CVE drops in the ecosystem you ship in
|
|
22
|
+
- When a lockfile changes in a PR you didn't write
|
|
23
|
+
- When `node_modules` is bigger than the rest of the repo
|
|
24
|
+
|
|
25
|
+
## Iron Laws
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
LOCKFILE IS THE TRUTH. PACKAGE.JSON IS THE WISH.
|
|
29
|
+
TRANSITIVE COUNTS. DEEP COUNTS DOUBLE.
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Four Phases
|
|
33
|
+
|
|
34
|
+
### Phase 1 — Inventory
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm ls --all --json > /tmp/deps.json
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Then count:
|
|
41
|
+
- Total packages (direct + transitive)
|
|
42
|
+
- Distinct authors
|
|
43
|
+
- Distinct registries (anything other than registry.npmjs.org is worth a second look)
|
|
44
|
+
- Packages updated in the last 30 days (fresh = potentially compromised)
|
|
45
|
+
|
|
46
|
+
### Phase 2 — Known CVEs
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm audit --json > /tmp/audit.json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Triage by severity. Critical and high get fixed this PR; medium gets a ticket; low gets a note. Read every advisory body — `npm audit` lies about exploitability often enough to matter.
|
|
53
|
+
|
|
54
|
+
### Phase 3 — Provenance
|
|
55
|
+
|
|
56
|
+
For each package above the trust line (default: anything in `dependencies`, not `devDependencies`):
|
|
57
|
+
- Author has a real GitHub presence?
|
|
58
|
+
- Repository link resolves to the package source?
|
|
59
|
+
- `provenance` field present in the npm metadata?
|
|
60
|
+
- Maintainer changed in the last 90 days?
|
|
61
|
+
|
|
62
|
+
A rotated maintainer + a fresh release is the classic supply-chain shape. Treat it as suspicious until proven otherwise.
|
|
63
|
+
|
|
64
|
+
### Phase 4 — Lockfile diff
|
|
65
|
+
|
|
66
|
+
When reviewing a PR:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
git diff main -- package-lock.json | grep -E '^\+.*"version"' | head -50
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Any new package, any version bump in a security-relevant package (auth, crypto, http, vm, fs), and any registry change deserves a manual look.
|
|
73
|
+
|
|
74
|
+
## Output
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
# Dependency Audit — <date>
|
|
78
|
+
- Direct: N | Transitive: M
|
|
79
|
+
- CVEs: critical=X, high=Y, medium=Z, low=W
|
|
80
|
+
- Suspicious provenance: [list of packages]
|
|
81
|
+
- Lockfile diff: [N packages changed]
|
|
82
|
+
|
|
83
|
+
## Action items
|
|
84
|
+
- [ ] Upgrade <pkg> from <a> to <b> (CVE-XXXX-YYYY)
|
|
85
|
+
- [ ] Replace <pkg> with <alt> (unmaintained)
|
|
86
|
+
- [ ] Pin <pkg> at <version> (recent maintainer change)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
File under `~/.kbot/security-audits/<session-id>/dependency-audit.md`.
|
|
90
|
+
|
|
91
|
+
## Anti-Patterns
|
|
92
|
+
|
|
93
|
+
- Running `npm audit fix` on autopilot — it can pull breaking majors
|
|
94
|
+
- Ignoring transitive vulnerabilities because "they're not in our package.json"
|
|
95
|
+
- Trusting the GitHub stars count as a proxy for safety
|
|
96
|
+
- Letting Dependabot PRs merge without a human look
|
|
97
|
+
|
|
98
|
+
## How kbot Helps
|
|
99
|
+
|
|
100
|
+
- `bash` — drive `npm ls`, `npm audit`, `git diff`
|
|
101
|
+
- `kbot_read` — open the package's `index.js` to see what it actually does
|
|
102
|
+
- `local-vulnerability-hunt` — once a package is confirmed in scope, audit how *you* use it
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: local-vulnerability-hunt
|
|
3
|
+
description: Use when the user wants to find security vulnerabilities in a local codebase using their own BYOK frontier model. Mythos-style audit, local-first, audit trail on disk.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: kbot
|
|
6
|
+
license: MIT
|
|
7
|
+
metadata:
|
|
8
|
+
kbot:
|
|
9
|
+
tags: [security, audit, vulnerability, byok, local-first]
|
|
10
|
+
related_skills: [dependency-audit, secrets-leak-scan, threat-model-quickdraw, systematic-debugging]
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Local Vulnerability Hunt
|
|
14
|
+
|
|
15
|
+
The Project Glasswing posture — but BYOK, local, MIT. Anthropic shipped Claude Mythos to six organizations to hunt zero-days; this skill gives the same workflow to anyone with a frontier model API key, against their own code, with the audit trail on disk where they can read it.
|
|
16
|
+
|
|
17
|
+
## When to Use
|
|
18
|
+
|
|
19
|
+
- The user asks "scan my repo for vulnerabilities"
|
|
20
|
+
- Pre-release security pass before a tag
|
|
21
|
+
- After importing a third-party module of unknown provenance
|
|
22
|
+
- After a CVE drops and you want to know if your code touches the same surface
|
|
23
|
+
- Quarterly hygiene sweep, with the trail filed for later reference
|
|
24
|
+
|
|
25
|
+
Do **not** use this skill against systems you don't own. For external targets see `pentest` and `hacker-toolkit` — those are scoped for authorized testing.
|
|
26
|
+
|
|
27
|
+
## Iron Laws
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
NO REMOTE SCAN WITHOUT CONSENT.
|
|
31
|
+
NO FINDING WITHOUT EVIDENCE.
|
|
32
|
+
NO FIX WITHOUT VERIFICATION.
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The model proposes; you verify; the trail records both.
|
|
36
|
+
|
|
37
|
+
## Five Phases
|
|
38
|
+
|
|
39
|
+
### Phase 1 — Scope
|
|
40
|
+
|
|
41
|
+
Decide what counts as in-scope before reading a line of code. Write it down.
|
|
42
|
+
|
|
43
|
+
- Source tree root (absolute path).
|
|
44
|
+
- Languages and runtimes that matter (`node`, `python`, `go`, `rust`).
|
|
45
|
+
- Excluded paths (`node_modules`, `dist`, `vendor`, generated code).
|
|
46
|
+
- Severity floor: report `MEDIUM+` by default, `LOW+` when asked.
|
|
47
|
+
- Time bound: a quick pass is one hour; a thorough pass is a working day.
|
|
48
|
+
|
|
49
|
+
### Phase 2 — Surface map
|
|
50
|
+
|
|
51
|
+
Walk the tree once and inventory the attack surface. The `security_audit_local` tool does this in one call:
|
|
52
|
+
|
|
53
|
+
- HTTP handlers and route registrations
|
|
54
|
+
- Auth boundaries and session handling
|
|
55
|
+
- Subprocess and shell-out points (`exec`, `spawn`, `system`)
|
|
56
|
+
- Eval-shaped sinks (`eval`, `Function`, `vm.runInContext`, dynamic `require`)
|
|
57
|
+
- File-system writes and path-join sites
|
|
58
|
+
- Crypto usage (key derivation, randomness, ciphers, JWT signing)
|
|
59
|
+
- Third-party network egress
|
|
60
|
+
- Secrets-shaped strings (delegate to `secrets-leak-scan`)
|
|
61
|
+
|
|
62
|
+
Record findings as **signals** — not yet vulnerabilities — in `~/.kbot/security-audits/<session-id>/surface.jsonl`.
|
|
63
|
+
|
|
64
|
+
### Phase 3 — Hypothesize
|
|
65
|
+
|
|
66
|
+
For each high-signal site, write down one sentence: "I think this could be exploited because X, by Y, with consequence Z." If you can't finish the sentence, downgrade to LOW or drop.
|
|
67
|
+
|
|
68
|
+
The frontier model goes here. Hand it the code window plus the signal context and ask for the threat hypothesis. Cap context: never feed more than 4k LOC per turn — accuracy collapses past that.
|
|
69
|
+
|
|
70
|
+
### Phase 4 — Confirm
|
|
71
|
+
|
|
72
|
+
A hypothesis is not a finding. Confirm by:
|
|
73
|
+
|
|
74
|
+
1. Writing a failing test that reproduces the exploit (preferred), or
|
|
75
|
+
2. Constructing a minimal call sequence that demonstrates it, or
|
|
76
|
+
3. Citing a specific equivalent CVE with the same pattern.
|
|
77
|
+
|
|
78
|
+
Findings without confirmation get filed as `UNCONFIRMED` and never graduate without phase 4 evidence.
|
|
79
|
+
|
|
80
|
+
### Phase 5 — File
|
|
81
|
+
|
|
82
|
+
Every confirmed finding lands in `~/.kbot/security-audits/<session-id>/findings.jsonl` with this shape:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"id": "AUDIT-2026-05-09-001",
|
|
87
|
+
"severity": "HIGH",
|
|
88
|
+
"category": "command-injection",
|
|
89
|
+
"file": "src/exec.ts",
|
|
90
|
+
"line": 47,
|
|
91
|
+
"evidence": "user-controlled `path` flows into child_process.exec without escaping",
|
|
92
|
+
"reproduction": "POST /api/run {\"path\":\"foo; rm -rf /\"}",
|
|
93
|
+
"remediation": "use execFile with arg array; never compose shell strings from user input",
|
|
94
|
+
"confidence": "high",
|
|
95
|
+
"model": "claude-opus-4-7",
|
|
96
|
+
"cited_cwe": "CWE-78",
|
|
97
|
+
"ts": 1746792000000
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The whole directory is your evidence pack. Ship it alongside the patch commit.
|
|
102
|
+
|
|
103
|
+
## Output
|
|
104
|
+
|
|
105
|
+
When finished, produce a short markdown summary:
|
|
106
|
+
|
|
107
|
+
- **Scope**: paths walked, files read, LOC scanned
|
|
108
|
+
- **Counts by severity**: CRITICAL / HIGH / MEDIUM / LOW
|
|
109
|
+
- **Top three** with file:line, one-sentence why
|
|
110
|
+
- **Audit trail**: pointer to `~/.kbot/security-audits/<session-id>/`
|
|
111
|
+
- **Model used**: which BYOK model produced the hypotheses
|
|
112
|
+
|
|
113
|
+
Keep the summary under 60 lines. The full trail belongs on disk, not in the chat.
|
|
114
|
+
|
|
115
|
+
## Anti-Patterns
|
|
116
|
+
|
|
117
|
+
- Letting the model autonomously edit code based on its own findings — confirm first, edit second, separate commits.
|
|
118
|
+
- Scanning without writing the scope down — irreproducible audits are worthless.
|
|
119
|
+
- Over-trusting one model — for HIGH+ findings, get a second opinion from a second provider before filing.
|
|
120
|
+
- Treating LOW findings as noise. They cluster around the next HIGH.
|
|
121
|
+
|
|
122
|
+
## How kbot Helps
|
|
123
|
+
|
|
124
|
+
- `security_audit_local` — substrate tool: walks the tree, builds the surface map, persists JSONL trail.
|
|
125
|
+
- `kbot --thinking` — turn on extended thinking when forming threat hypotheses.
|
|
126
|
+
- `kbot --provider <name>` — rotate providers between phases for independent confirmation.
|
|
127
|
+
- `pentest` — the remote-target counterpart; use only with consent.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: secrets-leak-scan
|
|
3
|
+
description: Use when sweeping for hardcoded secrets, accidentally-committed credentials, or .env leaks across the working tree and git history.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: kbot
|
|
6
|
+
license: MIT
|
|
7
|
+
metadata:
|
|
8
|
+
kbot:
|
|
9
|
+
tags: [security, secrets, credentials, git-history, audit]
|
|
10
|
+
related_skills: [local-vulnerability-hunt, dependency-audit]
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Secrets Leak Scan
|
|
14
|
+
|
|
15
|
+
A leaked key in git history is a leaked key forever. This skill catches them before they ship and rotates them when they already did.
|
|
16
|
+
|
|
17
|
+
## When to Use
|
|
18
|
+
|
|
19
|
+
- Before pushing a new branch to a public remote
|
|
20
|
+
- After any `git rebase` that touched config files
|
|
21
|
+
- After a teammate says "I think I committed something I shouldn't have"
|
|
22
|
+
- Quarterly, against the entire history, even if no one reported anything
|
|
23
|
+
- Before open-sourcing a previously private repo
|
|
24
|
+
|
|
25
|
+
## Iron Laws
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
A SECRET IN HISTORY IS A SECRET LEAKED.
|
|
29
|
+
ROTATE FIRST, EXPLAIN SECOND.
|
|
30
|
+
NEVER REWRITE PUBLIC HISTORY WITHOUT TEAM CONSENT.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Four Phases
|
|
34
|
+
|
|
35
|
+
### Phase 1 — Working tree
|
|
36
|
+
|
|
37
|
+
Sweep what is on disk right now. The cheapest catch.
|
|
38
|
+
|
|
39
|
+
Patterns to grep, ranked by signal:
|
|
40
|
+
- `AKIA[0-9A-Z]{16}` — AWS access key
|
|
41
|
+
- `sk-[A-Za-z0-9]{20,}` — OpenAI / Anthropic / generic
|
|
42
|
+
- `xox[baprs]-[A-Za-z0-9-]+` — Slack tokens
|
|
43
|
+
- `ghp_[A-Za-z0-9]{36}` / `github_pat_[A-Za-z0-9_]{82}` — GitHub PAT
|
|
44
|
+
- `-----BEGIN (RSA |OPENSSH |EC )?PRIVATE KEY-----` — any private key
|
|
45
|
+
- `eyJ[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}` — JWT
|
|
46
|
+
- `[A-Za-z0-9+/]{40,}={0,2}` — long base64 (high false-positive, last resort)
|
|
47
|
+
|
|
48
|
+
Files that warrant a manual look regardless of grep hits: `.env*`, `config/*.yml`, `*.pem`, `*.key`, `*credentials*`, `*secrets*`.
|
|
49
|
+
|
|
50
|
+
### Phase 2 — Git history
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git rev-list --all | xargs -I{} git grep -E '<pattern>' {} -- '*.json' '*.yml' '*.env*' 2>/dev/null
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
For each hit:
|
|
57
|
+
1. Identify the commit hash and author
|
|
58
|
+
2. Determine the secret class (rotate-able? revoke-able?)
|
|
59
|
+
3. Check whether the commit was ever pushed to a remote you don't fully control
|
|
60
|
+
|
|
61
|
+
### Phase 3 — Rotate
|
|
62
|
+
|
|
63
|
+
Order of operations matters. Rotate **before** rewriting history — the old secret is already out there.
|
|
64
|
+
|
|
65
|
+
1. **Rotate the credential at the source** (cloud console, OAuth app, GitHub).
|
|
66
|
+
2. **Audit the credential's recent usage** — was anything done with it since the leak commit?
|
|
67
|
+
3. **Update the live deployment** with the new credential.
|
|
68
|
+
4. **Confirm the old credential no longer works.**
|
|
69
|
+
|
|
70
|
+
### Phase 4 — Scrub (only after phase 3)
|
|
71
|
+
|
|
72
|
+
If history was pushed only to a private remote you control, and the team consents:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git filter-repo --invert-paths --path <leaked-file>
|
|
76
|
+
git push --force-with-lease
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Notify every collaborator to re-clone — their local history still has the secret.
|
|
80
|
+
|
|
81
|
+
If the history was ever public, **do not rely on rewriting**. Treat the secret as permanently compromised. Rotation is the only remediation.
|
|
82
|
+
|
|
83
|
+
## Output
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
# Secrets Scan — <date> — <repo>
|
|
87
|
+
- Working tree hits: N (file:line list)
|
|
88
|
+
- Git history hits: M (commit:file list)
|
|
89
|
+
- Rotated: [list of credentials]
|
|
90
|
+
- Scrubbed: [list of paths] | not attempted (history is public)
|
|
91
|
+
|
|
92
|
+
## Open items
|
|
93
|
+
- [ ] <credential> still appears in commit <sha> — rotation required
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
File under `~/.kbot/security-audits/<session-id>/secrets-scan.md`.
|
|
97
|
+
|
|
98
|
+
## Anti-Patterns
|
|
99
|
+
|
|
100
|
+
- Rewriting history before rotating — the secret is already public
|
|
101
|
+
- Assuming `.gitignore` prevents leaks (it doesn't, retroactively)
|
|
102
|
+
- Trusting the regex sweep alone — the high-value secrets often look like nothing
|
|
103
|
+
- Telling the team about the leak after rewriting their history
|
|
104
|
+
|
|
105
|
+
## How kbot Helps
|
|
106
|
+
|
|
107
|
+
- `bash` — drive `git rev-list`, `git grep`, `git filter-repo`
|
|
108
|
+
- `kbot_read` — confirm the hit is a real secret and not a fixture
|
|
109
|
+
- `kbot --no-network` — when you must scan a sensitive repo without phoning home
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: threat-model-quickdraw
|
|
3
|
+
description: Use when designing a new feature or reviewing an architectural change. STRIDE-lite, fits in a single sitting, produces a written artifact.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: kbot
|
|
6
|
+
license: MIT
|
|
7
|
+
metadata:
|
|
8
|
+
kbot:
|
|
9
|
+
tags: [security, threat-model, design-review, stride]
|
|
10
|
+
related_skills: [local-vulnerability-hunt, dependency-audit, ship-pipeline]
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Threat Model Quickdraw
|
|
14
|
+
|
|
15
|
+
A real threat model takes a week and a whiteboard. A quickdraw takes thirty minutes and a markdown file. Most features deserve the latter; very few warrant the former.
|
|
16
|
+
|
|
17
|
+
## When to Use
|
|
18
|
+
|
|
19
|
+
- Before writing the first line of a new feature that touches auth, money, PII, or third-party data
|
|
20
|
+
- Before committing an architectural change that adds a network boundary
|
|
21
|
+
- During PR review when the diff crosses a trust boundary
|
|
22
|
+
- After a security incident, on the affected subsystem
|
|
23
|
+
|
|
24
|
+
Skip when the change is internal-only, has no user input, and touches no secrets.
|
|
25
|
+
|
|
26
|
+
## Iron Laws
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
EVERY EXTERNAL INPUT IS HOSTILE UNTIL PROVEN OTHERWISE.
|
|
30
|
+
EVERY TRUST BOUNDARY GETS A NAMED CHECK.
|
|
31
|
+
EVERY MITIGATION GETS A TEST.
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Four Phases
|
|
35
|
+
|
|
36
|
+
### Phase 1 — Diagram
|
|
37
|
+
|
|
38
|
+
A box-and-arrow diagram in ASCII or markdown. Five-minute exercise. Include:
|
|
39
|
+
- Every actor (user, admin, service, attacker)
|
|
40
|
+
- Every data store (database, blob, queue, cache)
|
|
41
|
+
- Every trust boundary as a dashed line
|
|
42
|
+
- Every flow as a labeled arrow
|
|
43
|
+
|
|
44
|
+
If you cannot draw it in five minutes, the feature is too big — split it.
|
|
45
|
+
|
|
46
|
+
### Phase 2 — STRIDE walk
|
|
47
|
+
|
|
48
|
+
For each component and each flow, ask the six questions in order:
|
|
49
|
+
|
|
50
|
+
| Letter | Threat | Sample question |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| **S** | Spoofing | Can someone claim to be a different actor? |
|
|
53
|
+
| **T** | Tampering | Can data be modified in transit or at rest? |
|
|
54
|
+
| **R** | Repudiation | Can an actor deny they took the action? |
|
|
55
|
+
| **I** | Information disclosure | Can secrets or PII leak via this path? |
|
|
56
|
+
| **D** | Denial of service | Can an attacker exhaust this resource cheaply? |
|
|
57
|
+
| **E** | Elevation of privilege | Can an actor gain rights they shouldn't have? |
|
|
58
|
+
|
|
59
|
+
For each "yes," write a one-line threat and a one-line mitigation. Park "maybe" entries in an Open Questions section.
|
|
60
|
+
|
|
61
|
+
### Phase 3 — Rank and cut
|
|
62
|
+
|
|
63
|
+
Rank threats by `(likelihood × impact)`. Address the top third now; ticket the middle third; document the bottom third as accepted risk with a name attached.
|
|
64
|
+
|
|
65
|
+
### Phase 4 — Record
|
|
66
|
+
|
|
67
|
+
Output goes to `docs/threat-models/<feature>.md` checked into the repo, plus a JSONL trail at `~/.kbot/security-audits/<session-id>/threat-model.jsonl`.
|
|
68
|
+
|
|
69
|
+
## Output Template
|
|
70
|
+
|
|
71
|
+
```markdown
|
|
72
|
+
# Threat Model — <feature> — <date>
|
|
73
|
+
|
|
74
|
+
## Diagram
|
|
75
|
+
<ascii box-and-arrow>
|
|
76
|
+
|
|
77
|
+
## Trust boundaries
|
|
78
|
+
1. <boundary name> — <check enforced>
|
|
79
|
+
2. ...
|
|
80
|
+
|
|
81
|
+
## Threats (STRIDE)
|
|
82
|
+
| ID | Letter | Component | Threat | Likelihood | Impact | Mitigation | Status |
|
|
83
|
+
|---|---|---|---|---|---|---|---|
|
|
84
|
+
| T-001 | S | login API | session token guessable | M | H | rotate to 256-bit random | now |
|
|
85
|
+
| T-002 | I | logs | PII written to stdout | H | H | redact in formatter | now |
|
|
86
|
+
| ... | | | | | | | |
|
|
87
|
+
|
|
88
|
+
## Accepted risks
|
|
89
|
+
- <risk> (rationale, owner)
|
|
90
|
+
|
|
91
|
+
## Open questions
|
|
92
|
+
- <question> (assigned to)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Anti-Patterns
|
|
96
|
+
|
|
97
|
+
- Treating the model as one-and-done — re-walk on any architectural change
|
|
98
|
+
- STRIDE-checking each component in isolation while ignoring the flows between them
|
|
99
|
+
- Writing mitigations that cannot be tested
|
|
100
|
+
- Letting "we'll think about it later" be the resolution for a HIGH-impact threat
|
|
101
|
+
|
|
102
|
+
## How kbot Helps
|
|
103
|
+
|
|
104
|
+
- `kbot --plan` — read-only mode for the diagram phase
|
|
105
|
+
- `kbot_write` — produce the markdown artifact
|
|
106
|
+
- `local-vulnerability-hunt` — once the model exists, audit the implementation against it
|
|
107
|
+
- `ship-pipeline` — gate releases on the threat model existing
|