How to use shadow mode to test WAF rules in Envoy Gateway
Envoy Gateway WAF shadow mode records what a rule would block and lets the request through. Here is how to read those events and promote a route safely.
Envoy Gateway WAF shadow mode evaluates incoming requests against web application firewall rules, records what would have been blocked, and forwards the unaltered request to your upstream service. Traffic passes without disruption. It gives platform and security engineers a reliable way to validate WAF rules before blocking production traffic without causing unexpected client outages. When running Envoy Gateway on Kubernetes, configuring a dry run mode inside the proxy path prevents legitimate business traffic from breaking when you turn on defensive signatures. Shadow mode reveals real payload anomalies.
What shadow mode actually does in the request path
In standard blocking operation, an inline web application firewall inspects the stream of headers, query parameters, and body bytes. If an inspection engine scores a payload above a defined disruption threshold, it halts execution, drops the connection or emits an HTTP 403 Forbidden status code, and increments an error metric. Shadow mode works differently. In Envoy Gateway WAF shadow mode, that evaluation pipeline executes identically, but the final verdict is decoupled from request routing.
The module evaluates the configured rule set, records the matched rule identifier along with target metadata, and lets the request continue to the upstream backend. The transaction finishes as if no rule matched. The upstream backend notices nothing. Observability systems capture the exact condition that triggered the engine.
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. Because the engine runs directly inside Envoy's execution thread, the evaluation happens at the exact point in the filter chain where blocking will eventually occur. There are no external network calls, serialized gRPC hops, or out-of-process protocol buffers involved in passing the request to the evaluation engine.
This in-process architecture contrasts with offline log replay or asynchronous traffic mirroring. Offline log replayers inspect requests after the fact, usually reconstructed from access logs or mirrored streams. Those replayed packets miss the mutations, path normalizations, header sanitizations, and routing rewrites executed by upstream Envoy filters. As documented in the Envoy Gateway concepts architecture guide, the data plane manages traffic extensions directly through an integrated filter pipeline. An external dry run tool cannot see the precise bytes that Envoy's active worker thread handles.
Shadow mode provides concrete evidence of rule matches, but it cannot make operational judgements for your team. It tells you what a rule would have matched, not whether blocking that request is safe for your business. Determining whether a match is a true exploit attempt, a benign integration bug, or a malformed internal client call remains an engineering decision. Shadow mode records what a rule would have blocked and lets the request through. Blocking is a separate, per-route promotion.
Why Envoy Gateway WAF shadow mode beats a staging cluster
Engineering teams frequently attempt WAF dry run mode testing in pre-production or staging environments. Staging environments rarely replicate the variety and oddity of real production traffic. Legitimate client calls that trigger web application firewall rules tend to be edge cases: a legacy mobile application using non-standard character encoding, a partner integration sending unescaped XML in a query parameter, or a monitoring probe with custom authorization tokens. Staging misses these edges.
Synthetic integration suites pass cleanly because developers write them to conform to API specifications. Real users, automated client libraries, and browser variants regularly deviate from those specifications.
Running in shadow mode on production routes introduces a clear operational trade-off. Your cluster carries the CPU evaluation cost on every request while you observe traffic. Your team must actively triage the recorded events. You cannot simply wait for a single metric dashboard to report zero blocks before flipping a switch.
Understanding your rule coverage is essential before interpreting shadow events. Revetment runs the OWASP Core Rule Set (CRS). Specifically, 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. Shadow mode highlights which of those 477 compiled rules match against your actual production traffic. As explained in the OWASP CRS anomaly scoring guide, rules contribute individual scores toward an aggregate threshold, making it critical to inspect which individual signatures trigger before enforcing hard blocks on a live route.
Attaching a policy to an HTTPRoute without changing behaviour
In Kubernetes environments using the Gateway API, configuration is driven declaratively by custom resources. As detailed in the Kubernetes custom resources documentation, CRDs allow platforms to introduce structured APIs that integrate with standard cluster tooling and GitOps controllers.
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. RevetmentPolicy is a Kubernetes CRD that targets HTTPRoutes through the Gateway API. It allows you to place a specific route into shadow mode while leaving upstream delivery unchanged. The following manifest illustrates how a route is targeted for passive evaluation:
apiVersion: revetment.io/v1alpha1
kind: RevetmentPolicy
metadata:
name: api-orders-shadow
namespace: production
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: api-orders-route
mode: Shadow
paranoiaLevel: 1
When this policy attaches to the targeted HTTPRoute, Envoy Gateway reconfigures its filter chain to process the native inspection engine. No request is rejected, aborted, or delayed with an error code while the policy is set to shadow mode. Upstream services receive identical payloads, headers, and timings as they did before the manifest was applied.
Revetment is not open source. The Helm chart and the four images are Apache-2.0 and public on registry.revetment.io; the source repository is private. To run this configuration, you need a functional deployment of Envoy Gateway alongside those artifacts. The installation manifests and platform prerequisites vary depending on your underlying cloud infrastructure. Consult the installation guides before deploying; each install guide states its own validation status.
When applying policies, watch for two common operational pitfalls:
- Filter order conflicts and hostname mismatches: if an HTTPRoute defines hostnames or path matches that diverge from your active traffic routing rules, or if conflicting filter policies take precedence, the WAF filter may process unintended traffic paths or fail to attach altogether.
- Assuming cluster-wide coverage: a RevetmentPolicy does not automatically apply to every route serviced by the gateway. It strictly binds to the specific HTTPRoutes declared in its
targetReffield. Unreferenced routes remain uninspected.
Reading shadow events: rule, route, parameter, excerpt
Shadow mode generates actionable telemetry when requests match inspection signatures. The Revetment console groups shadow events along four specific dimensions:
- Rule identifier: the exact CRS rule number (such as 942100 for SQL injection heuristics) that triggered the match.
- Route: the specific HTTPRoute resource and URI path where the transaction took place.
- Parameter: the exact request component containing the matching payload, such as a query parameter key, request header name, or JSON field path.
- Redacted excerpt: a normalized, truncated snippet of the string that triggered the rule, sanitized of sensitive session values.
Isolating the parameter is critical for reliable engineering triage. A signature match on a search input field (for example, q=SELECT) represents a vastly different operational risk than that same signature firing on a session token inside an Authorization header or a base64-encoded cookie. Knowing the exact key and location prevents engineers from misdiagnosing client behaviour.
Redaction ensures that operational triage does not introduce credential leaks. The engine replaces detected session keys, passwords, and authorization tokens with deterministic redaction markers before persisting event data. Excerpts remain safe for review. You can paste the excerpt into an issue tracker or share it during an engineering review without exposing customer data.
We recommend a systematic triage loop for new shadow events:
- Group the events by HTTPRoute to isolate blast radius.
- Sort the route's events by rule identifier to see which CRS checks match most frequently.
- Drill into the parameter field for each rule cluster to identify the offending payload key.
- Classify the cluster into one of three buckets: true positive (actual malicious probe), false positive (valid application logic triggering a rigid signature), or ambiguous (unsupported or malformed client usage requiring application review).
Your team must plan observation windows around data retention limits. The console is hosted or self-hosted. Accounts are operator-invited, not self-serve, and there is no free trial; the Free tier is a product tier. Pricing is per cluster, never per request, rule, route, or user. The hosted console keeps 7 days on Free and 13 months on Pro. Self-hosted retention is yours to set. On Free, finish your triage before the 7 days elapse. Full tier details are documented on the Revetment pricing page.
From an architectural perspective, the data plane inspects requests inside your Envoy process and sends no traffic to Revetment. The hosted console is optional. Telemetry emitted for console visualization contains only metadata and redacted excerpts, allowing your primary application payloads to stay strictly between Envoy and your backends.
Writing exceptions that stay scoped
When triage identifies a false positive, do not disable the offending CRS rule across your entire infrastructure. Disabling a rule globally turns off protection for every API endpoint, re-exposing your backends to the very vulnerabilities the rule was designed to detect.
RevetmentException is a Kubernetes CRD that provides fine-grained tuning. Exceptions are scoped to a rule, a route, and a parameter. They are not a global rule disable. The manifest below demonstrates an exception scoped to a single JSON field on an orders endpoint:
apiVersion: revetment.io/v1alpha1
kind: RevetmentException
metadata:
name: allow-json-metadata-sql-signature
namespace: production
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: api-orders-route
ruleId: 942100
location: BodyJson
parameter: "metadata.notes"
rationale: "Internal dispatch system submits formatted notes containing SQL-like syntax."
This exception instructs the engine inside Envoy to bypass rule 942100 only when inspecting the metadata.notes field inside a JSON request body destined for api-orders-route. If an attacker passes a SQL injection string within a query parameter, header, or a different JSON key on that same route, rule 942100 executes and records the match normally.
When evaluating matches, follow a clear decision tree:
- True positive: leave the rule intact. The shadow event proves the rule is working as intended against malicious or probing traffic.
- False positive on a specific input: write a tightly scoped RevetmentException targeting that specific rule, route, and parameter.
- False positive across the entire route or application: evaluate whether the rule fundamentally conflicts with your application architecture. If you must disable a rule entirely for a route, document the exact structural reason within your engineering issue tracker.
Detailed guidance on managing false positives without degrading posture can be found in the OWASP CRS false positives and tuning guide. Always populate the rationale field in your custom resources. Because RevetmentException objects live in your GitOps repositories alongside standard Kubernetes manifests, including a clear explanation ensures future maintainers understand why an exception was granted long after the original incident is resolved.
Promoting a route from shadow to blocking in three steps
Moving from observation to active enforcement should not be a binary, cluster-wide switch. A premature transition can drop mission-critical traffic if an unobserved client workflow suddenly appears. Blocking is promoted per route in many, many, then many steps, with an automatic rollback threshold.
When you initiate a promotion step, the native engine enforces blocking on only the assigned percentage of matching traffic. The remaining percentage continues running in shadow mode. If the engine detects that the volume of blocked requests on that route exceeds your configured rollback threshold over an evaluation window, the data plane automatically reverts enforcement to shadow mode without waiting for human intervention.
Before advancing a route through canary stages, complete this operational pre-flight checklist:
- Observation window: verify the route has remained in shadow mode across a full business traffic cycle (typically seven full days to capture weekend and weekday variations).
- Exception review: confirm all known false positives have corresponding, committed RevetmentException resources applied in the cluster.
- Telemetry confirmation: ensure shadow event rates have stabilized to predictable background noise or known scanner activity.
- Named owner: assign an active on-call engineer to monitor edge error rates during each step of the promotion window.
Managing promotion per route prevents noisy, high-complexity endpoints from holding back the rest of your system. A static asset route or simple microservice API can advance to many blocking quickly, while complex, legacy partner endpoints remain in shadow mode until their false-positive exceptions are fully mapped.
We followed this exact operational path within our own infrastructure. 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 only named deployment is the operator's own production; Revetment does not publish customer logos, named users, or case studies. You can read the chronological operational log of how our own gateways transitioned in the article on 28 days from shadow to blocking.
Failure modes we have hit, and what they look like
Operating an in-process WAF inside Envoy Gateway has revealed several non-obvious failure modes that every platform engineer should anticipate:
First, client encoding variations can create unexpected signature matches. During internal testing, an iOS client library sent UTF-8 characters with non-standard byte sequences inside a custom tracking header. Desktop web browsers did not emit this header format. Because the mobile client ran only in production, synthetic testing did not trigger the match. Shadow mode exposed rule 920270 (Invalid Character in Request) firing exclusively on that specific client version, allowing us to patch the client library before any connection was dropped.
Second, internal microservice communication can trigger injection signatures. In one case, an internal automation service pushed automated diagnostic reports containing raw JSON payloads with keys like table_name and values containing SQL syntax. Rule 942100 flagged every submission as a SQL injection attack. Had the route been deployed in blocking mode from day one, internal task queues would have stalled immediately. Because we had shadow telemetry, we implemented a parameter-scoped RevetmentException targeting that specific JSON attribute on that internal route.
Third, promotion can move faster than organizational review. Early in our development, we advanced a route to many blocking before an updated mobile application build had finished rolling out across third-party app stores. The older client versions continued submitting legacy payload formats. The automated rollback threshold tripped within four minutes, reverting the route to shadow mode before our support queues were flooded with client authentication errors.
Telemetry triage requires patience. Early on, we treated shadow events as an aggregate count rather than a grouped structure. We saw 10,000 matches over two days and assumed the entire Core Rule Set was incompatible with our API schema. When we grouped the data by rule, route, and parameter, we discovered that a single rule accounted for 9,850 of those matches on a single parameter. Writing one scoped exception eliminated most of the noise, leaving a manageable set of true events to analyze.
It is equally important to understand the boundary conditions of signature inspection. 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. Shadow mode reveals where your traffic collides with defined rule definitions, but it cannot predict an attack vector that lacks a signature.
What shadow mode will not tell you
While shadow mode is an indispensable tool for Envoy Gateway security testing, it has structural limitations that you must account for in your platform design:
Shadow mode will not tell you whether an incoming request was malicious. It tells you only that a byte sequence satisfied a regular expression or an anomaly heuristic. A developer debugging an API using curl commands may trigger multiple rules, while a targeted, slow-and-low attack payload might carefully evade low paranoia-level heuristics. Evaluating intent remains an engineering responsibility.
Shadow mode will not cover rules that failed to load into memory. As noted earlier, 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 an attack vector targets a vulnerability covered only by a rule that failed compilation, shadow mode will show zero events for that vector.
Shadow mode does not produce performance profiling figures. Revetment publishes no latency or throughput benchmark; describe the mechanism and the rule coverage instead of a performance number. Do not plan a canary promotion around an unmeasured latency assumption; test your own application profiles under realistic load in your own clusters.
Revetment is an L7 WAF. It does not absorb DDoS traffic, filter network-layer threats, protect DNS, or act as a scrubbing network; use an edge CDN or DDoS service for that. Furthermore, Revetment does not implement rate limiting, slowloris protection, HTTP/2 rapid-reset budgets, or concurrency limits. Those network defences belong at your edge layer or in standard Envoy rate-limiting filters.
Revetment does not sell bot management, device fingerprinting, account-takeover protection, or credential-stuffing protection.
Frequently asked questions
What happens when a request matches a rule in shadow mode?
In shadow mode, the engine evaluates the request headers, parameters, and payload against the compiled Core Rule Set. If a rule triggers, the engine records the event metadata, including the rule identifier, route, parameter, and a redacted excerpt. It then allows the request to proceed to the upstream service without alteration or delay.
Can a RevetmentPolicy be applied to the whole cluster at once?
No. A RevetmentPolicy binds explicitly to individual HTTPRoutes via the Gateway API targetRef field. Routes that are not referenced in a policy manifest remain uninspected. This allows platform teams to evaluate rules on specific paths without modifying traffic handling across the rest of the gateway.
How do you tune out false positives during shadow evaluation?
You define a RevetmentException custom resource. Exceptions are scoped to a specific rule ID, HTTPRoute, and parameter path, such as a query key or JSON body attribute. The engine bypasses evaluation for that exact parameter on that route, leaving the rule active for all other inputs and routes.
How does promotion from shadow mode to blocking operate?
Blocking is promoted per route in many, many, then many steps, with an automatic rollback threshold. During canary stages, the configured percentage of traffic undergoes enforcement while the rest remains in shadow mode. If the rate of blocked requests crosses your rollback limit, enforcement automatically reverts to shadow mode.
Does Revetment send raw request payloads to a hosted cloud service?
The data plane inspects requests inside your Envoy process and sends no traffic to Revetment. The hosted console is optional. When telemetry is forwarded to the console, it contains only the matched rule ID, route identifier, parameter name, and a redacted snippet with sensitive credentials removed.