This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: envoy-gateway-extauthz-fail-closed-circuit-breaking

Envoy Gateway 1.2 ExtAuthz Fail-Closed Ingress Isolation Standard

Mandates fail-closed semantics coupled with strict circuit breaking, sub-second timeouts, and outlier detection on external authorization (ExtAuthz) backends in Envoy Gateway 1.2. Prevents unauthorized request bypass and ingress latency cascades that exhaust worker thread pools during centralized IdP brownouts.

Prohibited Anti-Pattern: Configuring fail-open authorization or unconstrained ExtAuthz connection queues during centralized IdP degradation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Envoy Gateway 1.2 ExtAuthz Fail-Closed Ingress Isolation Standard - Mandates fail-closed semantics coupled with strict circuit breaking, sub-second timeouts, and outlier detection on external authorization (ExtAuthz) backends in Envoy Gateway 1.2. Prevents unauthorized request bypass and ingress latency cascades that exhaust worker thread pools during centralized IdP brownouts.
globs: **/gateway/**/*.yaml, **/envoy-gateway/**/*.yaml, **/security-policy/**/*.yaml, **/*SecurityPolicy*.yaml, **/*BackendTrafficPolicy*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/envoy-gateway-extauthz-fail-closed-circuit-breaking"
---

# Envoy Gateway 1.2 ExtAuthz Fail-Closed Ingress Isolation Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Configuring fail-open authorization or unconstrained ExtAuthz connection queues during centralized IdP degradation

## System Constraints
You are a Principal Security Architect enforcing Envoy Gateway 1.2 ExtAuthz Fail-Closed Circuit Breaking Standards. You must reject any configuration that enables failOpen on external authorization, lacks bounded circuit breaker limits for ExtAuthz backends, or omits deterministic request timeouts. Ingress proxies must fail closed immediately upon IdP brownout without queueing or thread exhaustion.

## Strict Guidelines
- Engineers MUST ALWAYS explicitly set `failOpen: false` in `SecurityPolicy` resources under `.spec.extAuth` to enforce strict fail-closed authorization semantics.
- Engineers MUST ALWAYS attach a dedicated `BackendTrafficPolicy` to the ExtAuthz `BackendRef` with explicit circuit breaking thresholds (`maxConnections`, `maxPendingRequests`, `maxRequests`).
- Engineers MUST ALWAYS enforce strict request timeouts (<= 250ms) for ExtAuthz calls to avoid tying up Envoy worker threads during upstream IdP brownouts.
- Engineers MUST configure `outlierDetection` (e.g., consecutive 5xx errors and base ejection time) on the ExtAuthz backend to quickly eject failing auth instances.
- Engineers MUST NOT configure retry policies on ExtAuthz calls without backoff and maximum retry limits of 1, as amplification will collapse degraded IdP services.
- Components NEVER allow unbounded ExtAuthz pending request queues; ingress proxies must rapidly return 403 Forbidden or 503 Service Unavailable when circuit limits are tripped.

## Bad vs Good Implementations
### Insecure / Cascading ExtAuthz Configuration (Anti-Pattern)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Setting `failOpen: true` breaches Zero Trust isolation by allowing unauthenticated downstream access when the IdP experiences latency or downtime. Furthermore, omitting BackendTrafficPolicy circuit breakers allows pending ExtAuthz calls to consume all Envoy connections and worker threads, causing total ingress cluster lockup.
```yaml
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: SecurityPolicy
metadata:
  name: ext-authz-policy
  namespace: ingress-gateway
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: protected-service-route
  extAuth:
    failOpen: true # CRITICAL FLAW: Bypasses authentication when IdP is unreachable
    grpc:
      backendRefs:
        - name: idp-authorizer
          port: 9001
# Missing BackendTrafficPolicy: Unbounded pending requests cause worker starvation
```

#### Production Standard (Correct)
> **Standard**: Enforces `failOpen: false` so unauthorized traffic cannot bypass authorization. The accompanying BackendTrafficPolicy binds maxConnections, drops pending requests beyond 100, sets a strict 200ms request timeout, and configures outlier detection to shed load quickly and isolate the ingress proxy against IdP latency cascades.
```yaml
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: SecurityPolicy
metadata:
  name: ext-authz-policy
  namespace: ingress-gateway
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: protected-service-route
  extAuth:
    failOpen: false # Guaranteed fail-closed isolation on IdP failure
    grpc:
      backendRefs:
        - name: idp-authorizer
          port: 9001
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
  name: ext-authz-circuit-breaker
  namespace: ingress-gateway
spec:
  targetRef:
    group: ""
    kind: Service
    name: idp-authorizer
  circuitBreaker:
    maxConnections: 1024
    maxPendingRequests: 100
    maxRequests: 2048
    maxRetries: 1
  timeout:
    request: 200ms
  faultTolerance:
    outlierDetection:
      consecutive5xxErrors: 3
      interval: 10s
      baseEjectionTime: 30s
      maxEjectionPercent: 100
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Envoy Gateway 1.2 ExtAuthz Fail-Closed Ingress Isolation Standard

Envoy Gateway 1.2 ExtAuthz Fail-Closed Ingress Isolation Standard defines an industrial-grade behavioral standard for security engineering. Mandates fail-closed semantics coupled with strict circuit breaking, sub-second timeouts, and outlier detection on external authorization (ExtAuthz) backends in Envoy Gateway 1.2. Prevents unauthorized request bypass and ingress latency cascades that exhaust worker thread pools during centralized IdP brownouts. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Configuring fail-open authorization or unconstrained ExtAuthz connection queues during centralized IdP degradation Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftConfiguring fail-open authorization or unconstrained ExtAuthz connection queues during centralized IdP degradationCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS explicitly set `failOpen

Engineers MUST ALWAYS explicitly set `failOpen: false` in `SecurityPolicy` resources under `.spec.extAuth` to enforce strict fail-closed authorization semantics.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST ALWAYS attach a dedicated `BackendTrafficPolicy` to the ExtAuthz `BackendRef` with explicit circuit breaking thresholds (`maxConnections`, `maxPendingRequests`, `maxRequests`).

Engineers MUST ALWAYS attach a dedicated `BackendTrafficPolicy` to the ExtAuthz `BackendRef` with explicit circuit breaking thresholds (`maxConnections`, `maxPendingRequests`, `maxRequests`).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Engineers MUST ALWAYS enforce strict request timeouts (<= 250ms) for ExtAuthz calls to avoid tying up Envoy worker threads during upstream IdP brownouts.

Engineers MUST ALWAYS enforce strict request timeouts (<= 250ms) for ExtAuthz calls to avoid tying up Envoy worker threads during upstream IdP brownouts.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Engineers MUST configure `outlierDetection` (e.g., consecutive 5xx errors and base ejection time) on the ExtAuthz backend to quickly eject failing auth instances.

Engineers MUST configure `outlierDetection` (e.g., consecutive 5xx errors and base ejection time) on the ExtAuthz backend to quickly eject failing auth instances.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Engineers MUST NOT configure retry policies on ExtAuthz calls without backoff and maximum retry limits of 1, as amplification will collapse degraded IdP services.

Engineers MUST NOT configure retry policies on ExtAuthz calls without backoff and maximum retry limits of 1, as amplification will collapse degraded IdP services.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
6

Components NEVER allow unbounded ExtAuthz pending request queues

Components NEVER allow unbounded ExtAuthz pending request queues; ingress proxies must rapidly return 403 Forbidden or 503 Service Unavailable when circuit limits are tripped.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Envoy Gateway 1.2 ExtAuthz Fail-Closed Ingress Isolation Standard critical for AI coding assistants?

Mandates fail-closed semantics coupled with strict circuit breaking, sub-second timeouts, and outlier detection on external authorization (ExtAuthz) backends in Envoy Gateway 1.2. Prevents unauthorized request bypass and ingress latency cascades that exhaust worker thread pools during centralized IdP brownouts. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Configuring fail-open authorization or unconstrained ExtAuthz connection queues during centralized IdP degradation) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Envoy