StepGleam logoStepGleam
Coding guide

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.

~60 minAdvanced 80/100 6 steps Updated Oct 28, 2026
Claude CodeGit
Reduce attack surface with Claude before you chase individual CVEs — illustration for this Coding guide

Tools used

  • Claude CodeRuns the reachability passes and proposes gates or feature flags
  • GitReview the patch before you ship it
Step navigator0/6 done
0 of 6 steps done
What you'll get

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.

Who this is for

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.

Read this first

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

Step 1 of 6 · Coding

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.

Copy-ready promptClaude Code
Classify this project as Public, Gated or Private using Anthropic's definitions, and list the main network or protocol entry points.
Reduce attack surface with Claude before you chase individual CVEs — guide thumbnail
Why this works

Without that label, Claude cannot tell intended pre-auth surfaces from accidental ones.

Step 2 of 6 · Coding

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.

Copy-ready promptClaude Code
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.
Step 3 of 6 · Coding

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.

Copy-ready promptClaude Code
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.
Step 4 of 6 · Coding

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.

Copy-ready promptClaude Code
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.
Step 5 of 6 · Coding

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.

Copy-ready promptClaude Code
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.

Step 6 of 6 · Coding

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.

Copy-ready promptClaude Code
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.
FAQ2
Is there a ready-made Claude skill I can install?
Anthropic says they are integrating a three-pass skill into OSS-Scanner. This guide does not invent that file. Use the method below, or wait for the published skill.
Will Claude always cooperate on security work?
Not always. One HN commenter with years of history had to switch models for early CVE investigation because Claude and Codex refused, then switched back for the fix.