Using LLMs to secure source code
by Anthropic
Anthropic's six-step loop for finding, verifying, triaging and patching vulnerabilities in your own code with Claude agents.
Overview
Using LLMs to secure source code is a best-practices guide published on Anthropic's claude.com blog on May 27, 2026, written by Eugene Yan and Henna Dattani with contributions from Anthropic security engineers. It draws on Anthropic's work with security teams and on its own scanning of open-source software, which had produced 1,596 disclosed vulnerabilities, 97 of them known to be patched, as of May 22, 2026. Its argument is that discovery with Claude Opus is now cheap to parallelize, so verification, triage and patching are where teams get stuck. The guide is organized as a six-step loop. Threat modeling and sandboxing are one-time setup per codebase: bootstrap a THREAT_MODEL.md from code, docs, git history and past CVEs, interview a system owner with Shostack's four questions, and run targets and PoCs in microVMs or gVisor containers with egress limited to the model API. Discovery, verification, triage and patching repeat. You partition the codebase and run parallel agents with short goal-focused prompts and structured output, verify each finding in a fresh context with an adversarial verifier told to assume it is false, deduplicate by root cause and rank by preconditions and impact, then write a failing test, fix the root cause, search for variants and re-attack with a fresh agent. The companion GitHub repo, anthropics/defending-code-reference-harness, ships these steps as Claude Code skills (/threat-model, /vuln-scan, /triage, /patch) plus an autonomous pipeline configured for C/C++ memory bugs with Docker and ASan. Its README says the repo is not maintained and does not accept contributions.
At a Glance
- Topic
- Agentic
- Level
- Intermediate
- Format
- Guide
- Cost
- Free
- Duration
- ~25 min read; the optional reference harness needs Docker and gVisor setup
- Provider
- Anthropic
- Hands-on
- Yes — code/exercises
- Certificate
- None
What You’ll Learn
- ✓Bootstrap a THREAT_MODEL.md from code, docs, git history and past CVEs
- ✓Run scanning agents and PoCs in microVM or gVisor sandboxes with egress limited to the model API
- ✓Partition a codebase by attack surface and run parallel discovery agents with structured output
- ✓Verify findings with independent adversarial agents in a fresh context, plus majority voting
- ✓Deduplicate findings by root cause and rate severity on preconditions, reachability and blast radius
- ✓Validate patches with a failing test, the original PoC, the existing test suite and a fresh re-attack
- ✓Use the reference repo's Claude Code skills for threat modeling, scanning, triage and patching
Highlights
- •Grounded in Anthropic's own open-source scanning, with 1,596 disclosed vulnerabilities as of May 22, 2026
- •Reports what improved precision: one team's adversarial verifier roughly halved non-exploitable findings, and requiring a PoC brought them near zero
- •Companion repo anthropics/defending-code-reference-harness had 7.7k GitHub stars and 635 forks as of November 1, 2026
- •Gives a concrete severity heuristic based on preconditions and authentication that teams can tune per system
- •The reference repo is marked unmaintained, so treat it as a template to adapt to your own codebase
Who It’s For
Best For
- ✓Application security engineers adding LLM-driven code review
- ✓Platform teams building autonomous vulnerability scanning pipelines
- ✓Engineers using Claude Code who want reusable security skills
Prerequisites
- •Comfort with Claude Code or another agentic coding tool
- •Application security basics: threat modeling, CVEs and proof-of-concept exploits
- •Docker and Linux experience if you run the reference harness
FAQ
What is Using LLMs to secure source code?
Anthropic's practical guide to finding and fixing vulnerabilities in your own code with Claude agents, written for security and platform engineers who want LLM code scanning without a flood of false positives. After reading it you can set up a loop of threat modeling, sandboxing, parallel discovery, adversarial verification, triage and validated patching.
Is Using LLMs to secure source code free?
Using LLMs to secure source code is free to access.
What level is Using LLMs to secure source code for?
Using LLMs to secure source code is aimed at a intermediate audience. Recommended background: Comfort with Claude Code or another agentic coding tool, Application security basics: threat modeling, CVEs and proof-of-concept exploits, Docker and Linux experience if you run the reference harness.
How long does Using LLMs to secure source code take?
Expect roughly ~25 min read; the optional reference harness needs Docker and gVisor setup. Most learners work through it at their own pace.
What will I learn from Using LLMs to secure source code?
You'll learn: Bootstrap a THREAT_MODEL.md from code, docs, git history and past CVEs; Run scanning agents and PoCs in microVM or gVisor sandboxes with egress limited to the model API; Partition a codebase by attack surface and run parallel discovery agents with structured output; Verify findings with independent adversarial agents in a fresh context, plus majority voting; Deduplicate findings by root cause and rate severity on preconditions, reachability and blast radius; Validate patches with a failing test, the original PoC, the existing test suite and a fresh re-attack; Use the reference repo's Claude Code skills for threat modeling, scanning, triage and patching.
Topics
Sources
This page was written from 2 sources, 1 on domains other than claude.com.