Can an Agent Audit a Codebase for Security Bugs?

Key Takeaways
- •Cloudflare's audit skill splits review into coverage tracking, hunting, independent verification and checked reports. Discipline matters more than the model.
- •Examines why one-shot review fails, analyzing the structural bottlenecks and trade-offs in real-world deployments.
- •Provides engineering benchmarks and verification criteria for the phases and what each buys.
Cloudflare's security-audit-skill describes a six-phase workflow for finding vulnerabilities with an AI agent. Its README reports a specific observation: one run found roughly half the vulnerabilities that repeated runs found in total. That 50 percent figure is the reason the workflow is shaped the way it is.
That sentence is the most useful thing in the repository. It states a measured limitation of the method rather than a capability, and it explains why the workflow is designed the way it is.
Why one-shot review fails
Asking a model to find the bugs in a repository produces output that reads like an audit. Sections, severity labels, exploit descriptions. The format is convincing and the content is a sample.
Two problems cause that. The first is stochasticity. The same prompt against the same repository on consecutive runs will surface different findings, because the model's attention lands in different places. Neither run is complete.
The second is coverage blindness. A model that reports four findings has no idea whether it examined the surface where the fifth lives. It examined what it retrieved into context, and the retrieval was driven by heuristics it does not expose.
An audit where nobody can say what was checked is not an audit. It is a sample with a report format attached.
The phases and what each buys
The workflow divides the work so that each phase answers a question the next one needs.
Mapping establishes what exists. The agent identifies entry points, trust boundaries and input surfaces, and writes them down. The output is a list of places where untrusted data can reach privileged code.
Coverage tracking is the ledger. As the audit proceeds, each surface gets a status: examined, not examined, or deferred with a reason. The ledger is the artefact that makes the result falsifiable, because it tells a reader what the audit did not look at.
Hunting is the phase most people mean by the word audit. Isolated agents take a slice of the mapped surface and look for issues, each with a bounded scope so that context does not blur.
Verification is where the design earns its keep. Every candidate finding goes to a fresh agent that did not see the hunt, and that agent tries to disprove it. A finding that survives an adversarial read is different in kind from one that emerged from a single pass.
Classification separates confirmed issues from unresolved leads and rejected candidates. Collapsing those into one list is the most common way an audit report misleads, because a rejected candidate and a confirmed bug look identical under a severity heading.
Schema validation checks the machine-readable report against a defined structure. It is unglamorous and it prevents a class of failure where the report is unparseable by the tooling that is supposed to act on it.
Why the verifier must be a separate agent
A model asked to confirm its own finding will usually confirm it. The reasoning that produced the finding is in the same context as the request to check it, and the check becomes a continuation rather than a test.
A fresh context removes that continuity. The verifier sees the claim and the code, and has no investment in the conclusion.
The OWASP Top 10 for LLM Applications catalogues the risk class this addresses. That is adversarial review, and it works for the same reason it works between people. A second reader who did not write the patch asks different questions, and some of those questions are the ones that find the problem.
The cost is real. Verification roughly doubles the work per candidate, which is why most agent audits skip it and most agent audit findings need re-checking by hand.
The sandbox is not optional
The skill requires an operating-system-enforced sandbox for builds, tests, browsers, fuzzers and any process the target controls, with restricted networking, environment variables, resources and writable paths.
The reason is not theoretical. Auditing a codebase means running its tests, which executes its code. A project that ships a malicious test harness gets code execution on the auditor's machine, and a security audit that compromises the auditor is a specific kind of failure.
Restricted networking matters because a test suite that phones home reveals the repository under audit to whoever receives the call. Restricted writable paths matter because a build script that writes outside the workspace is doing something the auditor did not intend.
Sandboxing is also what makes the fuzzing phase usable. A fuzzer generates malformed input by design, and running one against a target outside a container is how an audit becomes an incident.
What the workflow still cannot do
Five limits, and each is worth stating because the design does not remove them.
Coverage is bounded by the map. A surface the mapping phase missed will not appear in the ledger, so the report will be accurate about what it examined and silent about what it never saw. The map is produced by the same kind of system being audited, and it inherits its blind spots.
Severity is a judgement. A label of critical attached to a finding is a claim about exploitability, and the workflow's verification step tests whether the finding is real rather than whether it is severe. Those are separate questions.
False positives survive verification. An adversarial reviewer reduces the rate and does not eliminate it, because a plausible-looking bug that does not reproduce under the actual conditions can look solid in the abstract.
The single-run finding rate is a measured limitation rather than a solved problem. If one run finds half of what repeated runs find collectively, then a report from one run is half an audit no matter how well formatted it is.
And a passing schema is not evidence of quality. A structurally valid report can contain findings of low value, and the validation step confirms the container rather than the contents.
What to ask for in an agent audit
Four things, and a report that does not contain them is a sample.
The coverage ledger, including what was deferred and why. The verification status of each finding, distinguishing confirmed from candidate. The reproduction steps for anything labelled confirmed, because a finding that cannot be reproduced is a lead. And the sandbox configuration, because the conditions of the audit determine what it could have found.
The workflow's real contribution is making those questions askable. Before it, an agent audit produced a narrative. With a ledger and a verifier, it produces a record that someone else can check, and checking is what separates security work from security theatre.



