The last post ended on one line: if the second step looks the name up again, the check proved nothing. Our mail clients validated a hostname and then handed the hostname to a library that resolved it again.
After that fix we wanted one command that checks a whole product the way an attacker would look at it, that we could run on every repo we own, and whose result we could believe. Nothing we tried did all of it, so we built it: bughunt, open source, one Rust binary.
The first product it checked was itself. Its own fuzz target found that its host check accepted an address it should have refused, which is the same class of mistake as the mail sockets: the check and the thing that acts on the result disagreed about what the input meant. This post is about that bug and the others like it, because they are the part of a security tool that nobody sees and everybody relies on.
What it runs
bughunt doesn't reimplement scanners. Each layer runs the best open-source engine for the job, pinned to a tested version, and bughunt does the part the engines don't: deciding what is worth a person's time, making every layer report in one shape, and saying plainly what did not run.
| Layer | Engine | Finds |
|---|---|---|
scan | Opengrep | injection, unsafe output, weak crypto, in 30+ languages |
deps | osv-scanner | packages with published vulnerabilities, and the version that fixes all of them |
secrets | gitleaks | keys and passwords in the files and in the whole git history |
infra | trivy, zizmor | containers, Kubernetes, cloud templates, CI workflows |
api | Schemathesis | crashes, missing login checks, one user reading another's data (REST, GraphQL, gRPC) |
web | katana, nuclei | SQL injection, XSS, exposed files, CORS, cookies, headers, TLS |
fuzz | libFuzzer and each language's own | crashes in the repo's own fuzz targets, eight languages |
ai | bughunt, your AI tool | prompt injection in AI features; a confined pentest agent |
Every layer reports in the same shape, so one command gives one report. What did not run is part of the result.
Rule one: "did not run" is never "nothing found"
A security tool has two ways to be wrong. It can report a problem that isn't there, which costs a person an hour. Or it can report nothing when it didn't look, which costs you the problem. The second one is silent, so it's the one to design against.
Each of these was a real case in an early version, and each now ends in exit status 2 ("could not run, in whole or in part") instead of 0:
- The code scanner ran out of memory. The report said "0 raw flags", exit 0.
- gitleaks pointed at a folder that isn't a git repo logs an error and exits 0. Read by its exit status alone, the git history had no secrets in it.
- The API under test was down. The run reported one empty finding.
- A Go package that didn't compile was reported as "no fuzz targets".
The rule in the code is simple: a layer either produces a report or a reason it
couldn't, and the reason goes into the report as a section marked
ran: false. The exit status is 0 only when everything ran and found nothing.
SARIF output says the same thing to a dashboard (executionSuccessful: false),
so a green badge can't come from a scanner that never started.
Rule two: the repo being checked is not trusted
A scanned repo can talk to the scanner. Most engines read configuration from the folder they scan, and most honour inline comments that switch a finding off. That is reasonable for a team's own CI. It is wrong for a tool whose job is to check code someone else controls.
| The repo can... | So bughunt... |
|---|---|
add nosemgrep comments | runs Opengrep with --disable-nosem |
ship its own .semgrepignore | points the ignore file at a name that can't exist |
mark files export-ignore, so a branch export leaves them out | exports a branch through a throwaway git index, not git archive |
carry osv-scanner.toml that ignores a package | passes its own empty config. In the lab, the repo's file hid a vulnerable Django; ours brought it back |
use .gitleaksignore or gitleaks:allow | passes --ignore-gitleaks-allow and an empty ignore file |
include .trivyignore or zizmor config | passes its own ignore file and --no-config |
| name a baseline file outside itself | accepts only a plain file inside the repo |
None of this is exotic. It's the difference between "the repo says it's fine" and "we checked".
The bug in its own host check
bughunt api and bughunt web attack a running app. By default they go only
to this machine (localhost, 127.0.0.1, ::1, *.localhost, *.test),
because an attack sent to the wrong host is someone else's incident. Anything
else needs --allow-host, naming a test host you own.
That makes the host check a security boundary, so it has a fuzz target. The target feeds it arbitrary strings and asserts one property: whatever bughunt reads as "this machine", a browser-grade URL parser must read the same way.
It found inputs like these:
http://[::1]example.com/ check: local (it read the bracketed part and stopped)
http://[127.0.0.1] check: local (an IPv4 address in IPv6 brackets)
Neither is a valid address. What a client does with one is up to that client,
which is exactly the problem: the check and the thing that sends the requests
were reading the same text differently. It's the mail-socket bug again, in
another layer. The earlier version had already been caught once the classic
way: http://localhost:80@other-host/ reads as localhost to a naive check and
sends to other-host.
The fix wasn't a better parser for odd shapes. It was to accept one plain shape and refuse everything else: no login part, no escapes, nothing after a bracket, a port that exists, IDNA labels that decode. If an address needs interpretation, bughunt refuses it, and the person can write it plainly.
The bug in "read-only"
bughunt api is read-only by default: it should send GET requests (or GraphQL
queries) and nothing that changes data. In version 0.2.0 that wasn't true.
The engine, Schemathesis, has a coverage phase that also tries the methods an operation doesn't list, to see whether the server answers them correctly. That is a good check. It also meant DELETE, POST, PUT and PATCH went out, with the login token, on a run that said it would only read.
An independent review of 0.2.0 found it, and we proved it the only way that
counts: a small recording server that logs every request it receives. 0.2.0
sent seven different methods to it. The fix (switching that probing off unless
--write or --full is given, in a settings file bughunt always passes)
sends GET only. Recording servers for REST, GraphQL and gRPC now run in CI and
check what each mode really sends: GET only by default, queries only for
GraphQL, nothing at all for a gRPC run that wasn't allowed to write.
We had run 0.2.0 against a development copy of our own API, so we read the database logs for that window, statement by statement. The only change those requests made was signing one development user out everywhere. The release notes for 0.3.0 open with this, under "Security: upgrade from 0.2.0".
The lesson we took is that a security tool's flags are claims, and a claim needs a test that watches what actually goes out on the wire, not a test that reads what the tool was configured to do.
Other things it got wrong about itself
| What | Found by | Now |
|---|---|---|
| A proxy variable could carry every request, and the token, to another host | review | proxy settings are removed for local targets |
A schemathesis.toml in the working folder was obeyed, and it can load code | review | bughunt always passes its own settings file |
$ref: https://… in an API description fetched part of itself from elsewhere | review | refused |
| The login token was visible to every program bughunt ran, including a repo's own fuzz targets | review | taken out of the environment at start, passed only to the engine that needs it |
| A secret found by reading the code was printed in full in the report | building the lab | masked; a test proves it never appears |
| A file name with terminal escape codes could forge lines in the text report | review | control characters replaced in text, everything escaped in HTML; a fuzz target on the report writer keeps it that way |
Proof is a score, not a claim: the lab
"It finds SQL injection" means nothing without a denominator. So bughunt ships
a lab: a small shop that is vulnerable on purpose, built into the binary, with
an answer key of 21 planted holes across every layer. SQL injection, reflected
XSS, an API route with no login check, one user reading another's order, an
exposed .env, a secret that lives only in git history, a privileged pod, a
public bucket, a workflow that runs pull-request code with write access, a
parser that crashes, an AI assistant that follows injected instructions, and
the rest.
bughunt lab writes the shop, gives it a git history, starts it, runs every
layer against it and scores the result: found, missed, or not
tested (the layer that would find it didn't run). Missing one exits 1; not
testing one exits 2.
$ bughunt lab
21 of 21 planted holes found
0 missed · 0 not tested · 38 more findings the answer key does not list
CI runs the lab on every change, on a clean Linux machine with every engine installed from scratch, and fails unless the score is 21 of 21. A change that makes bughunt quieter has to keep it finding what it found.
AI features, and an AI pentester on a short leash
The AI layer has two parts.
Prompt-injection tests send eight attacks to the app's chat endpoint, each a different way of smuggling instructions into a message, and each carrying a fresh random marker. A finding needs the marker to come back in the form the attack asked for, so a model that only talks about the attack doesn't count. Markdown images and raw HTML in an answer are rated high, because rendering them is how injected text turns into a request to someone else's server.
The pentest agent runs on the AI tool the person already has (Claude Code,
Codex, Gemini CLI or Copilot CLI), on their own subscription. It gets read
access to the repo and exactly one way to reach the app: bughunt probe,
which sends one request, only to the app under test, only with methods the
run allows, and records it. Everything else (a general shell, web access, file
writes) is held back through each tool's own permission settings. We checked
that on Claude Code by telling it to use curl and to write a file: both were
refused.
When it reports a finding, the finding must cite the ids of recorded probes. A claim with no recorded request behind it is listed as unproven, not as a finding. When the model declines the task, which one did on its first run, the report says "declined" rather than "nothing found".
What it found in our own products
We ran it on every repo we own the day it worked. Most of what a scanner flags is noise, so every candidate on the shortlist was read by a person before anything was called a bug.
- Our CRM's API: 751 operations, 9,154 requests, 25 minutes, against a throwaway database: zero server errors. The report also says what it didn't really reach. 279 operations only ever answered "not found" (random ids, thin seed data) and 79 only answered "not allowed" (operator endpoints need another login). So about 390 were exercised, not 751.
- Both Rails backends: every candidate on the code-reading shortlist was read by a person (201 in one, 229 in the other). None was a real bug.
- parda, our open-source proxy
that masks secrets before they reach an AI agent: fuzzing found that a long
run of digits took cubic time (8 KB of numbers stalled it for 70 seconds in
a debug build), and that a secret found by its name (
DB_PASSWORD=x) wasn't masked where the same value appeared again on its own. Both are fixed, and its fuzz targets now run in its CI.
In a terminal
The last piece is the one people see first. Typed with no command in a repo,
bughunt says what can run there (which engines are installed, whether a
running app is needed) and offers the choices as the commands they are.
audit and lab show each layer as it runs and what has been found so far.
s skips a layer and ctrl-c stops while keeping what ran. Either way the
layer is reported as not run, so a later retest can't call its findings fixed.
At the end there's a summary and report.html and report.json, saved for the
next retest.
The screens appear only when a person is watching. In a pipe, a file or CI, bughunt prints the plain report, with the same exit status. A script never gets a screen it didn't ask for.
What it doesn't do yet
- Log in to a web app before crawling it. The web layer sees what a visitor without an account sees.
- WebSockets and streaming gRPC calls.
- Windows.
- The pentest agent, end to end, on every AI tool. One declined; the others haven't been run against the lab yet.
The decisions, and what set each one
| Decision | The constraint that set it |
|---|---|
| Run the best engine per layer, pinned | rewriting a scanner is years of work; pinning makes a result repeatable |
| Exit 2 for "did not run", in whole or in part | silence is the expensive failure; a dashboard must tell "clean" from "didn't start" |
| Override every repo-side ignore mechanism | the scanned repo is the thing being checked, not a party to the check |
| One plain address shape, refuse the rest | a host check and an HTTP client that parse differently is the bug we had just fixed elsewhere |
| Test what goes out on the wire | "read-only" was configured and still wasn't |
| A lab with an answer key, required in CI | a detection claim needs a denominator, and a regression needs to fail a build |
| An agent's claim must cite recorded requests | a model can describe an attack it never made |
| Screens only when a person is watching | scripts and CI depend on the plain output and the exit status |
A security tool is a program that makes claims about other programs: this is safe, this was checked, this is read-only. Those claims deserve the same treatment as the code it checks. Fuzz them, record what actually happens, and keep a score.
bughunt is MIT or Apache-2.0, on GitHub, with docs at sundarshahi.github.io/bughunt.