Safeguard
Security Guides•

Using a feature flag kill switch to contain a security incident

A kill switch lets you disable a risky feature in seconds without a redeploy. How to design, test and govern one so it works during an incident.

Safeguard Security Team
4 min read

A kill switch is an operational feature flag that turns off a feature or degrades behavior without a deploy. For security it buys time: when a flaw is found in one feature, you disable that feature in seconds while a proper fix is built. It only works if you designed it, tested it and know who may flip it.

The category it belongs to

Martin Fowler's article on feature toggles separates four kinds by lifespan and how often decisions change. Release toggles hide unfinished work and last a week or two. Experiment toggles support A/B tests. Permissioning toggles expose features to groups of users and can last years. Ops toggles let operators disable or degrade behavior during problems or high load. Most ops toggles are short lived, but some kill switches may persist almost indefinitely, and the article says they need very fast reconfiguration.

That last point is the design requirement. A kill switch that needs a redeploy is not a kill switch.

Where kill switches earn their place

Good candidates are features with a large attack surface or a history of trouble:

  • File upload and processing
  • Third party integrations and webhooks that accept outside input
  • Export and bulk download functions
  • Newly released endpoints
  • Anything that calls an AI model with user supplied content

If a vulnerability appears in one of these, turning it off may be an acceptable temporary response, while the rest of the product keeps working.

Design rules

  1. Off must be safe. Decide what users see when the feature is disabled. A clear message beats an error page.
  2. Fast propagation. Check how long a flag change takes to reach every instance. Measure it.
  3. Evaluate at the right layer. Server side enforcement is what protects you. Hiding a button in the interface while the endpoint stays live does nothing against an attacker.
  4. Fail closed where it matters. Decide what happens if the flag service is unreachable. For a risky feature, default to disabled.
  5. No dependency on the thing that is broken. If the flag console needs the same login system you are trying to contain, you have a problem.

Governance

Name who may flip each switch, and write it in the incident runbook. Log every change with who, when and why. Limit edit rights, since a flag system with broad write access is itself a target. Fowler's article notes that flag categories differ in who owns the configuration and how it changes, so manage kill switches under their own rules.

Test it

Fowler advises testing both the on and off states of any toggle that could go live, using the convention that off keeps legacy behavior and on enables the new. For kill switches, add a drill: flip it in staging, confirm the feature is unreachable at the server, confirm the rest works, flip it back. Repeat every quarter.

What a kill switch does not do

It does not fix the flaw. It does not cover data already exposed. And it only protects features that were built with a switch. Treat it as a first response and follow with a fix, review and, if needed, disclosure.

Safeguard's asset discovery and reachability analysis help you see which features and components are actually exposed, so you know where switches are worth building. The free scan is at gold.safeguard.sh/scan.

Quick check

Is hiding a feature in the interface enough?

No. The server must refuse requests for the disabled feature, or an attacker can call the endpoint directly.

Should the flag default to on or off if the flag service fails?

For risky features, default to off. For essential features, weigh availability and decide in advance.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.