Skip to content

Commit 876d099

Browse files
authored
feat(claude_agent_sdk): add vulnerability detection agent cookbook (anthropics#595)
* feat(claude_agent_sdk): add vulnerability detection agent cookbook 06_The_vulnerability_detection_agent.ipynb runs threat-model -> find -> triage -> report on a self-contained 45-line canary C target using claude-agent-sdk: ClaudeSDKClient for the multi-turn bootstrap-then- interview threat model, stateless query() for find/triage/report, with Claude Code's built-in Read/Grep/Glob in place of a hand-rolled tool loop. Supporting changes: - vulnerability_detection_agent/canary/canary.c: three unlabeled memory-safety bugs (heap OOB, stack OOB, UAF) - registry.yaml: new entry under Claude Agent SDK + Cybersecurity; threat_intel_enrichment_agent also tagged Cybersecurity - authors.yaml: add eugeneyan-ant - pyproject.toml: +claude-agent-sdk so root 'uv sync' covers the series - .gitignore: generated THREAT_MODEL.md - .claude/commands/add-registry.md: add Cybersecurity to category list * feat: add Cybersecurity to registry category enum Add Cybersecurity to .github/registry_schema.json so the new vuln detection cookbook entry passes registry-check.
1 parent 33424c3 commit 876d099

9 files changed

Lines changed: 1018 additions & 0 deletions

File tree

.claude/commands/add-registry.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Add a new entry to `registry.yaml` for the notebook specified in the prompt abov
2626
- **categories**: Select 1-2 appropriate categories from this list:
2727
- Agent Patterns
2828
- Claude Agent SDK
29+
- Cybersecurity
2930
- Evals
3031
- Fine-Tuning
3132
- Multimodal

.github/registry_schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"enum": [
3131
"Agent Patterns",
3232
"Claude Agent SDK",
33+
"Cybersecurity",
3334
"Evals",
3435
"Fine-Tuning",
3536
"Multimodal",

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,6 @@ validation_report_*.md
158158
tool_use/demo_memory/
159159
tool_use/memory_storage/
160160
tool_use/.env
161+
162+
# Cybersecurity notebook artifacts (regenerated each run)
163+
claude_agent_sdk/vulnerability_detection_agent/canary/THREAT_MODEL.md

authors.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ davidhershey:
2929
name: David Hershey
3030
website: https://github.com/davidhershey
3131
avatar: https://avatars.githubusercontent.com/u/11651858?v=4
32+
eugeneyan-ant:
33+
name: Eugene Yan
34+
website: https://x.com/eugeneyan
35+
avatar: https://avatars.githubusercontent.com/eugeneyan-ant?v=4
3236
gaganb-ant:
3337
name: Gagan Bhat
3438
avatar: https://avatars.githubusercontent.com/u/235440171?v=4

claude_agent_sdk/06_The_vulnerability_detection_agent.ipynb

Lines changed: 763 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// canary.c
2+
// Entry: ./canary <input_file>
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include <string.h>
6+
7+
static void parse_alpha(const unsigned char *data, size_t len) {
8+
unsigned char *buf = malloc(32);
9+
memcpy(buf, data, len);
10+
printf("alpha: %02x\n", buf[0]);
11+
free(buf);
12+
}
13+
14+
static void parse_bravo(const unsigned char *data, size_t len) {
15+
char name[16];
16+
memcpy(name, data, len);
17+
name[15] = 0;
18+
printf("bravo: %s\n", name);
19+
}
20+
21+
static void parse_charlie(const unsigned char *data, size_t len) {
22+
char *p = malloc(64);
23+
if (len > 0 && data[0] == 0xff) {
24+
free(p);
25+
}
26+
memcpy(p, data, len < 64 ? len : 64);
27+
printf("charlie: %p\n", (void *)p);
28+
}
29+
30+
int main(int argc, char **argv) {
31+
if (argc < 2) return 1;
32+
FILE *f = fopen(argv[1], "rb");
33+
if (!f) return 1;
34+
unsigned char buf[4096];
35+
size_t n = fread(buf, 1, sizeof buf, f);
36+
fclose(f);
37+
if (n < 1) return 1;
38+
switch (buf[0]) {
39+
case 'A': parse_alpha(buf + 1, n - 1); break;
40+
case 'B': parse_bravo(buf + 1, n - 1); break;
41+
case 'C': parse_charlie(buf + 1, n - 1); break;
42+
default: printf("unknown format\n");
43+
}
44+
return 0;
45+
}

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "0.1.0"
44
requires-python = ">=3.11,<3.13"
55
dependencies = [
66
"anthropic>=0.77.0",
7+
"claude-agent-sdk>=0.1.50",
78
"ipykernel>=7.1.0",
89
"notebook>=7.4.7",
910
"numpy>=2.3.4",

registry.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
categories:
7777
- Tools
7878
- Agent Patterns
79+
- Cybersecurity
7980
- title: Knowledge graph construction with Claude
8081
description: Build knowledge graphs from unstructured text using Claude for entity
8182
extraction, relation mining, deduplication, and multi-hop graph querying.
@@ -746,3 +747,14 @@
746747
categories:
747748
- Agent Patterns
748749
- Tools
750+
- title: The vulnerability detection agent
751+
description: Build a vulnerability-discovery agent with the Claude Agent SDK
752+
that threat-models a C target, hunts memory-safety bugs with built-in file
753+
tools, and triages findings into a structured report.
754+
path: claude_agent_sdk/06_The_vulnerability_detection_agent.ipynb
755+
authors:
756+
- eugeneyan-ant
757+
date: '2026-04-22'
758+
categories:
759+
- Claude Agent SDK
760+
- Cybersecurity

uv.lock

Lines changed: 188 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)