mirror of
https://github.com/elementalsouls/Claude-BugHunter.git
synced 2026-11-24 20:30:23 +01:00
Governance fix (Security): the autopilot ledger (engine/memory.py) wrote host/url findings, negatives, and per-target rollups to the shared ~/.claude/bughunter/memory/ store on EVERY run, while its reads were already gated behind --use-memory. That asymmetry persisted target-identifying data by default. record_finding and record_run are now gated behind --use-memory too: a default run pools NOTHING target-identifying across engagements. Opt-in --use-memory preserves the ledger and /pickup exactly as before — no behaviour removed, no data relocated. Confirmed no other default-on reader breaks (/pickup, /remember, /autopilot docs updated to say recall is opt-in). New (Added): engine/attack_metrics.py + --use-metrics. A leak-proof, per-operator store of GENERIC COUNTERS ONLY — attempts/successes/cost keyed by tech-stack signature + vuln-class (+ generic technique) — that never stores a host, url, payload, or body (fail-closed allowlist). On a new target it ranks class suggestions by past hit-rate in arsenal.md; advisory only — never auto-fires, and scope + the corroborator + the 7-Q gate still apply. No engagement/host field exists, so cross-engagement leak is impossible by construction. Tests: engine/test_attack_metrics.py (8), engine/test_memory_write_gate.py (4). engine 103 OK, tests 129 OK, lint/doc-count/leak/skill_index clean. Docs: engine/README.md, USAGE.md, /pickup, /remember, /autopilot, .gitignore, CHANGELOG. Engine code only — no skill added, counts unchanged. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
95 lines
7.0 KiB
Markdown
95 lines
7.0 KiB
Markdown
# Engagement engine
|
||
|
||
A **decision-support engine**, not an autonomous robot. It maps a target's attack surface
|
||
deterministically, **categorizes it against the skill arsenal** (which `hunt-*` skill applies
|
||
where), and **shows you each stage live** — so you spend your expert 20% where the 80%
|
||
automation points. It does **not** try to test everything itself; active hunting is opt-in.
|
||
|
||
## Design principles
|
||
1. **Deterministic-first.** Breadth (recon, parameter discovery, secret scanning, service
|
||
fingerprint, categorization) is plain Python + passive tooling — **`$0`, no agents, no
|
||
rate-limit burn**. The LLM is reserved for the few judgment calls in the opt-in hunt.
|
||
2. **Map-first, hunting opt-in.** A default run stops at the **arsenal map** and hands off to
|
||
you. Spend agents only when you choose (`--hunt`).
|
||
3. **Show every stage.** Each phase logs what it found, live, so you always know where to focus.
|
||
4. **Curl-first.** Active testing uses `curl`; Burp MCP is optional (OOB/blind/fuzzing only).
|
||
5. **Safe by construction.** Scope is a deterministic allowlist; agents run **read-only by
|
||
default** with hard rules-of-engagement; a deterministic scope-audit flags any out-of-scope PoC.
|
||
|
||
```
|
||
DEFAULT (deterministic, $0, no agents) │ OPT-IN (--hunt)
|
||
recon ───▶ rank ───▶ map ──────────────────────────────▶│ hunt ─▶ validate ─▶ report
|
||
│ │ └ surface → skill arsenal + │ │ └ adversarial verifier (read-only)
|
||
│ │ curl-first probes (arsenal.md) │ └ curl-first agent per ranked (url,param,class), skills-off
|
||
│ └ class-weight priority (secrets boosted) │
|
||
└ service/tech + JS endpoints + JS secrets + ALL params (gau + katana), categorized
|
||
```
|
||
> **OSINT (subdomain/asset enum) is a *separate* concern** — handled by Claude-OSINT, not the
|
||
> engine. The engine takes the in-scope seed target(s) and goes straight to deterministic recon.
|
||
|
||
| Piece | What it is |
|
||
|---|---|
|
||
| `scope.py` | deterministic allowlist (apex/wildcard/CIDR/regex; deny-wins; default-deny). Enforced at recon **and** hunt. |
|
||
| `recon.py` | **deterministic recon** — per target: service/tech (JS markers), JS-bundle endpoint mining, **JS secret scanning** (AWS/GCP/Anthropic/OpenAI/Slack/GitHub/Stripe/EmailJS… keys, redacted), and **all input parameters** from two independent sources — `gau` (passive historical) + `katana` (active live crawl). Noise-filtered, scope-filtered, multi-class categorized. No LLM in the find-step. |
|
||
| `skill_map.py` | **arsenal categorization** — maps each `(endpoint\|param, class)` → the specific `hunt-*` skill(s) **actually installed** in `~/.claude/skills`, plus a curl-first starter probe. Tech-stack skills (`hunt-nextjs`, `hunt-nodejs`…) mapped from the fingerprint. |
|
||
| `osint.py` | **separate/optional** — per-target service/tech probe (PD `httpx-toolkit`) reused by recon. Its subdomain-enum path is *not* in the engine flow (that's Claude-OSINT). |
|
||
| `state.py` | persistent, resumable engagement store (`state.json` + `evidence/` + `engine.log` + `arsenal.md` + `report.md`). |
|
||
| `agent.py` | headless `claude -p` dispatch + JSON extraction. **Skills OFF by default** (eval: ~0 capability gain, saves ~12–15k tokens/agent). Used only for the opt-in hunt/validate. |
|
||
| `engine.py` | the orchestrator: phases, scope enforcement, ranking, the map, parallel hunt/validate, candidate→confirm, report. |
|
||
|
||
## The map (the default deliverable)
|
||
`map` writes `arsenal.md` and logs every target live — for each endpoint/parameter: the attack
|
||
classes, the exact `hunt-*` skill(s) to open, and a ready-to-run curl. Example line:
|
||
```
|
||
map: redirect_to https://t/wp-login.php?redirect_to=FUZZ ssrf→hunt-ssrf lfi→hunt-lfi open-redirect→hunt-open-redirect
|
||
```
|
||
|
||
## Run
|
||
```bash
|
||
# DEFAULT — deterministic map only ($0, no agents). Stops for you with arsenal.md:
|
||
python3 engine/engine.py --scope my-engagement.json
|
||
# scope file = {name, in_scope, out_of_scope, seeds}; output in ~/.bughunter-engagements/<name>/
|
||
|
||
# OPT-IN — auto-test the mapped surface with agents (read-only, curl-first, parallel):
|
||
cp engine/burp-mcp.json.example engine/burp-mcp.json # only if you want Burp for OOB/blind
|
||
python3 engine/engine.py --scope my-engagement.json --hunt --parallel 3 --max-hunts 12
|
||
python3 engine/engine.py --scope my-engagement.json --hunt --allow-intrusive # permit state-changing PoCs (off by default)
|
||
|
||
# dry-run the whole wiring with canned output (no agents, no budget):
|
||
python3 engine/engine.py --scope engine/engagement.example.json --base /tmp/eng --mock --hunt
|
||
|
||
# standalone recon (deterministic, no engine state):
|
||
python3 engine/recon.py https://target/ target.com
|
||
```
|
||
Key flags: `--hunt` (opt into agents) · `--allow-intrusive` (default OFF = read-only) ·
|
||
`--parallel N` (concurrent agents, default 3) · `--phases a,b,c` (explicit override) ·
|
||
`--use-memory` (opt-in cross-engagement ledger — reads AND writes) ·
|
||
`--use-metrics` (opt-in leak-proof generic hit-rate metrics).
|
||
|
||
## Safety
|
||
- **Read-only by default** — hunt/validate agents are told: in-scope hosts only (never
|
||
third-party, even to prove a finding), and no state-changing actions (no emails/writes/
|
||
deletes/cache-purge, don't exercise exposed creds). `--allow-intrusive` lifts this.
|
||
- **Deterministic scope-audit** — every confirmed finding is checked for out-of-scope hosts in
|
||
its PoC; any hit is flagged (⚠) in the report for review.
|
||
- **Calibrated severity** — the adversarial validator's severity (not the hunt's raw guess) is
|
||
what's stored.
|
||
- **Data isolation by default** — cross-engagement persistence is opt-in. The autopilot
|
||
ledger (`memory.py`: `findings.jsonl` / `negatives.jsonl` / `targets/<host>.json`, which
|
||
hold hostnames + URLs) is only **read AND written** under `--use-memory`. A default run
|
||
pools **nothing** target-identifying across engagements; per-engagement state lives and
|
||
dies in `<base>/<name>/`. `--use-memory` makes persistent per-target recall (and
|
||
`/pickup`) a knowing choice — it then captures host/URL exactly as before.
|
||
- **Leak-proof metrics (`--use-metrics`, `attack_metrics.py`)** — a separate opt-in store of
|
||
**generic counters only**: attempts / successes / cost keyed by tech-stack signature +
|
||
vuln-class (+ a generic technique category). It **never** stores a host, URL, payload, or
|
||
body (fail-closed allowlist drops anything target-shaped). It only **ranks** class
|
||
suggestions by past hit-rate for the operator — it never auto-fires, and scope, the
|
||
corroborator, and the 7-Question gate still apply.
|
||
|
||
## Why this and not more skills
|
||
The measured result (`eval/`): skills add ~0 capability on benchmarkable tasks — the base model
|
||
already exploits standard classes, and skills cost ~12–15k tokens/agent to load. The leverage is
|
||
here: turning that raw capability into a **safe, deterministic, skill-routing, operator-in-the-
|
||
loop** engine. Breadth is free and visible; you bring the judgment.
|