An AI agent security-audited real WordPress core — 1,492 PHP files, ~619k lines — for ~26,000 tokens instead of the ~5,200,000 it costs just to load the code once. A queryable code graph in XERJ decided what deserved reading; the agent read only candidates. Per-phase measured costs, published end to end.
TOKEN ACCOUNTING: SUMMED PER-PHASE MEASURED COSTS VS THE READ-EVERYTHING BASELINE · NOT A LATENCY BENCHMARK · SOURCES IN docs/case-studies/wordpress-security-audit →
ONE BOOL-FILTER QUERY VS grep · UNITS DIFFER: FUNCTION-LEVEL CANDIDATES VS WHOLE FILES · GREP'S LITERAL RECALL IS PERFECT
Locate the gatekeepers, read their real implementations, compile the correct-vs-buggy shape into a query, and pull back only the violators. Precision comes from reading; scale comes from the index.
$ python3 wp_audit_index.py ./wordpress # 11,990 functions + 1,343 hooks $ python3 wp_authz_graph.py ./wordpress # capability/nonce shapes + call edges $ python3 wp_compose_index.py ./wordpress # sanitizer-sequence fingerprints
$ curl -s "$XERJ/wpaudit/_search" -H 'Content-Type: application/json' \
-d '{"query":{"bool":{"filter":[
{"term":{"has_source":"true"}},
{"term":{"sinks":"sql"}},
{"term":{"sanit":"false"}}]}}}'
# a request source + SQL sink in the same function, no sanitizer between
$ curl -s "$XERJ/wphooks/_search" -H 'Content-Type: application/json' \
-d '{"query":{"term":{"unauth":true}},"_source":["hook","callback"]}'
# 2 of 1,343 hooks
Core came back hardened: 0 missing-capability IDOR across 226 handlers, 0 auto-triggered deserialization gadgets. The one real weakness: wp_http_validate_url does not block 169.254.169.254 (cloud metadata), reachable unauthenticated via pingback_ping. A known-class limitation, not a novel 0-day.
The result that matters here is the negative one: the audit did not invent a 0-day, and that is written as the result, not hidden. Token accounting, missed cases, and the grep counter-examples sit in the walkthrough, so you can see where a keyword search was the cheaper tool. For the same kind of work in a shorter form, see the code security audit use case. Other measured studies are on the case studies index.
The research journals, reproduction scripts, and verification harness are all published. The method ships as a copyable Claude Code skill — the taint model is data, not code, so it retargets to your stack.
The skill runs the same audit — index, triage queries, verification prompts — on your codebase. Want a walkthrough with your team? Leave an email.