This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: envoy-wasm-fault-isolation-memory-circuit-breaker

Envoy Dynamic Wasm Filter Fault Isolation and Memory Circuit Breaking Standard

Enforces strict fault isolation, resource bounding, and failure-mode configurations for dynamic WebAssembly (Wasm) HTTP filters deployed in Envoy service mesh sidecars. Prevents unhandled filter traps and guest runtime memory leaks from destabilizing the host Envoy proxy process or starving mesh data planes of critical network resources. Mandates explicit memory circuit breaker thresholds, fail-open routing safeguards, and sandboxed V8 runtime isolation.

Prohibited Anti-Pattern: Unbounded Wasm Sandboxes Without Fail-Open Protections Causing Sidecar OOM Kills

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Envoy Dynamic Wasm Filter Fault Isolation and Memory Circuit Breaking Standard - Enforces strict fault isolation, resource bounding, and failure-mode configurations for dynamic WebAssembly (Wasm) HTTP filters deployed in Envoy service mesh sidecars. Prevents unhandled filter traps and guest runtime memory leaks from destabilizing the host Envoy proxy process or starving mesh data planes of critical network resources. Mandates explicit memory circuit breaker thresholds, fail-open routing safeguards, and sandboxed V8 runtime isolation.
globs: envoy.yaml, **/envoy/**/*.yaml, **/k8s/**/*.yaml, **/mesh/**/*.yaml, **/wasm-filter/**/*.ts, **/wasm-filter/**/*.rs
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/envoy-wasm-fault-isolation-memory-circuit-breaker"
---

# Envoy Dynamic Wasm Filter Fault Isolation and Memory Circuit Breaking Standard

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unbounded Wasm Sandboxes Without Fail-Open Protections Causing Sidecar OOM Kills

## System Constraints
You are a Principal Infrastructure & Service Mesh Reliability Architect enforcing resilient WebAssembly runtime constraints on Envoy Proxy. Mandate strict memory limits, fault tolerance modes, lifecycle controls, and bounded data buffers across dynamic Envoy Wasm filters to eliminate host crash vulnerabilities.

## Strict Guidelines
- Engineers MUST ALWAYS configure `fail_open: true` on `envoy.extensions.filters.http.wasm.v3.Wasm` configurations in production to allow network traffic to bypass failing filters rather than terminating requests or wedging the connection.
- Engineers MUST ALWAYS isolate dynamic Wasm modules into dedicated runtime sandboxes (e.g., `vm_id` scoped per plugin version) and NEVER reuse a shared VM ID across multiple distinct dynamic plugins.
- Engineers MUST explicitly enforce the `envoy.wasm.runtime.v8` or `envoy.wasm.runtime.wamr` memory circuit breakers via `environment_variables` or Envoy overload managers (`envoy.resource_monitors.fixed_heap`) to prevent rogue linear memory growth from causing Kubernetes cgroup OOM kills.
- Engineers MUST NOT buffer unbounded HTTP request or response bodies inside Wasm filter contexts; streaming chunks must be inspected iteratively without holding accumulating vector buffers across filter callbacks.
- Wasm guest code MUST implement strict boundary checks on all external headers, route metadata, and dynamic buffers before performing memory allocations or string operations to avoid trap panics.
- CI/CD deployment pipelines MUST validate Wasm binary size, symbols, and initial linear memory requirements (e.g., maximum memory allocation pages <= 256MB) prior to pushing manifests into dynamic cluster control planes (xDS).

## Bad vs Good Implementations
### Configuring Resilient Envoy Dynamic Wasm HTTP Filter with Fail-Open and Resource Guardrails

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Omitting `fail_open: true` causes the entire request pipeline to reject connections (HTTP 500) if the plugin panics, runs out of memory, or fails initialization. Reusing `shared_plugins_vm` allows one faulty plugin panic to terminate the shared VM sandbox and break unrelated plugins.
```yaml
# INSECURE & FRAGILE: Default fail_open is false, VM is unbounded and unisolated
name: envoy.filters.http.wasm
typed_config:
  "@type": type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
  config:
    name: auth_routing_plugin
    # Default fail_open (false): Wasm crash causes Envoy 500 error or connection teardown
    vm_config:
      vm_id: shared_plugins_vm
      runtime: envoy.wasm.runtime.v8
      code:
        remote:
          http_uri:
            uri: https://cdn.internal.net/plugins/auth_filter.wasm
            cluster: plugin_cdn_cluster
            timeout: 5s
          sha256: 3c9b7430489cf2d5b62b08a8a48b30d306b986f7b11c75c808f97e7f6291a921
```

#### Production Standard (Correct)
> **Standard**: Explicitly sets `fail_open: true` to bypass the filter during panics, isolates the plugin to a distinct `vm_id`, constrains the HTTP download with timeouts and retries, and enforces structured runtime configurations that cap maximum heap and buffer allocations.
```yaml
# RESILIENT & FAULT-TOLERANT: Fail-open active, dedicated VM ID, and sandboxed memory boundaries
name: envoy.filters.http.wasm
typed_config:
  "@type": type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
  config:
    name: auth_routing_plugin
    fail_open: true # Prevents sidecar proxy from crashing or returning 500 on Wasm trap
    vm_config:
      vm_id: dynamic_routing_auth_v1_2
      runtime: envoy.wasm.runtime.v8
      code:
        remote:
          http_uri:
            uri: https://cdn.internal.net/plugins/auth_filter_v1.2.wasm
            cluster: plugin_cdn_cluster
            timeout: 2s
          sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
          retry_policy:
            num_retries: 3
            retry_back_off:
              base_interval: 0.1s
              max_interval: 1s
      configuration:
        "@type": type.googleapis.com/google.protobuf.StringValue
        value: '{"max_buffer_bytes": 65536, "circuit_breaker_error_threshold": 5}'
      environment_variables:
        host_env_keys: ["POD_NAME", "REGION"]
        key_values:
          MAX_WASM_HEAP_MB: "64"
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Envoy Dynamic Wasm Filter Fault Isolation and Memory Circuit Breaking Standard

Envoy Dynamic Wasm Filter Fault Isolation and Memory Circuit Breaking Standard defines an industrial-grade behavioral standard for devops engineering. Enforces strict fault isolation, resource bounding, and failure-mode configurations for dynamic WebAssembly (Wasm) HTTP filters deployed in Envoy service mesh sidecars. Prevents unhandled filter traps and guest runtime memory leaks from destabilizing the host Envoy proxy process or starving mesh data planes of critical network resources. Mandates explicit memory circuit breaker thresholds, fail-open routing safeguards, and sandboxed V8 runtime isolation. 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: Unbounded Wasm Sandboxes Without Fail-Open Protections Causing Sidecar OOM Kills 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 DriftUnbounded Wasm Sandboxes Without Fail-Open Protections Causing Sidecar OOM KillsCritical
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 configure `fail_open

Engineers MUST ALWAYS configure `fail_open: true` on `envoy.extensions.filters.http.wasm.v3.Wasm` configurations in production to allow network traffic to bypass failing filters rather than terminating requests or wedging the connection.

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 isolate dynamic Wasm modules into dedicated runtime sandboxes (e.g., `vm_id` scoped per plugin version) and NEVER reuse a shared VM ID across multiple distinct dynamic plugins.

Engineers MUST ALWAYS isolate dynamic Wasm modules into dedicated runtime sandboxes (e.g., `vm_id` scoped per plugin version) and NEVER reuse a shared VM ID across multiple distinct dynamic plugins.

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 explicitly enforce the `envoy.wasm.runtime.v8` or `envoy.wasm.runtime.wamr` memory circuit breakers via `environment_variables` or Envoy overload managers (`envoy.resource_monitors.fixed_heap`) to prevent rogue linear memory growth from causing Kubernetes cgroup OOM kills.

Engineers MUST explicitly enforce the `envoy.wasm.runtime.v8` or `envoy.wasm.runtime.wamr` memory circuit breakers via `environment_variables` or Envoy overload managers (`envoy.resource_monitors.fixed_heap`) to prevent rogue linear memory growth from causing Kubernetes cgroup OOM kills.

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 NOT buffer unbounded HTTP request or response bodies inside Wasm filter contexts

Engineers MUST NOT buffer unbounded HTTP request or response bodies inside Wasm filter contexts; streaming chunks must be inspected iteratively without holding accumulating vector buffers across filter callbacks.

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

Wasm guest code MUST implement strict boundary checks on all external headers, route metadata, and dynamic buffers before performing memory allocations or string operations to avoid trap panics.

Wasm guest code MUST implement strict boundary checks on all external headers, route metadata, and dynamic buffers before performing memory allocations or string operations to avoid trap panics.

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

CI/CD deployment pipelines MUST validate Wasm binary size, symbols, and initial linear memory requirements (e.g., maximum memory allocation pages <= 256MB) prior to pushing manifests into dynamic cluster control planes (xDS).

CI/CD deployment pipelines MUST validate Wasm binary size, symbols, and initial linear memory requirements (e.g., maximum memory allocation pages <= 256MB) prior to pushing manifests into dynamic cluster control planes (xDS).

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 Dynamic Wasm Filter Fault Isolation and Memory Circuit Breaking Standard critical for AI coding assistants?

Enforces strict fault isolation, resource bounding, and failure-mode configurations for dynamic WebAssembly (Wasm) HTTP filters deployed in Envoy service mesh sidecars. Prevents unhandled filter traps and guest runtime memory leaks from destabilizing the host Envoy proxy process or starving mesh data planes of critical network resources. Mandates explicit memory circuit breaker thresholds, fail-open routing safeguards, and sandboxed V8 runtime isolation. 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 (Unbounded Wasm Sandboxes Without Fail-Open Protections Causing Sidecar OOM Kills) 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