Reduce attack surface with Claude before you chase individual CVEs
Have Claude inventory what code is reachable by default, before authentication, and under conflicting config options, then gate or feature-flag what you do not need, and prove the change with the project tests.

Tools used
- Claude CodeRuns the reachability passes and proposes gates or feature flags
- GitReview the patch before you ship it
Step navigator
A smaller set of reachable code paths, with gates or feature flags for anything that is not needed by default, checked against the project test suite.
Developers who own a codebase (or an open-source dependency they can patch) and want Claude to shrink what an unauthenticated client can reach before they hunt individual CVEs.
Before you start
Anthropic's Frontier Red Team (Chris Rohlf, 20 Oct 2026) ran Claude over 25 open-source projects and found 493 attack-surface issues, including unnecessary pre-auth reachability in OpenSSH that later shipped as fixes in 10.5 and 10.6. Separately, Joel Parker Henderson used the same idea on his Vix IDE repo by asking Claude to move features behind Cargo feature flags. This guide sticks to those two sources. Anthropic says they are packaging the three-pass method as a Claude skill for OSS-Scanner; that skill file is not published here, so the steps describe the method rather than inventing a skill file. Models sometimes refuse security work on your own code; that limitation is noted, not worked around with invented prompts.
Step-by-step instructions
Classify the project as Public, Gated or Private
Anthropic buckets projects by who can reach them: Public serves any user who can hit the service, Gated expects authentication before useful functionality, and Private serves the operator's own environment. That framing decides what "unnecessary" means. In their run, gated projects produced the most surprising early-reachability findings.
Classify this project as Public, Gated or Private using Anthropic's definitions, and list the main network or protocol entry points.

Why this works
Without that label, Claude cannot tell intended pre-auth surfaces from accidental ones.
Pass 1: find code the default config can reach but intended features never use
First pass, with a fresh context: look for code that is reachable in the shipped default configuration but is not used by any intended default functionality. For each finding Claude "designs and implements a gate and ensures that this causes no change in the program's default behavior" by running the project's own test suite plus a black-box regression suite against the baseline, and requiring identical results. Gates that would change a non-default configuration are set aside for a human.
With a fresh context: inventory entry points reachable under the default configuration that no intended default feature uses. For each, propose a gate that keeps default behaviour identical. Run the project test suite (and a black-box regression suite if we have one) against baseline and gated builds.
Pass 2: find complex or security-sensitive code that runs before a hard gate
Second pass, again with an empty context except a short note from the prior pass: look for security-sensitive or complex code that runs before authentication, without victim interaction, or before a protocol state-machine entry point, in any configuration. Anthropic's OpenSSH case study is the concrete example: ML-DSA-44 parsing was reachable by an unauthenticated client even when the algorithm was not enabled; the maintainers later moved the allow-list check before parsing.
Fresh context. From the entry points, find complex or security-sensitive code that runs before authentication or before a protocol state transition. Propose reordering the allow-list or config check so it runs before parsing or deserialization.
Pass 3: find configuration pairs that silently weaken a control
Third pass: combinations of options that look reasonable alone but, together, silently turn a security control off, leave behaviour undefined, or leave a listener reachable after the admin thinks it is disabled. Anthropic found 162 such combinations across the 25 projects; in 94 of them a control was silently switched off. Claude proposes rejecting the combination at config load, or documenting and guarding it.
Fresh context. Inventory security-relevant configuration options. Find pairs that the software accepts without error or warning and that silently disable or degrade a security control. Propose rejecting the pair at config load, or a guard that matches the documented intent.
Confirm every finding with a dynamic trace before you keep the patch
In every pass, Anthropic has Claude "create an inventory of the entry points from the code and confirms each finding with a dynamic trace of the program." A static guess is not enough. Keep only findings you can reproduce that way, then review the patch yourself.
For each candidate finding, show a dynamic trace that proves the code path is reachable under the stated configuration, then keep only the confirmed ones.
Why this works
Static guesses invent reachability; a trace shows it.
Or shrink the surface by moving features behind flags, then build a minimal binary
Joel Parker Henderson applied the same tactic to Vix IDE with this prompt: "Goal: rework to reduce the attack surface. Process: move features into feature-flag Rust crates. Output: build a minimal version. Questions: Ask me anything." Claude (Fable/Opus/Sonnet) split the codebase into separate crates and Cargo features so a security-oriented user can pick capabilities, and so an auditor can look at one capability at a time. He points at the commit messages in the repo rather than pasting them here.
Goal: rework to reduce the attack surface. Process: move features into feature-flag Rust crates. Output: build a minimal version. Questions: Ask me anything.
Why this works
Feature flags turn "reachable by default" into an explicit opt-in.
End of guide · Reviewed Oct 28, 2026
Pro tips2
- Treat Public, Gated and Private projects differently; gated projects are where early reachability is most surprising.
- Any gate that would change a non-default configuration is a human decision, not an automatic merge.
Common mistakes2
- Asking Claude only to find CVEs and skipping reachability; Anthropic argues fixing one vuln says nothing about the rest.
- Expecting Claude or Codex to always help with defensive security work; some developers report the models refuse audits or PoCs on their own code.


