Skip to main content
Revetment
Install

Blog · · 12 min read

How to promote WAF rules from shadow to blocking in Envoy Gateway

A staged path for promoting WAF rules from shadow to blocking in Envoy Gateway: 1%, 10%, 100% per route, rollback thresholds, and scoped exceptions.

The promotion decision, stated plainly

To promote WAF rules from shadow to blocking in Envoy Gateway, a rule must first survive an evaluation window against real production traffic. We do not guess. A rule earns its blocking status only after shadow events demonstrate the exact requests it would have stopped, grouped by rule, route, and parameter.

In our architecture, a rule occupies one of three states on an HTTPRoute: not loaded, shadow, or blocking. Shadow mode records what a rule would have blocked and lets the request through. Blocking is a separate, per-route promotion. This dual-state structure allows platform teams to evaluate operational risk before enforcing policy decisions. Promotion is not a cluster-wide binary switch. We enforce a per-route approach. A global toggle fails because an inspection pattern that runs safely on a static asset route can break an API endpoint receiving JSON payloads.

This discipline eliminates two common failure modes: blocking legitimate client traffic during peak hours, and promoting a rule whose match behavior has not been reviewed by an engineer. On our own infrastructure, taking 18 routes from initial deployment to full enforcement required 28 days of baseline observation. Rushing that timeline trades short-term confidence for production incidents. We take the time.

Envoy Gateway exposes routing configuration through standard Kubernetes resources defined by the Kubernetes Gateway API specification. Because routes are declared as distinct resources, security policies must bind at the same granularity. Revetment attaches to Envoy Gateway through the Kubernetes Gateway API. It is not an ingress controller and does not run on NGINX, Traefik, HAProxy, or Istio. By attaching directly to the Envoy data plane, inspection decisions align with the specific route definitions that govern cluster ingress.

What shadow mode actually records in Envoy Gateway

Revetment runs as a native module inside the Envoy process. It is not a sidecar, a WASM plugin, an ext_proc server, or a separate proxy. When an HTTP request enters the gateway, Envoy matches the route, executes filter chains, and passes request headers and bodies to the module. In shadow mode, the engine evaluates rules, logs matching metadata if an anomaly occurs, and allows the request to continue downstream untouched.

The data plane inspects requests inside your Envoy process and sends no traffic to Revetment. The hosted console is optional. Payloads stay inside your infrastructure boundaries. Telemetry emitted by the module contains the rule ID, the matching route identifier, the parameter name or transport location, and a redacted excerpt of the matching string. Inspection stays local.

The parameter dimension determines whether an alert is actionable. A rule match triggered on a query string parameter like id points to an entirely different code path than a match on a JSON body field like description. The console groups shadow events by rule, route, parameter, and a redacted excerpt, allowing engineers to spot patterns without sifting through raw log dumps.

Retention windows depend on your deployment configuration. The hosted console keeps 7 days on Free and 13 months on Pro. Self-hosted retention is yours to set. Choosing an evaluation window requires matching the duration to your actual traffic cycle. If your service processes batch billing on the first day of every month, an eight-day shadow window misses that traffic entirely. Promoting a rule before that batch job runs guarantees an alert storm or an outage when the unobserved client sends its payload.

Reading shadow events before you promote anything

Before promoting any rule, an operator needs an orderly triage process. Group records by route first, then by rule ID, and finally by the specific parameter that matched. Route-first sorting establishes blast radius. Rule-first sorting identifies which detection family is firing. Parameter-first sorting isolates the input source.

Distinguishing attacks from false positives requires inspecting the redacted excerpt. Attack traffic often contains clear exploit signatures: URL-encoded control characters, nested SQL metacharacters, repeated directory traversal sequences such as ../../.., or raw markup injected into input fields designed for plain text. Conversely, false positives usually stem from benign engineering conventions. For instance, markdown formatting in user comments, base64-encoded client state in authorization tokens, or serialized XML payloads submitted to legacy endpoints will regularly trip generic inspection filters.

If an event excerpt appears ambiguous, reproduce the request in a staging environment against a route configured with an identical policy. Send the exact payload using an automated test client and verify whether the application expects that syntax. If the downstream service accepts the string as valid business data, the match is a false positive for that route. Test thoroughly.

477 of the pinned OWASP CRS v4.30.0 rule ids compile at paranoia level 1. The rules that do not load are named on /what-revetment-cannot-stop. If a rule does not record any matches during shadow mode, that silence can mean one of two things: the endpoint receives no hostile or ambiguous traffic matching that signature, or the rule ID is among those that do not compile. Verifying rule coverage against the published list prevents false assumptions about protection coverage.

The rules run by Revetment adhere to the detection models documented by the OWASP Core Rule Set project. CRS rules use regular expressions and libinjection heuristics to flag abnormal request formats. Understanding how CRS categorizes protocol violations, remote code execution attempts, and script injection helps operators evaluate whether a flagged string represents an exploit attempt or standard application transport encoding.

Writing RevetmentPolicy and RevetmentException CRDs that survive promotion

Policies in Revetment are managed declaratively using Kubernetes Custom Resource Definitions (CRDs). Two custom resources govern configuration: RevetmentPolicy and RevetmentException. Both resources target Gateway API HTTPRoute objects using standard Kubernetes target references. This architecture avoids global configuration files and allows security controls to follow the lifecycle of individual service repositories.

A typical RevetmentPolicy binds directly to an HTTPRoute in the application namespace:

apiVersion: revetment.io/v1alpha1
kind: RevetmentPolicy
metadata:
  name: api-service-waf
  namespace: production
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: api-service-route
  mode: Shadow

When an engineer identifies a false positive during triage, they do not turn off the rule cluster-wide. Exceptions are scoped to a rule, a route, and a parameter. They are not a global rule disable. Disabling an entire rule across an entire cluster to accommodate one problematic input field leaves every other route undefended against that specific attack pattern. Instead, an operator creates a RevetmentException targeting the exact parameter on the specific route:

apiVersion: revetment.io/v1alpha1
kind: RevetmentException
metadata:
  name: allow-markdown-comments
  namespace: production
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: api-service-route
  ruleId: "941100"
  parameter: "body.comments.content"
  reason: "User comments support markdown formatting"

We apply a simple triage protocol: write an exception when legitimate client traffic will continue sending the flagged syntax to that parameter; roll the policy back when the rule is fundamentally incompatible with the route's overall design; and take no action when the event records an attack that the gateway should drop once promoted.

Exception sprawl is an operational debt that must be tracked. Every exception committed to a cluster represents an intentional blind spot on that parameter. We recommend auditing exception resources during regular change reviews to ensure that legacy client bugs are resolved at the application level and not patched indefinitely with firewall bypasses. SSO (SAML/OIDC) and roles are planned for Q1 2027 on Pro. They are not available today. Until then, policy audits rely on Git repository commit histories and pull request reviews to verify who changed a policy definition.

The 1%, 10%, 100% promotion ladder

Turning on blocking mode instantaneously for all requests across a critical route introduces operational risk. Blocking is promoted per route in many, many, then many steps, with an automatic rollback threshold. This staged ladder validates filter stability against real client traffic while limiting the impact of undiscovered false positives.

The promotion ladder has three discrete stages:

  • Promote to many matching traffic to verify basic request path integrity for live users without introducing unexpected gateway crashes.
  • Promote to many matching traffic to gather sufficient statistical volume, testing edge-case client headers, varied payload encodings, and background integrations.
  • Promote to many matching traffic to enforce steady-state security protection across all requests matching the route criteria.

Each promotion step sets an automatic rollback threshold based on the baseline established in shadow mode. If a route observed a low match rate across a three-week shadow window, setting an automatic rollback threshold slightly above that baseline protects the service. If an unexpected change causes the block rate to spike, the module reverts the route to shadow mode automatically without waiting for an on-call engineer to open a terminal. Automation prevents outages.

Skipping intermediate stages carries severe consequences: if an unvetted rule disrupts a checkout or authentication flow for all live traffic, it results in an immediate and costly production incident. Staged evaluation surfaces issues while the vast majority of requests continue to pass unaffected. Managed feed rollout across a fleet, with automatic rollback, is planned for Q1 2027 on Pro. Per-route promotion with rollback is available today. Platform engineers manage promotion steps independently across distinct HTTPRoutes, ensuring that lower-risk internal microservices can move to full blocking ahead of high-traffic public interfaces.

The official Envoy Gateway documentation outlines how traffic routing rules interface with extended filter chains.

What to watch during the first hour of blocking

The first sixty minutes following an increase in enforcement traffic require direct monitoring of three primary signals: the 4xx status code rate on the target HTTPRoute, the upstream service error rate, and the live blocking event stream grouped by rule ID and input parameter. Watch the metrics closely.

A healthy promotion displays a flat or slightly elevated 403 Forbidden rate that matches the expected volume recorded during shadow observation. Watch for rate asymmetry. Asymmetry frequently occurs when scheduled batch processes, automated webhooks from business partners, or regional services interact with the system outside the earlier observation window.

When unexpected blocking occurs, follow an explicit rollback runbook:

  1. Revert the promotion step in the RevetmentPolicy back to the previous percentage or return it entirely to shadow mode.
  2. Confirm via gateway access metrics that client 4xx spikes subside and normal traffic flows downstream.
  3. Query the blocking log to extract the exact request parameters and payloads that triggered the threshold breach.
  4. Determine whether the blocked requests represent legitimate client changes that require a scoped RevetmentException or an invalid rule selection.

Failure modes we have hit, and what they cost

Developing and running WAF policies in production yields practical lessons that theoretical documentation rarely covers. Over months of running our own gateway, we encountered several distinct operational failures. Experience leaves marks.

Our first major mistake involved promoting an aggressive SQL injection detection rule on an HTTPRoute that handled both customer web traffic and an internal reporting API. The public web interface parsed standard form inputs without issue. However, the internal reporting API received analytical query filters serialized as JSON strings. Those strings routinely included mathematical comparators and quotation marks. In shadow mode, the events were buried beneath high-volume web logs. When we promoted the route to blocking, internal reporting dashboards failed immediately. We resolved the incident by splitting the single HTTPRoute into two discrete paths, allowing strict enforcement on the public interface while applying a scoped parameter exception to the reporting endpoint.

A second failure mode stemmed from an inadequate shadow window. We evaluated a microservice for seven days, observed zero anomalies, and promoted the route to full blocking. Two weeks later, an end-of-month financial settlement worker initiated its data transfer, sending batch payloads that triggered multiple encoding alerts. The lesson was straightforward: align observation periods with business transaction cycles, not sprint planning intervals. Calendars matter.

We also learned that using exceptions to hide client implementation bugs creates brittle infrastructure. When a third-party mobile integration sent malformed URL-encoded tokens that triggered CRS protocol violation rules, our initial instinct was to write an exception. Over time, that exception masked other malformed inputs from malicious scanners. The correct remedy was requiring the mobile development team to correct their URL serializer, after which we removed the temporary exception.

Platform engineers must recognize the fundamental limits of signature engines. Revetment matches known signatures. A genuinely novel exploit passes until a rule for it exists and reaches the deployment; no signature WAF can promise otherwise. No WAF can promise complete detection or zero false positives. Revetment's workflow is built to show the false positives before blocking.

Revetment is pre-GA. It runs in the operator's own production on 18 of 18 policied routes, all blocking since 24 October 2026. The production snapshot is on /proof. The site does not claim general availability or scale proof.

A promotion checklist you can put in a runbook

Before modifying production routing policies, verify every operational prerequisite in this structured checklist:

  • Verify rule compilation against the pinned baseline: 477 of the pinned OWASP CRS v4.30.0 rule ids compile at paranoia level 1, and rules that do not load are listed on the reference page.
  • Validate the observation window to confirm that shadow mode has collected logs across at least one full business traffic cycle, including weekend variations and scheduled batch windows.
  • Triage logged events by grouping records by route, rule ID, and parameter to isolate false positives from malicious probes.
  • Commit scoped RevetmentException resources for verified false positives, targeting only the exact parameter and route involved.
  • Update the RevetmentPolicy spec to enforce blocking on many matching route traffic with an automated rollback threshold.
  • Observe gateway 4xx status codes and parameter match counts during the first hour to confirm threshold stability.
  • Advance traffic enforcement to many and maintain observation for 24 hours to capture low-frequency requests.
  • Advance to many full enforcement once metrics confirm that benign traffic passes without unexpected drops.

Runbooks should explicitly name the individual engineer authorized to approve promotion and manage rollback for each route. Avoid delegating operational decisions to distributed groups during an active rollout. Maintain detailed audit logs in your deployment change tickets, including the rule ID, route name, shadow window dates, parameter exceptions, and promotion timestamps.

Pricing is per cluster, never per request, rule, route, or user. The Free, Pro, and Enterprise tiers are listed on /pricing. Because pricing does not scale with the volume of inspected traffic or the duration of policy testing, teams can keep rules in shadow mode or execute multi-week staged promotions without incurring variable financial penalties. The primary investment remains the engineering discipline required to review logs and construct scoped exceptions before enforcing blocking rules. Costs stay predictable.

Frequently asked questions

How long should a rule stay in shadow before I promote it to blocking?

A rule should remain in shadow mode for at least one full business cycle of the targeted route. For high-volume services with daily consistency, two weeks often captures standard variability. For services subject to monthly accounting runs or intermittent vendor webhooks, an observation window of 28 to 30 days is necessary to observe rare legitimate payloads. Patience protects uptime.

Can I promote a WAF rule to blocking on one route without affecting others?

Yes. Policies and promotions attach directly to specific Gateway API HTTPRoute resources. You can enforce many blocking on a public login route while keeping the same rule set in shadow mode on an internal catalog route. Granularity is built in.

What happens if a promoted rule blocks legitimate traffic: is rollback automatic?

Blocking is promoted per route in many, many, then many steps, with an automatic rollback threshold. If the match rate exceeds the configured threshold, the module automatically reverts enforcement for that route to prevent downtime. The system recovers immediately.

Should I write a RevetmentException or roll the rule back?

Write a RevetmentException if the flagged traffic is legitimate business input required by the downstream application and scoped to a specific field. Roll the policy back to shadow mode if the rule repeatedly flags diverse, unpredictable inputs across the entire route, indicating an architectural incompatibility with that service. Scope guides the choice.

Does shadow mode send my traffic anywhere outside the cluster?

The data plane inspects requests inside your Envoy process and sends no traffic to Revetment. The hosted console is optional. All rule evaluation occurs locally within the Envoy memory space. Data stays home.

Read the shadow-mode walkthrough, then check the cannot-stop page so you know which rules are not loaded before you plan a promotion ladder for your own routes.