Join our Newsletter — 33% off our NHI Course
Home› Guides› Feature Flags for Beginners: Switching Features On and…
Guide Application Security

Feature Flags for Beginners: Switching Features On and Off and Why the Switches Need Guarding

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 2 December 2026 11 min read
On this page

A feature flag is a switch that turns part of an app on or off without changing its code.

This guide is for anyone who has heard "we'll just flip a flag" and wants to know what that means. You do not need to write code to be affected: if your business runs apps or websites, a flag change can alter what every customer sees, with no new release.

In short

  • A feature flag lets a team switch a feature on or off while the app keeps running.
  • Teams use flags to release slowly, test ideas and turn off a broken feature fast.
  • Whoever can change a flag can change how the live app behaves, so that power needs guarding.
  • Limit who can flip live flags, keep flag keys secret, log every change and remove old flags.

What you will learn

  • Explain what a feature flag is in one sentence.
  • Spot the people and tools that can change flags in your apps.
  • Check that flag changes are limited and recorded.
  • Ask why a flag should not be the only lock on private data.
On and off switch for a feature (feature flag)
a setting the app checks to decide which version of a feature to run.
Flag service
a tool where people store and change flags, and where apps fetch them.
Software password for the flag service (SDK key)
a secret code an app uses to fetch its flags.

What is a feature flag?

Think of a light switch on a wall. The wiring is already in place, and the switch decides whether the light comes on. A feature flag works like that for software.

The new feature's code is already inside the app. A feature flag is a setting the app checks at run time to choose between two paths[2]. If the flag is on, people get the new feature. If it is off, they get the old one. Flags let teams change how a system behaves without changing its code[1]. Flags are also called feature toggles.

Flags can be smarter than a simple switch. A rule can turn a feature on for staff only, for one country, or for one in ten users. This is called targeting: rules that decide which value each user gets[2].

Where the comparison stops working: a light switch sits in one room, in plain sight. A flag service can change features for every user at once, from anywhere, and the change may not be visible unless someone checks the records.

Why does it matter?

Changing a flag is a change to the live app. If the wrong person or tool can change flags, they can change what customers see and do.

If you manage a product or service

What could happen: a flag is switched on by mistake and a half-finished feature reaches every customer.

Check this: ask who can change flags in the live app, and whether a second person checks big changes.

Next: Change Management Security

If you are a developer

What could happen: a flag key with power to change flags is pasted into code and copied by someone else.

Check this: keep secret flag keys in a vault, not in code or chat.

Next: Secrets Management for Beginners

If you are new to IT or security work

What could happen: a paid feature is hidden by a flag in the browser, and a curious user turns it on.

Check this: make sure the server also checks who may use each paid or private feature.

Next: Least Privilege for Beginners

What does it look like?

Here is a made-up flag, as a team might see it in a flag service.

Example only. All values are made up.

Flag name:      new-checkout-EXAMPLE
Live app:       ON for 10% of users         (1)
Test app:       ON for everyone
Who can edit:   everyone in the company     (2)
SDK key:        FAKE-sdk-key-0000           (3)
Last changed:   0000-00-00 by FAKE Name     (4)
Created:        two years ago, still here   (5)
  1. A targeting rule: one in ten users sees the new checkout.
  2. Too many people are allowed to change this flag.
  3. In a real file, this line would contain a secret key that lets an app fetch flags.
  4. A change record, so the team can see who flipped it and when.
  5. An old flag that nobody removed.

Why this is risky: anyone in the company could change the live checkout. The old flag also keeps code paths that nobody checks any more.

The safer way: a small, named group can change live flags. Keys sit in a vault. Every change is logged, and old flags are removed.

How does it work?

  1. The code is shipped with the flag. The new feature goes into the app, switched off. Teams use this to keep "shipping code" apart from "turning it on"[1].
  2. Someone sets a rule. A person, or a tool with its own key, sets the flag in the flag service: on, off, or on for some users.
  3. The app asks. When the app reaches that point, it checks the flag and picks a path.
  4. People see the result. The new feature appears or disappears with no new release.
  5. The flag is removed. When the feature is settled, the team deletes the flag and the old code. Flags add complexity, so guidance suggests keeping the number low and setting removal dates[1].

Some flags run on the server, and some run in the user's browser or phone app. Code on a user's device can be unpacked and examined. For this reason, one flag service keeps sensitive data out of what it sends to devices[3]. The same documentation says server keys should be kept secret, while the IDs used in browsers do not need to be[3].

Diagram titled How a feature flag changes what people see. Four boxes in a row joined by arrows. Box 1, Someone flips it: a person, or a tool with its own key, changes a flag in the flag service. Box 2, Rules are saved: the flag service stores who gets the feature, everyone, a group or a share. Box 3, The app asks: the app checks the flag each time it needs to choose, on or off. Box 4, People see it: users get the new feature, or the old one, with no new release. A note underneath says to guard step 1: only a few named people should change live flags, the keys used by tools are kept secret, and every change is logged. A flag in the user's own browser or phone can be read, so it should not be the only lock on anything private.
Figure 1. A flag change reaches users without a new release, so the first step needs the most care.

A worked example

Freya Engel leads a small team that runs an online booking app. The team is building a new way to pay. They put it behind a flag called new-payments, switched off.

When the code is ready, Freya's colleague Pia Lindahl turns the flag on for staff only. Staff test it for a week. Then Pia sets it to one in ten customers. Payment errors stay low, so she raises it to everyone over the next fortnight.

One evening, the payment supplier has problems. Pia switches the flag off. Customers go back to the old way to pay within a short time, and no new release is needed. This is the kind of quick off switch that flags are often used for[1].

Afterwards, Freya reviews the flag service. She finds that all twenty people in the company can change live flags. She also finds a flag key with editing power saved in an old script.

Freya makes three changes. Only four named people can now change live flags, and a second person approves big ones. The old key is replaced and the new one is kept in the team's vault. Flag changes now go into the same log as other changes, so they show up if something breaks.

A month later, the new payments work well. Pia deletes the flag and the old payment code, so nobody can switch the old path back on by mistake.

Old code left behind a flag can cause harm. In 2012, a US trading firm reused a flag that had once switched on old code. One server still held that code, and the firm lost more than 460 million US dollars in about 45 minutes[4][5].

Myths and mistakes

What people thinkWhat is true
Flipping a flag is not a real change.It changes the live app. Treat it with the same care as a release.
A hidden feature is a secure feature.A flag in the browser or phone can be read or changed. Check access on the server too.
Everyone on the team should be able to flip flags.Give live flag rights to a few named people, and log every change.
Old flags do no harm.Old flags keep old code paths alive. Remove them once a feature is settled.
All flag keys are secret.Some IDs sit in browser code and are not secret. Server keys and editing keys must be kept secret.

What can I do this week?

  • Ask which flag service your apps use, and who looks after it.
  • List the people and tools that can change live flags.
  • Check that flag changes are recorded with a name and a time.
  • Search your code and scripts for flag keys left in plain sight.
  • Pick one old flag and plan to remove it.

Checklist

  • Only a small, named group can change live flags.
  • Big flag changes get a second person's approval.
  • Staff sign in to the flag service through the company's normal sign-in.
  • Server keys and editing keys are kept in a vault.
  • Every flag change is logged and kept.
  • Private or paid features are also checked on the server.
  • No personal data is sent to devices in flag rules.
  • Each flag has an owner and a planned removal date.

Common questions

Are feature flags and feature toggles the same thing?

Yes. Both names describe a setting that lets a team switch a feature on or off while the app is running. Some teams also say feature switches. The security advice is the same whichever name you use.

Why do flags need guarding?

Because changing a flag changes the live app. Someone who can flip flags can turn features on or off for every user. That is real power, so limit who has it, keep the keys secret and record every change.

Can a feature flag control who sees private data?

Only with care. A flag in a browser or phone app can be read and changed by the user. If a flag hides private data or paid features, the server should also check that the user is allowed in.

What is a kill switch?

A kill switch is a flag kept to turn a feature off fast if it causes trouble. Teams use it when a feature breaks or a system is under strain. It should be tested, and only trusted people should be able to use it.

When should a flag be removed?

Once the feature is fully on, or fully dropped, and the team is confident in it. Leaving flags in place keeps old code alive and adds complexity. Give each flag an owner and a removal date when you create it.

Where next?

Ready for the detail? Read the practitioner guide: Feature Flag Security. It goes further into SDK keys and management tokens, admin roles and approvals, audit logging, and targeting data and privacy.

Also useful:

Related NHI Mgmt Group resources: Secrets Management for Beginners, Security Logging for Beginners and Non-Human Identities for Beginners.

Key terms

Feature flag
A setting checked at run time that turns a feature on or off for some or all users.
Feature toggle
Another name for a feature flag.
Kill switch
An emergency control used to stop something quickly, such as a flag that turns a failing feature off.
API key
A secret code a program uses to prove it may use a service, such as a flag key.
Audit trail
A record in time order of who did what, so changes can be traced.
Separation of duties
Splitting a sensitive task so one person cannot do all of it alone, such as needing a second approver.
Least privilege
Giving each person or tool only the access it needs, and no more.

Sources and further reading

  1. Pete Hodgson, "Feature Toggles (aka Feature Flags)", martinfowler.com, last revised 9 October 2017. https://martinfowler.com/articles/feature-toggles.html (accessed 2 Dec 2026).
  2. OpenFeature, "Glossary", OpenFeature Specification. https://openfeature.dev/specification/glossary (accessed 2 Dec 2026).
  3. LaunchDarkly, "Client-side, server-side, and edge SDKs", LaunchDarkly documentation. https://launchdarkly.com/docs/sdk/concepts/client-side-server-side (accessed 2 Dec 2026).
  4. US Securities and Exchange Commission, "In the Matter of Knight Capital Americas LLC", Release No. 34-70694, 16 October 2013. https://www.sec.gov/files/litigation/admin/2013/34-70694.pdf (accessed 2 Dec 2026).
  5. US Securities and Exchange Commission, "SEC Charges Knight Capital With Violations of Market Access Rule", press release 2013-222, 16 October 2013. https://www.sec.gov/newsroom/press-releases/2013-222 (accessed 2 Dec 2026).

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.