Join our Newsletter — 33% off our NHI Course
Home Glossary Cyber Security Open/Closed Principle
Cyber Security

Open/Closed Principle

← Back to Glossary
By NHI Mgmt Group Updated September 9, 2026 Domain: Cyber Security

A software design principle that says components should be open for extension but closed for direct modification. It encourages adding behaviour through abstraction rather than rewriting core logic. In AI-generated code, the principle may be less dominant in some fast-changing areas, but it still supports safer evolution and cleaner boundaries.

Expanded Definition

The Open/Closed Principle is a design rule for software structure: existing modules should keep their established behaviour stable while new behaviour is introduced through extension points such as interfaces, composition, strategy objects, or plug-ins. It is usually applied to reduce regression risk, make code easier to evolve, and keep core logic from becoming a rewrite target every time requirements change.

The principle does not mean code should never change. It means changes should be concentrated at intentional boundaries rather than by editing a working component every time a new case appears. That boundary is often misunderstood: a system can be “open” in one place and still be tightly controlled elsewhere, which is normal and often desirable. In practice, good use of the principle is judged by how cleanly variation is isolated, not by whether a class is literally never edited again. For readers working with modern software delivery, the most useful boundary question is whether a new requirement can be added without destabilising the behaviour already relied on by other parts of the system.

For a concise external reference on the adjacent identity-security design concerns that often arise when software boundaries are extended, see the OWASP Non-Human Identity Top 10.

Examples and Use Cases

  • A payment service adds a new fraud rule by introducing a rule interface rather than editing a long conditional chain in the checkout flow.
  • A notification system supports email, SMS, and push by registering channel handlers, so each channel can evolve independently.
  • A policy engine keeps its core evaluation path stable while new policy types are added through plug-in modules.
  • An AI-generated codebase uses a small abstraction layer around external APIs so prompt-driven feature additions do not repeatedly alter the same core function.
  • A platform team exposes extension points for tenant-specific logic, which helps preserve the shared baseline while allowing controlled variation.

The main trade-off is that extension mechanisms add structure up front. If the variation is still speculative, over-engineering abstractions can make the code harder to read than a direct edit would have been.

Security Implications

When the Open/Closed Principle is ignored, security-sensitive logic often becomes a dense editing hotspot. That raises regression risk because each new feature, exception, or workaround can quietly alter authentication checks, authorisation paths, validation rules, logging behaviour, or error handling. A component that is repeatedly modified in place also becomes harder to review for unintended privilege changes, bypass conditions, and inconsistent enforcement.

Security impact usually shows up as fragile control boundaries rather than dramatic failure. A direct modification to a shared module can create one-off exceptions that bypass the intended path, or it can duplicate logic across multiple call sites until controls drift apart. That drift is especially dangerous when the code governs input validation, trust decisions, or privilege-sensitive workflow steps, because the system may appear to work while silently enforcing different rules in different places.

A practical sign of trouble is when teams keep patching the same function to accommodate new cases. That is often a signal that the design no longer isolates variation well enough for safe change.

Domain and Governance Relevance

In software engineering governance, the principle matters because it is a maintainability and change-control discipline, not just a coding style preference. It supports safer evolution of shared components, clearer ownership of extension points, and more predictable review scope when business logic changes. That predictability is especially valuable in systems where change velocity is high and regression tolerance is low.

Where the code also mediates access, credentials, or automation, the design boundary becomes more consequential. Extension through well-defined interfaces helps keep sensitive behaviour visible and reviewable, rather than scattering special cases across the codebase. For NHIMG, the relevant point is not that every design pattern becomes an identity issue, but that unstable core logic can undermine control consistency when software handles privileged or machine-driven actions. The principle therefore supports governance by making critical behaviour easier to reason about, test, and audit over time.

In practice, teams should treat the principle as a way to preserve control integrity during change, not as a mandate to abstract everything.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

CIS Controls v8 and NIST CSF 2.0 set the technical controls, while ISO/IEC 42001:2023 define the regulatory obligations.

FrameworkControl / ReferenceRelevance
CIS Controls v816 — Application Software SecurityApplies to reducing regression risk in security-relevant code changes.
Recommendation — Apply secure development practices to keep extension points reviewable and avoid altering trusted control logic directly.
NIST CSF 2.0PR.IP — Information Protection Processes and ProceduresSupports disciplined change handling and preserving control consistency over time.
Recommendation — Use PR.IP to manage changes so new functionality extends the design without destabilising existing security behaviour.
ISO/IEC 42001:2023A.6 — AI system lifecycleRelevant where AI-generated code changes need controlled evolution and boundary management.
Recommendation — Govern AI-assisted code changes so new behaviour is added through controlled extension rather than ad hoc rewrites.

Deepen Your Knowledge

Sign up to our weekly newsletter — get 33% off our NHI Foundation Level Course

    NHIMG Editorial Note
    Reviewed and updated by the NHIMG editorial team on September 9, 2026.
    NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org