elementalsouls/Claude-BugHunter is a Claude Code skill bundle for bug hunting and external red-team work (MIT licensed; 85 skills, 16 slash commands, per its README). This is a source reading at commit 1712a82: I cloned the repo and read engine/scope.py, engine/engine.py, engine/skill_map.py, engine/agent.py, engine/closure.py, commands/scope.md and skills/triage-validation/SKILL.md. It is meant for assets you own or are authorized to assess; this post covers the architecture, not attack techniques.
Companion tutorial: how to install it and run scope, hunt, validate and report is on Cui.Guru: Hunt bugs with Claude Code, scope enforced in code.
The workflow in motion
Architecture
The engine README states its principles: deterministic-first (recon, parameter discovery and categorization are plain Python with no agents), map-first with hunting opt-in, and “safe by construction”: scope is an allowlist, agents are told to run read-only by default (a prompt restriction, as covered below), and a scope audit checks PoCs after the fact.
The core design idea
The engine “may run unattended, so scope is enforced in CODE, not by trusting an LLM”, as the scope.py docstring puts it. Two rules carry it: deny wins, and anything not matched is out of scope. The deterministic gate checks the initial work item and recon targets. Once an agent is running it builds its own requests, so scope and read-only limits reach it through the prompt (engine.py), and the agent is launched with bypassPermissions; the allowlisted python3 and curl are general-purpose. A deterministic pass afterwards audits what the agent reports, so it can flag a reported out-of-scope host but cannot undo a request already made. Most ambiguity fails closed, with one exception: an invalid deny regex in scope.py is turned into a literal rule with a warning, so it may no longer match what you intended. Resolve scope warnings before proceeding.
A deny-wins, default-deny check
# engine/scope.py (Scope.in_scope_host)
host = _host_of(target)
if not host:
return False
if any(_match(p, host) for p in self.out_of_scope):
return False # deny wins
return any(_match(p, host) for p in self.in_scope)
Fail closed when two parsers could disagree
_host_of returns an empty host (so the target is out of scope) when the authority contains a backslash, space or control character, because the source comments say urlparse and requests can resolve such a URL to different hosts. It does the same for percent-encoded hostnames and for IDN hosts that cannot be encoded.
# engine/scope.py (_host_of)
if any(c == "\\" or ord(c) <= 0x20 or ord(c) == 0x7f for c in parsed.netloc):
return ""
...
if "%" in host:
return ""
A scope audit on the model’s own output
After the agent returns a finding, _scope_audit extracts every authority from the PoC request, evidence and hosts_contacted, and returns those that are not in scope. The comments explain it captures the whole authority because userinfo (inscope@evil.com) can hide the real connect host.
# engine/engine.py (_scope_audit)
hosts = set(re.findall(r'https?://([^\s/?#]+)', blob)) | set(f.get("hosts_contacted") or [])
return sorted({h for h in hosts if h and not self.scope.in_scope_host(h)})
Skills mapped only if actually installed
skill_map.py maps each vulnerability class to hunt skills, then filters to the names present in the skills directory. If the directory cannot be read it returns none rather than assuming everything exists.
# engine/skill_map.py
def skills_for(vuln_class, tech=None):
out = _filter(CLASS_SKILL.get(vuln_class, []))
return out or _filter(["hunt-misc"])
Prompt-restricted agents, skills off
agent.py shells out to headless claude -p. Its comment says skills are off by default because an eval showed about zero capability gain and a cost of roughly 12 to 15k tokens per agent; the tool allowlist is limited to a few shell commands (curl, python3, jq, openssl, base64) plus optional Burp MCP tools.
# engine/agent.py
SHELL_TOOLS = ["Bash(curl:*)", "Bash(python3:*)", "Bash(jq:*)", "Bash(openssl:*)", "Bash(base64:*)"]
...
if not skills_on:
cmd.append("--disable-slash-commands")
A ledger that will not close cleanly with gaps
closure.py defines which verdicts count as coverage. blocked is deliberately excluded, so it becomes a caveat in the report instead of silent success.
# engine/closure.py
COVERED = {"clean", "finding", "not_applicable", "out_of_scope"}
VERDICTS = COVERED | {"blocked"}
The human-side gate
skills/triage-validation/SKILL.md adds a seven-question gate (reproducible steps, accepted impact, in-scope root cause, privileged access, already known, proven impact, known-invalid class). Its own note says a failed gate kills that finding, not the engagement; Q6 downgrades severity rather than killing.
Takeaways
- Put safety-critical decisions (scope) in deterministic code, but know where that code stops: here it gates the initial target and audits output, while in-flight agent requests rely on prompt restrictions.
- Audit the model’s output with the same code that gated its input.
- Fail closed on ambiguity, and check the exceptions: an invalid deny regex falls back to a literal rule with a warning, so treat scope warnings as errors.
- Make the expensive, agentic step opt-in, and let the default run end at an inspectable map.
- Treat “blocked” as a visible gap, not a pass.
Want help designing guardrails for an agentic workflow of your own? Get in touch.
Click to load Disqus comments