Skip to content

JWT Authentication Error on first request saying wrong requirement name #8313

Closed

Description

@tname9962

Description:

When i create a new pod , with its route and associated security policy with jwt authentication on and try to connect instantly, it sometimes gives this error, but after sometime, on trying to connect again, it works

'Failed JWT authentication: Wrong requirement_name: httproute/ns1/efghi/rule/0/match/0/test_domain_com. It should be one of [httproute/abcd/dd/rule/0/match/0/test_domain_com,httproute/abcd/nw-test/rule/0/match/0/test_domain_com,httproute/grafana/grafana-route/rule/0/match/0/test_domain_com,httproute/proj1-container-image-builder/proj1-cib-route/rule/0/match/0/test_domain_com,httproute/proj1/proj1-route/rule/0/match/0/test_domain_com,httproute/ns1/abcde/rule/0/match/0/test_domain_com,httproute/ns1/another-xyzd/rule/0/match/0/test_domain_com]

Repro steps:

Here is the securitypolicy and httproute config i am using,

kind: SecurityPolicy
metadata:
  labels:
    app.kubernetes.io/name: efghi
  name: efghi
spec:
  authorization:
    defaultAction: Deny
    rules:
    - action: Allow
      name: allow
      principal:
        jwt:
          claims:
          - name: email
            valueType: String
            values:
            - [email protected]
          provider: jwt_provider
  jwt:
    providers:
    - audiences:
      - djsadkasjdnkasndlkasndjb
      extractFrom:
        cookies:
        - token
      issuer: https://jwt-provider.provider.com
      name: jwt_provider
      remoteJWKS:
        uri: https://jwt-provider.provider.com/.well-known/jwks.json
  targetRefs:
  - group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: efghi
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  generation: 1
  labels:
    app.kubernetes.io/name: efghi
  name: efghi
spec:
  hostnames:
  - test.domain.com
  parentRefs:
  - group: gateway.networking.k8s.io
    kind: Gateway
    name: eg-gateway
    namespace: eg
  rules:
  - backendRefs:
    - group: ""
      kind: Service
      name: efghi
      port: 3333
      weight: 1
    matches:
    - path:
        type: PathPrefix
        value: /pathsvc```


*Environment*:
> I used helm to install envoy gateway in eks, and used this chart gateway-helm-v1.5.5

Activity

  1. arkodg commented on Feb 22, 2026

    @arkodg
    Contributor
  2. added
    kind/bug
    on Feb 22, 2026
  3. added this to the v1.8.0-rc.1 Release milestone on Feb 22, 2026
  4. github-actions commented on Mar 24, 2026

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had activity in the last 30 days.

  5. tname9962 commented on Apr 1, 2026

    @tname9962
    Author

    Is their any update on this ?

  6. added
    help wanted
    and removed on Apr 1, 2026
  7. self-assigned this
    on Apr 6, 2026
  8. removed
    help wanted
    on Apr 6, 2026
  9. rudrakhp commented on Apr 6, 2026

    @rudrakhp
    Member

    Based on the current XDS mechanism, this issue is because envoy receives LDS and RDS updates independently, so it can sometimes see the JWT filter but not the corresponding route updates yet. Here is an explanation of this race using an example:

    State before: JWT filter has RequirementMap = {routeA: req},
                  RouteConfig has one route (routeA), requirement_name = routeA
    
    New snapshot created with:
      LDS: JWT filter RequirementMap = {routeA: req, routeB: req}
      RDS: RouteConfig has routeA + new routeB, requirement_name = routeB
    
    Timeline A (no race — safe):
      1. Envoy receives new LDS → JWT filter updated, RequirementMap now includes routeB
      2. Envoy receives new RDS → new route routeB is active
      3. Request arrives → JWT filter finds routeB in RequirementMap 
    
    Timeline B (race — failure):
      1. Envoy receives new RDS → new route routeB is active immediately
      2. Request arrives → JWT filter looks up routeB in RequirementMap → NOT FOUND
         → "Wrong requirement_name: routeB. It should be one of [routeA, ...]" 
      3. Envoy receives new LDS → JWT filter updated, RequirementMap now includes routeB
      4. Next requests succeed 
    

    I don't think there is anything to solve for here since EG takes time to converge and guarantees eventual consistency only. @tname9962 how long does it take after this error shows up first before requests start succeeding again, in case there is room for improving convergence time here.

  10. tname9962 commented on Apr 6, 2026

    @tname9962
    Author

    Based on the current XDS mechanism, this issue is because envoy receives LDS and RDS updates independently, so it can sometimes see the JWT filter but not the corresponding route updates yet. Here is an explanation of this race using an example:

    State before: JWT filter has RequirementMap = {routeA: req},
                  RouteConfig has one route (routeA), requirement_name = routeA
    
    New snapshot created with:
      LDS: JWT filter RequirementMap = {routeA: req, routeB: req}
      RDS: RouteConfig has routeA + new routeB, requirement_name = routeB
    
    Timeline A (no race — safe):
      1. Envoy receives new LDS → JWT filter updated, RequirementMap now includes routeB
      2. Envoy receives new RDS → new route routeB is active
      3. Request arrives → JWT filter finds routeB in RequirementMap 
    
    Timeline B (race — failure):
      1. Envoy receives new RDS → new route routeB is active immediately
      2. Request arrives → JWT filter looks up routeB in RequirementMap → NOT FOUND
         → "Wrong requirement_name: routeB. It should be one of [routeA, ...]" 
      3. Envoy receives new LDS → JWT filter updated, RequirementMap now includes routeB
      4. Next requests succeed 
    

    I don't think there is anything to solve for here since EG takes time to converge and guarantees eventual consistency only. @tname9962 how long does it take after this error shows up first before requests start succeeding again, in case there is room for improving convergence time here.

    It varies greatly, sometimes working working perfectly in under 2-3 seconds to sometimes having to wait for 30-40 seconds.

    If i can get a max limit for convergence time that should be helpful.

    Also does this time scale based on the number of routes and security policies ?

  11. rudrakhp commented on Apr 6, 2026

    @rudrakhp
    Member

    There is no upper bound for this convergence time as it scales with the number of routes and listeners. You could reduce probability of these specific errors by updating/creating the routes first, wait for them to be accessible, and then the JWT policies referring them to avoid this race condition.

  12. rudrakhp commented on Apr 30, 2026

    @rudrakhp
    Member

    Closing this as there is no immediate/planned action to be taken for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugtriage

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions