Part 5 of 13 · 3 min read
Three similar guards share a blind spot; decide in advance what a broken guard should do
Stacking filters that fail for the same reason multiplies effort, not protection, and a guard that can itself break needs a decision made before it does.
Think of putting three umbrellas over the same exact spot on a rainy day, versus spreading three smaller umbrellas across a wider area. If the rain is coming from one direction, three stacked umbrellas are barely better than one. Three umbrellas positioned differently each cover something the others miss.
correlated failure means layers fail on the same inputs, so combined protection is weaker than the product of their individual rates would suggest. Three guards that each catch 80% of attacks only reach 99.2% combined if they fail independently, but if they share a blind spot that figure collapses toward the single-layer rate -- and separately, fail open means allowing the action if a check itself breaks, while fail closed means denying it, a decision that has to be made deliberately because a security check that silently fails open is no check at all.
A worked example. With three layers each missing 20% of attacks, independent failure gives a combined miss rate of 0.8% -- the product of the misses. At a correlation of 0.5 between what each layer misses, the combined miss rate rises to 5.0%; at 0.9, it's 12.8%; at a correlation of 1.0 (all three share the exact same blind spot), it's 20.0% -- identical to running just one layer alone, because the other two never catch anything the first one missed. Separately, when the guard itself errors on 5% of calls, failing closed passes 0% of attacks through but blocks 4.2% of legitimate outputs as collateral damage; failing open passes 5.2% of attacks through and blocks 0% of legitimate outputs.
The key lines. From code/mini-guardrails/guardrails.py:
# from code/mini-guardrails/guardrails.py
def guarded(check, action, on_error="closed"):
"""Run `check(x)`; allow `action` only if it returns no flags. If the check raises: closed denies, open allows."""
def run(x):
try:
flags = check(x)
except Exception:
return action(x) if on_error == "open" else None
return None if flags else action(x)
return run
Read it as: the except Exception branch is where the real decision lives. Everything above it is the ordinary pass/fail logic of the guard. The one line choosing between action(x) and None when the guard itself has crashed is the entire fail-open-versus-fail-closed policy. It is made explicit as a single parameter, rather than left to whatever happens to occur when an exception propagates unhandled.
Fail open, fail closed, correlated failure
Fail open means if the check breaks, allow the action; fail closed means if the check breaks, deny the action. Correlated failure is layers failing on the same inputs, so combined protection is weaker than the product of their rates.
Example: the miss rate climbing from 0.8% to 20.0% purely as correlation rises from 0 to 1, with each layer's own 20% miss rate never changing, is correlated failure stated as one number moving while nothing about any individual guard changed -- which is why "we have three layers of defence" is a claim worth asking a follow-up question about: three layers against what, failing for which different reasons?