Using Claude to reduce the attack surface of code
TL;DR Highlight
Claude scanned 25 open-source projects and found 493 needlessly reachable code issues.
Who Should Read
Backend and security engineers with complex server configs who can't tell what code runs before authentication.
Core Mechanics
- Shrink reachable code, not just bugs
- Finding and fixing individual vulnerabilities scales poorly because it says nothing about the remaining ones.
- Reducing reachable code lowers the severity of unknown vulnerabilities too.
- 493 issues across 25 projects
- The targets were 25 open-source projects in C, C++, Java, PHP and Python, over five million lines.
- Claude inventoried over 17,000 config options, of which 3,842 were security relevant.
- Three lenses for finding them
- Code reachable in the default config but unused by default functionality.
- Option pairs that look fine alone but cause problems together.
- Complex, sensitive code that runs before authentication, without victim interaction, or before a protocol state transition.
- Config combos silently disabled security
- 162 security-sensitive combos were accepted with no warning or docs, and 94 of them silently turned off a security control.
- In gated projects, 93 unnecessary pre-authentication surfaces were found in default configs.
- Hostname deny rules failed open when reverse DNS was off, and this pattern appeared in four unrelated projects.
- Even OpenSSH had some
- In 10.4, about 4,500 lines of experimental ML-DSA-44 code were reachable by unauthenticated clients in the default config.
- That was about 16% of default sshd's pre-authentication code.
- The key was parsed before the allow check, and 10.5 moved the check ahead of parsing.
- Packaged as a reusable Claude skill
- It runs three passes, each starting with an empty context plus a short summary from the previous pass.
- Each finding is confirmed by a dynamic trace, and default-config gates must match the project's test suite and a black-box regression suite.
- Gates that would change non-default configs are set aside for a human.
Community Reactions
- Many complained AI refuses security work
- One commenter said Claude and GPT refused to audit their own codebase, so GLM or Kimi finished the job.
- Another said Claude and Codex balked at PHP CVE investigation and at writing auth-related unit tests, so they switched to GLM 5.3.
- Another said Claude drops to less capable models on security topics even with Cyber Verification Program membership.
- Doubts about result quality
- One commenter cited a kernel developer's talk claiming most earlier AI-found kernel vulnerabilities were non-issues or already fixed.
- They wondered whether AI labs rush to announce results without understanding the underlying problems.
- Someone tried the same approach
- One commenter used the prompt "reduce attack surface, move features into feature-flag Rust crates, build a minimal version" on Vix IDE.
- The codebase was split into crates and Cargo features so an auditor can review one capability at a time.
- Counterpoint on AI-written code
- One commenter said Anthropic discusses finding bugs in others' code but not the vulnerabilities AI creates in new code.
How to Apply
- List your pre-auth entry points
- Today, open your codebase in Claude Code and have it list the parsers and handlers that run before auth or session setup.
- Mark whether each is reachable in the default config and whether it is actually used.
- Audit security option combinations
- List security-related options and test them in pairs for silently disabled controls.
- Check whether listeners or login paths remain when a feature is disabled.
- Reject bad combos with an error at config load.
- Move checks before parsing
- Put allow-list checks ahead of deserialization and signature verification.
- Compare the type the parser actually uses, not what the client claims.
- Verify gates with regression tests
- After adding a gate, run the existing test suite to confirm default behavior is unchanged.
- Route changes that affect non-default configs to a human for approval.
Try It
# Paste into Claude Code, Claude or ChatGPT (simplified version of the article's skill)
You are a security reviewer. Find candidates for attack surface reduction in the codebase below. Work in three passes and end each pass with a 3-line summary for the next.
Pass 1: Code reachable in the default config but unused by intended functionality
Pass 2: Complex code that runs before authentication, without user interaction, or before a protocol state transition
Pass 3: Option combinations that are fine alone but silently turn off or weaken a security control together
In each pass, first build an inventory of entry points. For each finding, tabulate file/function, reachability path, and a proposed gate (reorder checks, state-order guard, reject combo at config load). Mark proposals that change default behavior as 'needs human decision'.
Target code: {{codebase or directory}}
Next step: apply one proposed gate and run {{test command}} to confirm default behavior is unchanged.Terminology
Related Papers
Rust off Rails: The opinionated web stack for the AI era
Sixty Markdown files tell coding agents how to build a Rust web app, with no framework code.
LayerFS: The filesystem for AI coding agents
Mount an ephemeral workspace per agent, commit only the changes
Launch HN: Alter (YC S25) – Access control for multi-user agents
Alter gives each agent its own identity, policy, and audit trail instead of shared API keys.
WhatsApp's help pages hid LLM instructions: dont recommend a regulator
WhatsApp help pages hid 102 AI-only instructions, including not recommending a data regulator
Same Simulation, Different Evidence: Where Retrieved Tool Output Costs LLM Agents Accuracy
Saving long tool output to files cut GPT-5.1 accuracy by 11.3 points; naming the authoritative file restored it.
Fake News, Real Crashes: Information Injection Attacks on LLM Financial Trading Agents
Fake headlines hijacked LLM trading agents 62% of the time versus 14% for prompt injection.
Harness Engineering 101: The LLM is the brain, the harness is the body
An agent is a loop managing a JSON array; 16 chapters build one from scratch
Harness2 by Google Research – Recursive Agent Harnessing
Recursively refining the harness with fixed model weights raised benchmark scores by up to 11.8 points.