Repository navigation
Description
Description:
Since v1.9.0 (#9430), the jwt_authn requirement name is built from a hash of the requirement content (<providers>-or-missing_<hash>). Editing a JWT SecurityPolicy changes the provider config. For example, it might add an audience, change the JWKS, or change claimToHeaders. The change renames the requirement in two places together:
- the key in the listener's
requirement_map(LDS) - the
requirement_namein every route's per-route config (RDS)
Envoy applies the LDS and RDS updates separately. Downstream connections that are already open keep the old filter chain, with the old requirement_map, until the listener drains them. The new route config applies to them right away. The next request on each existing connection therefore asks for a requirement name that its filter chain does not hold, and Envoy rejects it:
403 jwt_authn_access_denied{Wrong_requirement_name:_example-or-missing_9e8a003bead59055._It_should_be_one_of_[example-or-missing_9824bfd54cd267ca]}
With optional: true, requests without a token are rejected too, so the impact is not limited to JWT clients.
This looks like #8313, but the cause differs. #8313 is about a requirement name being added: delivering LDS before RDS is a safe order, so it was closed as eventual consistency. Here the name is replaced, so no delivery order is safe:
- new routes + old listener: the route asks for the new name, and the old map does not hold it
- old routes + new listener: the route asks for the old name, and the new map no longer holds it
Both directions show up in the access log below.
Before v1.9.0, the requirement was named after the route, so a policy edit did not change it.
Expected: editing a SecurityPolicy does not reject requests. Connections still on the old filter chain should be evaluated with the old policy.
Repro steps:
-
Install v1.9.2 and the quickstart on kind:
helm install eg oci://docker.io/envoyproxy/gateway-helm --version v1.9.2 -n envoy-gateway-system --create-namespace --wait kubectl apply -f https://github.com/envoyproxy/gateway/releases/download/v1.9.2/quickstart.yaml
-
Apply a JWT SecurityPolicy on the Gateway.
optional: trueand an inline JWKS are used here only so that the repro needs no token and no external fetch:apiVersion: gateway.envoyproxy.io/v1alpha1 kind: SecurityPolicy metadata: name: jwt-gw spec: targetRefs: - group: gateway.networking.k8s.io kind: Gateway name: eg jwt: optional: true providers: - name: example audiences: [aud-a] localJWKS: type: Inline inline: | <contents of examples/kubernetes/jwt/jwks.json>
-
From a pod inside the cluster, send steady traffic over N keep-alive connections to the Envoy service (Host
www.example.com, path/). I used 8 HTTP/1.1 connections at 10 req/s each. -
While the traffic runs, edit the policy every 20 s:
kubectl patch securitypolicy jwt-gw --type=json -p '[{"op":"add","path":"/spec/jwt/providers/0/audiences/-","value":"aud-b"}]' # 20 s later kubectl patch securitypolicy jwt-gw --type=json -p '[{"op":"remove","path":"/spec/jwt/providers/0/audiences/1"}]'
The rename shows without a cluster too. Run egctl x translate --from gateway-api --to xds -t all on the same input before and after adding one audience:
| before | after | |
|---|---|---|
| provider (LDS) | example_d021055cb0c610d0 |
example_86815370e6ee1cbc |
requirement_map key (LDS) |
example-or-missing_9824bfd54cd267ca |
example-or-missing_9e8a003bead59055 |
route requirement_name (RDS) |
example-or-missing_9824bfd54cd267ca |
example-or-missing_9e8a003bead59055 |
Environment:
- Envoy Gateway v1.9.2 (helm chart), default EnvoyProxy settings
- The naming code is unchanged on
main(1873acf):jwtRequirementNameininternal/xds/translator/jwt.go - kind, single node
Logs:
Access log of one rejected request. 16 rejections had each direction of the mismatch:
{"response_code":403,"response_code_details":"jwt_authn_access_denied{Wrong_requirement_name:_example-or-missing_9e8a003bead59055._It_should_be_one_of_[example-or-missing_9824bfd54cd267ca]}","route_name":"httproute/default/foo/rule/0/match/0/www_example_com","protocol":"HTTP/1.1","start_time":"2026-10-15T08:44:44.602Z"}
Activity
kkk777-7 commentedon Oct 15, 2026
Results:
Each run lasted 100 s and included 4 policy edits.
Possible fix:
Make the requirement name independent of the provider content, but do not go back to per-route names. Per-route names would bring back the listener churn that #9103 fixed.
One option is to name the requirement after the SecurityPolicy that owns the providers, as
<namespace>/<name>[:missing|:missing-or-failed]. For a merged policy, the owner is whichever policy supplied theproviderslist. Provider names keep their content hash. Only the requirement's innerprovider_namerefers to them, and that reference lives inside the same LDS resource.With that naming:
requirement_mapentry. The RDSrequirement_namestays the same, so old and new filter chains both hold the name the route asks for.I tried this change as a patch on v1.9.2. With the same repro, it rejected 0 of 7,816 requests (8 connections) and 0 of 31,232 (32 connections). The listener still drains on each edit, as expected.
FedeBev commentedon Oct 25, 2026
We hit this in production on v1.9.0; three data points that may help.
1. HTTP/2 and HTTP/3 too. One apply added an issuer to
providerson our gateway-, listener- and route-level JWT SecurityPolicies (they share one provider list). 16 connections opened before the apply sent a request after it. Within the log window we inspected, 15 of them logged exactly one 403 each, asking for the new requirement name against the old map (HTTP/1.1 7, HTTP/2 2, HTTP/3 6), and each 403 was the last request started on that connection. The 16th's only logged request after the apply, in that window, was a CORS preflight (answered before jwt_authn); it logged no 403. We only saw that direction (route config ahead of the connection's filter chain).2. A JWKS key change renames too. In a minimal fixture — a gateway-level JWT policy with
localJWKS.type: ValueRef, plus a route policy (StrategicMerge) marking one routeoptional: true— adding one key to the ConfigMap renamed the provider and both requirements that reference it (egctl x translate, v1.9.0): providerexample_5c58573eade5ec5b→example_1d4cc6f089987357; requiredexample_9e29a489ca9f2446→example_889ae4de86ea3745; optionalexample-or-missing_91088b04bef35f9d→example-or-missing_92bb7feabcdf058a. The hash covers the JWKS bytes: pretty-printing the same JWKS renamed them too (required →example_bbccbd5f83e3650a). In the same fixture a CORS-only change left every provider and requirement name unchanged.3. Impact. 9 of the 15 refusals hit devices that poll over mTLS (
optional: trueon their route) and keep the connection open between polls; off-peak scheduling does not prevent this on connections that stay open and keep sending requests. Two of our POS terminals locked on that single 403 (our client's bug, since fixed).+1 to naming the requirement after the policy that supplies
providers. Two tests seem worth pinning: with the owning policy and its optional/failOpen mode unchanged, a provider or JWKS edit leaves every route'srequirement_nameunchanged; and two different requirements in onerequirement_mapnever share a name (a duplicate key is overwritten silently on insert). One trade worth stating in the PR (reasoned from the drain settings, not measured): with stable names, a connection still draining after a provider change keeps validating against the old providers until it closes. A connection that remains idle serves no further requests; HTTP/1.1 may serve at most one more request; HTTP/2/3 may serve streams opened during the GOAWAY grace, while already-open streams may persist until force-close. With v1.9.0 defaults that is about 60 s from when the new listener config activates, not from the apply; a stalled or NACKed update has no bound.@kkk777-7 would you open the PR with your patch in time for v1.10.0-rc.1, and is a
release-1.9cherry-pick possible? We are glad to test it against our shapes (ValueRef JWKS,optionalandfailOpenroute exemptions with StrategicMerge, several HTTPS listeners plus HTTP/3).kkk777-7 commentedon Oct 26, 2026
/assign