Heuristic:AISecurityLab Hackagent Guardrail Fail Open
| Knowledge Sources | |
|---|---|
| Domains | Security_Testing, Guardrails, Error_Handling |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Guardrail classifiers fail open on error or unparseable output, letting traffic through rather than blocking the entire run — a misconfigured guardrail never halts a red-team campaign.
Description
A guardrail wraps a target model with a content-safety classifier that checks prompts (before) and replies (after). When the classifier model is unavailable, returns an error, or produces unparseable output, the guardrail must decide: block the text (fail closed) or let it through (fail open).
HackAgent guardrails fail open. An unavailable or unparseable classifier returns GuardrailResult(is_safe=True) with an explanation noting the guardrail was unavailable. This ensures a misconfigured endpoint, a rate-limited classifier, or a malformed JSON response never blocks the whole campaign. Blocking everything would produce no attack data at all — the opposite of what a red-team tool needs.
The fail-open policy applies at two levels:
- ModelGuardrail.check: If the classifier call returns an error, the text passes.
- parse_verdict: If the raw text is not valid JSON, it falls back to keyword detection (unsafe, "safe": false). Only if keywords are also absent does it default to safe.
Usage
Use this heuristic whenever you wrap a target with guardrail classifiers in a red-team campaign. It is the default and only behavior — there is no fail-closed mode. Configure guardrails.before and/or guardrails.after in the campaign YAML; the fail-open policy applies automatically. Be aware that a downed guardrail classifier silently lets all traffic through, so monitor guardrail availability via the preflight check (execution.preflight: true, the default).
The Insight (Rule of Thumb)
- Action: Leave guardrails configured as-is; they fail open by default. Ensure execution.preflight: true (the default) so an unreachable guardrail is caught before the run starts.
- Value: Fail-open on classifier error; keyword-detection fallback on unparseable JSON; default to is_safe=True when no signal is found.
- Trade-off: A downed guardrail lets attacks through unfiltered, which could produce false jailbreak successes. Preflight mitigates this by checking reachability before the run. Without preflight, a silent guardrail failure inflates attack success rates.
- When to worry: If preflight is disabled and a guardrail classifier is down, all guardrail-blocked attempts become target successes. Always keep preflight on for guarded campaigns.
Reasoning
A red-team campaign's purpose is to measure how many attacks succeed against a target. A guardrail that fails closed (blocks everything on error) would make every attempt look blocked, producing a 0% attack success rate that reflects the guardrail outage, not the target's actual safety. This is worse than no guardrail — it is misleading.
Failing open means the campaign continues measuring the target directly when the guardrail is unavailable. The guardrail's blocks are recorded separately (in GuardrailInfo), so defense effectiveness can still be measured when the guardrail is working. Preflight catches the outage case before the run, so the user can fix the guardrail rather than run an unguarded campaign by accident.
The keyword-detection fallback in parse_verdict handles the middle ground: a classifier that returns malformed JSON but includes the word unsafe still blocks. This recovers partial signal from broken responses without the risk of blocking everything.
Code Evidence
Fail-open on classifier error from guardrail.py:85-107:
def check(self, text: str) -> GuardrailResult:
"""Classify ``text``; fails open when the classifier is unavailable."""
if not text or not text.strip():
return GuardrailResult(is_safe=True, explanation="No content to classify.")
completion = self.llm.complete([...], max_tokens=256, temperature=0)
if completion.error is not None:
logger.warning(
"Guardrail model error — failing open. Error: %s",
completion.error.message,
)
return GuardrailResult(
is_safe=True,
explanation=f"Guardrail unavailable: {completion.error.message}",
)
return parse_verdict(completion.text or "")
Fail-open policy documented in the spec from spec.py:205-213:
class GuardrailsSpec(_Spec):
"""Classifier models that defend the target.
``before`` checks each prompt and blocks an unsafe one before it reaches the
target; ``after`` checks the reply and withholds an unsafe one. Both fail open:
an unavailable or unparseable classifier lets the text through, so a
misconfigured guardrail never blocks the whole run.
"""