Security

Anthropic Reveals a 6-Step AI Workflow to Secure Source Code

Anthropic published a practical six-step loop for using Claude Opus to find and fix source-code bugs—because finding issues with AI is getting easy, while proving and patching them is the hard part.

Anthropic six-step AI workflow for finding and fixing source code vulnerabilities
Anthropic's find-and-fix loop covers threat modeling, sandboxing, discovery, verification, triage, and patching.

Anthropic has shared a detailed guide for using large language models (LLMs)—especially Claude Opus—to help secure source code. An LLM is an AI system that can read and write text and code. In this case, the goal is to find security weaknesses, prove which ones matter, and help fix them.

The company's main takeaway is clear: discovery is now easy to run in parallel, but the bottleneck has moved to verification, triage, and patching. As of May 22, 2026, Anthropic said its own open-source scanning work had disclosed 1,596 vulnerabilities, and to its knowledge 97 of those had been patched.

The six-step find-and-fix loop

Anthropic says teams that find and fix the most issues converged on a variation of existing security best practices. The company distilled that into six steps:

  1. Threat modelDecide what counts as a vulnerability before scanning.
  2. SandboxBuild an isolated environment so agents can work safely and prove exploits.
  3. DiscoveryHave models look for vulnerabilities in the source code.
  4. VerificationIndependently confirm which findings are actually exploitable.
  5. TriageDeduplicate findings, assign severity, and prioritize fixes.
  6. PatchingApply the fix, confirm it works, and search for similar bugs.

Threat modeling and sandboxing are usually done once per codebase and updated when the system changes. The next four steps form a repeating defender's loop: discover, verify, triage, and patch.

The first run often finds the most issues. Later runs may find fewer but harder bugs. Anthropic warns teams not to expect zero new findings forever—models are stochastic (they can behave a little differently each run), and large codebases can have a long tail of issues.

Budget tip from Anthropic: your first scan may surface more findings than expected. Plan time for verification and triage before you plan for even more scanning.

1. Threat model: decide what “vulnerable” means

A threat model is a clear description of what you are protecting, what can go wrong, and which risks matter. Anthropic says many false positives happen because the model misunderstands trust boundaries—for example, treating a trusted config file like attacker-controlled input, or treating an internet-facing service as internal-only.

One partner team told Anthropic that when the threat model was well defined, model findings were exploitable about 90% of the time. Another lesson from customers: the model may understand the code well, but not “us”—company assumptions, policies, and what developers will actually treat as a real issue.

Anthropic recommends building the threat model in two parts:

  • Bootstrap from evidence: feed architecture docs, wikis, entry points, git history, and past vulnerabilities, then ask for assets, trust boundaries, and vulnerability classes you do and do not care about.
  • Interview a system expert: refine the draft with questions such as what you are building, what can go wrong, what you already do about it, and whether that is good enough.

Keep a THREAT_MODEL.md file in the repo and update it as code changes. Discovery and triage agents can read it so they skip known non-issues and rank severity against your real environment.

2. Sandbox: keep agents safe and prove real exploits

A sandbox is a sealed test space. Anthropic says it has two jobs: protect your real systems, and let agents prove whether a bug can actually be exploited.

Without strong isolation, agents can surprise you. One team told a model it had no network access—when it did—and the model still fetched from GitHub. Another saw an agent answer a GitHub issue mid-scan. Neither was malicious, but both showed why limits must be enforced in code and config, not only in prompts.

  • Containers can be enough for a discovery agent that only reads code.
  • Run the target app and proof-of-concept exploits in a microVM (such as Firecracker) or a full VM with outbound network locked down.
  • Never give agents credentials such as ~/.aws, ~/.ssh, or .env files.
  • Pin image tags, commit SHAs, dependencies, and build commands so every run starts from the same clean snapshot.

If a faithful production-like sandbox is too hard at first, Anthropic says teams can start with source-only discovery. The trade-off is more time spent on verification later, because you cannot prove findings with a live proof of concept (PoC).

3. Discovery: find candidates broadly

Discovery is the search phase. Anthropic recommends giving the agent rich context it can load when needed: the threat model, architecture docs, and past scan results. Counterintuitively, long checklists can make discovery worse by narrowing creativity. Better prompts state the goal and context, then let the model decide how to hunt.

Helpful discovery practices from the guide include:

  • Ask for a specific vulnerability class when you want focus, such as issues common in one language.
  • Require structured output fields such as rationale, finding, impact, and severity.
  • Give tools for search and reading code, plus security tools such as SAST scanners or fuzzers.
  • Partition the system first, then run parallel agents on different areas so they do not all find the same shallow bugs.

One pentesting team gave the agent tools to send requests, check responses, and query traffic logs. That team said its true-positive rate rose to nearly 100% because the agent could test reachability instead of guessing.

4. Verification: prove what is really exploitable

Discovery aims for recall—catch as many possible issues as you can. Verification aims for precision—keep only findings that are actually exploitable. Anthropic learned that asking one agent to discover and verify at the same time can cause it to filter out real bugs.

The verifier should be independent: fresh container, no shared conversation history, and only the finding or PoC plus the codebase. Prompt it to try to disprove the claim. Across teams Anthropic worked with, an adversarial verifier roughly halved non-exploitable findings; requiring a working PoC brought the false positive rate near zero.

5. Triage: cut duplicates and rank what to fix first

With models able to find many candidates quickly, triage becomes the bottleneck. Too many duplicated or overrated reports can cause product engineers—and open-source maintainers—to stop trusting the queue.

Anthropic recommends deduplicating by root cause, then ranking severity using reachability, attacker control, preconditions, authentication, read versus write impact, and blast radius. Ask the model to answer those questions before assigning a severity label so it does not inflate every “SQL injection” to critical by default.

Feed the same threat model into triage. Clarifying assumptions such as “we trust authenticated clients” can remove whole classes of noisy criticals that do not match your environment.

6. Patching: fix, retest, and hunt for variants

Patching closes the loop. Anthropic recommends writing a failing test first, applying the fix, confirming the test passes, then searching for variants of the same pattern or vulnerability class. Before shipping, run an adversarial check with a fresh discovery agent against the patch.

Validate patches on a ladder of checks:

  1. BuildThe patch compiles and new tests pass.
  2. Try to reproduceThe original PoC should stop working.
  3. Check for regressionsThe existing test suite still passes.
  4. Re-attackA fresh discovery agent probes for incomplete fixes.

Prefer the smallest change that fixes the root cause—no drive-by cleanups. Anthropic is clear that a human still needs to own the patch. Generated fixes can be too narrow, too restrictive, or break dependent services.

Companion tools: Anthropic points teams to the open defending-code-reference-harness repository, with skills such as threat modeling, vuln scanning, triage, and patching, plus a demo autonomous harness. It also mentions Claude Security as a managed product for agentic detection and patching, and a Claude Code security-review GitHub Action for pull requests.

What It Means for Developers

This guide is not only for security specialists. It changes how everyday engineering teams should use AI on code: find broadly, prove carefully, fix with tests, and keep humans accountable.

What It Means for Software Developers

Software developers should treat AI security output like untrusted draft work until verified. A finding without a PoC or clear reachability is a hypothesis, not a finished bug report.

  • Keep architecture notes and a living threat-model file next to the code.
  • Require failing tests before accepting AI-generated patches.
  • Review for root-cause fixes, not only local call-site patches.

What It Means for Backend Developers

Backend services often hold the entry points, auth gates, and data sinks that threat models care about. Teams building APIs with Node.js or Express can use the loop to pressure-test those boundaries.

  • Document which clients and configs are trusted.
  • Pin sandbox dependencies to match production versions.
  • Prioritize findings that are reachable without authentication or with weak preconditions.

What It Means for Full-Stack Developers

Full-stack apps mix browser input, APIs, and data stores. Misstated trust boundaries are a common source of noisy AI findings.

  • Separate public internet entry points from internal admin paths in the threat model.
  • Use preview environments or sandboxes that include auth and important dependencies when possible.
  • Feed verified findings back into the next scan's context so the loop improves over time.

What It Means for DevOps Engineers

DevOps and platform teams own isolation, credentials, and CI wiring. Anthropic's sandbox guidance is especially relevant here.

  • Run exploit proofs in locked-down VMs or microVMs, not on shared developer laptops with cloud keys.
  • Snapshot clean environments and restrict network egress during scans.
  • Connect the loop to events later—such as scanning after a security review or analyzing variants after a bug bounty report.
  • Keep production edges hardened with practices covered in AWS security groups and AWS WAF, remembering those controls also belong in the threat model so AI does not over-report mitigated paths.

What It Means for Web Developers

Web developers working in JavaScript and browser-facing apps should expect AI scanners to flag input handling, auth assumptions, and unsafe data flows. The workflow's triage step helps separate theoretical issues from bugs an attacker can reach.

  • Write clear notes about which browser inputs are sanitized and where.
  • Prefer ranked, deduplicated reports over dumping every raw model finding into the backlog.

What to watch next

A few practical checkpoints follow from Anthropic's guide:

  1. Verification qualityWhether independent verifiers and PoCs keep engineer trust high as finding volume grows.
  2. Patch ownershipHow teams review AI diffs for root-cause fixes without over-restrictive changes.
  3. Loop automationHow far organizations connect scanning to PRs, bounty reports, and recurring schedules.

Bottom line

Anthropic's six-step workflow turns AI code security into a disciplined loop: define what matters, isolate agents, discover broadly, verify independently, triage by root cause and impact, then patch with tests and variant hunting.

For developers, the lasting lesson is practical. AI can find many candidates quickly. Defenders win when they invest in threat models, sandboxes, and human-owned fixes—so real vulnerabilities get closed before attackers exploit them.

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author