Most AI Code Audits Are Hallucination Factories. Cloudflare Just Open-Sourced the Fix

Most AI Code Audits Are Hallucination Factories. Cloudflare Just Open-Sourced the Fix

By Reggi, 27 Oct 2026

Giving a large language model a codebase and asking it to find vulnerabilities usually yields a predictable failure mode: a flood of plausible-sounding false positives, zero verifiable execution traces, and zero accountability for blind spots. Cloudflare open-sourced the blueprint to fix that exact problem with cloudflare/security-audit-skill.

Gaining over 16,000 GitHub stars in a single week, this JavaScript repository provides the single-repo foundation that seeded Cloudflare's own internal, fleet-wide vulnerability discovery harness. Instead of treating code auditing as a single speculative chat prompt, the skill orchestrates an adversarial, multi-agent pipeline designed to produce machine-readable, strictly verified security records.

Here is an architectural teardown of how this skill works, how it enforces verification, and why its structural design is a masterclass in autonomous software auditing.

The Six-Phase Audit Pipeline

The core issue with naive agentic audits is hallucination drift. When the same agent identifies an issue, defends its existence, and writes the report, confirmation bias dominates. Cloudflare breaks this cycle by splitting the audit into six isolated, sequential phases where no single agent holds unchecked authority.

+-----------------------------------------------------------------------------------+
| 1. Reconnaissance                                                                 |
|    - Map attack surfaces, trust boundaries -> architecture.md                     |
|    - Seed deterministic units -> coverage-ledger.json (validate-coverage-ledger) |
+----------------------------------------+------------------------------------------+
                                         |
                                         v
+-----------------------------------------------------------------------------------+
| 2. Coverage-Led Hunting                                                           |
|    - Isolated hunters audit ledger units                                          |
|    - Coverage critics identify audit gaps                                         |
+----------------------------------------+------------------------------------------+
                                         |
                                         v
+-----------------------------------------------------------------------------------+
| 3. Candidate Validation                                                           |
|    - Fresh, unprimed verifiers attempt to aggressively DISPROVE candidates         |
+----------------------------------------+------------------------------------------+
                                         |
                                         v
+-----------------------------------------------------------------------------------+
| 4. Structured Output                                                              |
|    - Write findings.json (confirmed, needs_validation, rejected)                  |
|    - Validate schema via validate-findings.cjs                                    |
+----------------------------------------+------------------------------------------+
                                         |
                                         v
+-----------------------------------------------------------------------------------+
| 5. Independent Record Verification                                                |
|    - Fresh agents re-verify final source claims                                   |
|    - Re-validate findings.json on every material replacement                      |
+----------------------------------------+------------------------------------------+
                                         |
                                         v
+-----------------------------------------------------------------------------------+
| 6. Target-Neutral Reporting                                                       |
|    - Generate REPORT.md, FINDINGS-DETAIL.md, and NEEDS-VALIDATION.md              |
+-----------------------------------------------------------------------------------+

Phase 1: Reconnaissance

The audit begins by mapping system architecture, input surfaces, trust boundaries, and prior evidence. Instead of keeping this context latent inside an LLM's context window, the reconnaissance phase formalizes it into two explicit artifacts: architecture.md and coverage-ledger.json.

The parent runner immediately executes validate-coverage-ledger.cjs to enforce strict formatting and validity before any hunting begins.

Phase 2: Coverage-Led Hunting

Audit workloads are broken down into discrete units recorded in the coverage ledger. Isolated hunter agents are assigned to these specific units. Hunters do not wander freely; they evaluate their assigned scope, record their specific checks, and submit to coverage critics whose sole purpose is discovering gaps in the hunter's audit scope.

Phase 3: Candidate Validation

When an agent flags a vulnerability, it does not get accepted into the final report. Instead, the candidate finding is handed to a completely fresh verifier agent. The verifier's operational mandate is adversarial: it must attempt to disprove the candidate. If an issue cannot survive an isolated agent actively trying to refute it against the code, it gets dropped or reclassified.

Phase 4: Structured Output

Findings that exit validation are written directly to findings.json under one of three strict verdict states. The parent runner enforces structural validity by executing validate-findings.cjs against report-schema.json.

Phase 5: Independent Record Verification

Even after a candidate is structured, final source claims must be confirmed by fresh agents. If any record requires material replacement or factual modification, another independent verifier is spawned to review the replacement, followed by another run of validate-findings.cjs.

Phase 6: Target-Neutral Reporting

Human-readable documentation is never generated directly from unverified agent conversations. Instead, REPORT.md, FINDINGS-DETAIL.md, and NEEDS-VALIDATION.md are derived deterministically from the validated findings.json records and the coverage ledger.


Machine-Enforced Verdicts: No Ambiguity

A foundational strength of this architecture is the rigid categorization of audit outcomes. In report-schema.json, findings are bound to three mutually exclusive states:

Verdict StateTechnical CriteriaSeverity Field Allowed?
confirmedRequires a complete source trace and a bounded observed resultYes
needs_validationTracks an exact unresolved fact; cannot produce speculative claimsNo
rejectedDocuments a candidate that was successfully disproven during validationNo

By stripping severity scores from needs_validation records, the skill blocks agents from generating alarming headlines for unverified hypotheses. A candidate cannot be marked confirmed without an unbroken path from the input surface down to the impacted component.


Zero-Dependency Deterministic Gatekeepers

Autonomous workflows often introduce brittle dependency chains. Cloudflare chose a zero-dependency architecture for its execution harness scripts:

  • validate-coverage-ledger.cjs: Runs after the ledger is initialized in Phase 1 and after every subsequent ledger update through Phase 5.
  • validate-findings.cjs: Validates the structure and verdict rules of findings.json during Phase 4 and immediately after any Phase 5 record replacement.
  • validate-findings.test.cjs: Provides automated test suites and producer-compatible fixture checks to guarantee that validator logic itself remains sound.

By using standalone CommonJS scripts, the orchestrator keeps verification fast, self-contained, and completely decoupled from external registry risks.


Target-Specific Attack Class Playbooks

Rather than relying on generic security prompts, cloudflare/security-audit-skill breaks security domains into modular markdown playbooks. These guides provide hunting prompts, validation methodologies, and attack classes tailored to specific architectural layers:

  • ATTACK-CLASSES.md: Core, wildcard, and obvious-things attack prompts.
  • AI-AND-LLM.md: Prompt-injection, agent/tool execution safety, and output-handling checks.
  • WEB-PROTOCOL-AND-AUTH.md: HTTP request-framing, cache behavior, and authentication-protocol validation.
  • MEMORY-SAFETY-AND-BINARY.md: Native targets, memory-safety bounds, and kernel-level hunting classes.
  • CLIENT-SIDE.md: DOM-injection, messaging trust, UI-redress, and prototype pollution.
  • CLOUD-AND-DEPLOYMENT.md: IAM structures, infrastructure-as-code, containers, serverless setups, ingress, and runtime configuration.
  • PROTOCOLS-RPC-AND-MESSAGING.md: RPC definitions, serialization boundaries, message queues, brokers, webhooks, and streaming protocols.
  • SUPPLY-CHAIN-AND-RELEASE.md: Dependencies, CI/CD pipelines, release mechanics, signing pipelines, updates, plugins, and extensions.
  • RESOURCE-EXHAUSTION-AND-AVAILABILITY.md: Shared resource contention, quotas, queue consumption, workers, and operator-spend attack surfaces.
  • DATA-ISOLATION-AND-LIFECYCLE.md: Multi-tenant isolation, cache boundaries, search indexes, data exports, backups, migrations, and deletion routines.
  • DESKTOP-MOBILE-AND-LOCAL-IPC.md: Native applications, deep-links, webviews, exported components, helpers, daemons, and local inter-process communication.

Additive State and Audit Resumption

Full codebase audits are computationally expensive. Running them repeatedly from scratch across active repositories is impractical.

The skill treats audit passes as additive. When re-executed against an existing target, the harness ingests prior ledgers and historical findings. It identifies newly introduced coverage gaps, re-evaluates changed source files, and carries forward historical source evidence.

Unresolved or stale audit tasks are never marked as covered by default. If source code changes invalidate prior findings, fresh validation runs are triggered automatically, keeping the audit output continuously aligned with repository state.

References


Popular Reads