Fail-secure design: preserve security policy and recovery when failures occur
Fail-secure design prevents an error in a security control or system from silently weakening the security policy. It does not mean shutting down every function whenever access verification fails. Decide in advance, based on the resource and service risk, which action must be denied, which public function may continue, and whether a limited fallback is safe; then test those choices.
Fail-secure design: preserve security policy and recovery when failures occur
Fail-secure design prevents an error in a security control or system from silently weakening the security policy. It does not mean shutting down every function whenever access verification fails. Decide in advance, based on the resource and service risk, which action must be denied, which public function may continue, and whether a limited fallback is safe; then test those choices.
This guide covers failures and exceptions in application authentication and authorization, policy lookups, required validation, and state changes. For user-facing permission and visibility settings at first use, see the guide to designing secure defaults.
What does it mean to fail securely?
The NIST glossary defines fail secure as terminating system functions in a way that prevents loss of a secure state when a failure occurs or is detected. OWASP also explains that exceptions in a security control must not enable behavior the control would normally disallow, and that errors in surrounding code may prevent the control from running at all. The design considers confidentiality, integrity, and availability while ensuring a failure does not violate security policy.
“Fail open” commonly means continuing with permission when a check fails; “fail closed” means denying. Turning a failed authorization check into an allow decision is a fail-open weakness. But stopping the entire service for every failure may protect access while seriously harming availability. Fail-secure therefore does not mean “always shut”; it means preserve the policy while retaining only functions that remain safe.
Which failure paths need design?
Testing only successful responses can miss paths that break policy during failure. Review security across initialization, normal operation, shutdown, maintenance, and recovery.
| Failure or exception | Security question | Example design direction |
|---|---|---|
| Authentication or authorization timeout | Can an unchecked request pass? | Do not treat a failed check as approval for sensitive reads or changes. If no reviewed limited policy exists, deny that action. |
| Policy engine or attribute store outage | Is a stale or partial policy used? | Define the authority and freshness of data, and how quickly revocation must take effect. Defer a decision if those conditions are not met. |
| Input, signature, or token validation exception | Does a partial check count as valid? | Do not treat incomplete validation as success. Make parsing, signature, expiry, audience, and issuer checks explicit. |
| Storage interruption or process termination | Can state change only partly or a request run twice? | Use appropriate atomicity around authorization and state change, with a way to restore consistency after interruption. |
| Logging or error-handling failure | Can a response reveal sensitive data or skip a security check? | Separate user responses from internal diagnostics and ensure error handlers do not bypass protection. |
| Restart, recovery, or failover | Can recovery revive old permissions or temporary exceptions? | Include resynchronization, session and policy reevaluation, and expiry of temporary exceptions in recovery procedures. |
These are examples, not a universal instruction to block every request. Public static content, a general health check, and a sensitive organization-data change need not share the same failure policy. Record decisions for each resource, action, and sensitivity level.
How can denial be balanced with availability?
First estimate the consequence of each action failing. If an incorrect allow could expose another organization’s data, enable account takeover or privilege escalation, or cause a financial transaction, the action needs strict validation. Separately decide whether an outage should also stop public help pages or non-sensitive, read-only information. Consider data sensitivity, mutability, outage duration, trustworthiness of fallback evidence, and operational impact.
Hypothetical example: an API that changes a project checks authorization with a central policy service. If the service does not respond, deny the change while continuing to serve a public help page designed for everyone. A brief cached permission for a read may be an option only after defining how quickly revocation must take effect, whether the cache is separated by user, organization, and action, and what happens on expiry. This is a design option to evaluate, not a claim about a real system or a universal recommendation.
Skipping a failed security control or automatically falling back to weaker cryptography, broad permissions, or an unvalidated old token is not a safe fallback. If a fallback is allowed, specify its preconditions, allowed functions and data, duration, reevaluation and termination rules, and owner. If its conditions cannot be verified, do not guess; switch to a limited behavior.
How should implementation distinguish allow, deny, and error?
A security decision should represent processing failure separately from allow and deny. Catching an exception and converting it to allow, or initializing a result as allowed and leaving it unchanged after a failed check, can create a bypass. Conversely, turning every error into an unexplained ban can make recovery difficult. Sensitive actions must not be allowed on error, but the error type and scope should be recorded and an explicit recovery path provided.
For state changes, use the synchronization or transaction boundary needed to prevent another request from changing state between authorization and the update. If the same request may be retried after interruption, check that it cannot create duplicate records, charges, or invitations. The implementation depends on the database and request; no single technique is a universal prescription.
How should validation and recovery be tested?
In a non-production environment, inject timeouts, disconnections, malformed responses, partial initialization, storage failures, restarts, and retries before recovery has completed. For each case, verify that:
A protected action does not complete without explicit approval.
Public or read-only functions continue only within their documented scope.
Error responses expose no secrets, internal paths, or another user’s data.
Internal logs aid diagnosis without indiscriminately recording secrets or sensitive request bodies.
After recovery, permissions and state are synchronized and no temporary exception or partial state remains.
Operators can detect a prolonged failure and follow a safe recovery procedure.
OWASP advises checking not only exceptions inside the security function but also exceptions in other code that may prevent the function from being called. For example, a failure in preprocessing may skip authorization entirely; testing the authorization function alone would miss this. Tests should include call order and injected failures at integration level.
How can a team decide the design is ready?
For each security function and critical dependency, document and test the allow, deny, and error outcomes; which functions remain available on error; fallback conditions; and recovery invariants. Define retries and outage detection for each service, checking that infinite retries or automatic degradation do not weaken the security boundary. The goal is to preserve confidentiality and integrity policy during failure and, when possible, restore only functions with a bounded safe scope.
Fail-secure design does not prevent every attack or outage. Deciding in advance what continues and what stops—and verifying the real exception and recovery paths—reduces the chance that a service will bypass security rules for convenience.
References
NIST CSRC Glossary, fail secure — definition of preserving a secure state when a system failure occurs or is detected.
NIST SP 800-53 Rev. 5, SA-8 Security and Privacy Engineering Principles — secure failure and recovery while maintaining policy across normal, degraded, and alternative modes.
OWASP Foundation, Fail Securely — risks and examples involving exceptions in security controls and code that can skip them.
MITRE CWE-636, Not Failing Securely (Failing Open) — design weakness of falling back to weaker cryptography or more permissive access on error.