Skip to content

Gateway API: allowedRoutes is incorrectly applied to all listeners when sectionName is omitted #42159

Closed

Description

@czepiec

Is there an existing issue for this?

  • I have searched the existing issues

Version

equal or higher than v1.18.2 and lower than v1.19.0

What happened?

The Cilium Gateway API controller incorrectly validates an HTTPRoute against only one listener defined in a Gateway when the HTTPRoute does not specify a sectionName.

The allowedRoutes rules of one (sometimes first, see bellow) listener are used to validate the attachment, and this result seems to be applied to all other listeners, ignoring their individual rules. For example, if one listener has a restrictive policy (from: Same) and a subsequent listener has a permissive policy (from: All), a cross-namespace HTTPRoute is incorrectly attached also to the restrictive listener.

This can lead to unintended traffic routing and a violation of the configured security posture. Specifying the sectionName in the HTTPRoute for each intended listener works as a successful workaround, as the controller then correctly applies the rules of the specified listener.

How can we reproduce the issue?

  1. Prerequisites: A Kubernetes cluster with Cilium v1.18.2 and the Gateway API CRDs installed.
  2. HTTPRoute in default namespace:
    kind: HTTPRoute
    apiVersion: gateway.networking.k8s.io/v1
    metadata:
      name: httproute
      namespace: default
    spec:
      parentRefs:
      - namespace: kube-system
        name: gateway
        # sectionName is intentionally omitted to trigger the bug
  3. (A) If Gateway in kube-system (another) namespace has one listener with from: All and another from: Same, HTTPRoute is attached to both listeners:
    apiVersion: gateway.networking.k8s.io/v1
    kind: Gateway
    metadata:
      name: gateway
      namespace: kube-system
    spec:
      gatewayClassName: cilium
      listeners:
      # Listener 1 (First): Restrictive policy
      - name: http-restrictive
        port: 80
        protocol: HTTP
        allowedRoutes:
          namespaces:
            from: Same # Should only allow routes from 'kube-system' ns
      # Listener 2 (Second): Permissive policy
      - name: http-permisive
        port: 8080
        protocol: HTTP
        allowedRoutes:
          namespaces:
            from: All
  4. (B) If Gateway in kube-system (another) namespace has first listener restricted to kube-system namespace by selector and second listener with from: All, HTTPRoute is not attached to either listener:
    apiVersion: gateway.networking.k8s.io/v1
    kind: Gateway
    metadata:
      name: gateway
      namespace: kube-system
    spec:
      gatewayClassName: cilium
      listeners:
      # Listener 1 (First): Restrictive policy
      - name: http-restrictive
        port: 80
        protocol: HTTP
        allowedRoutes:
          namespaces:
            from: Selector  # Should only allow routes from 'kube-system' ns
            selector:
              matchLabels:
                kubernetes.io/metadata.name: kube-system
      # Listener 2 (Second): Permissive policy
      - name: http-permisive
        port: 8080
        protocol: HTTP
        allowedRoutes:
          namespaces:
            from: All
  5. (C) If Gateway in kube-system (another) namespace has just changed order to first listener with from: All and second listener restricted to kube-system namespace by selector, HTTPRoute is attached to both listeners:
    apiVersion: gateway.networking.k8s.io/v1
    kind: Gateway
    metadata:
      name: gateway
      namespace: kube-system
    spec:
      gatewayClassName: cilium
      listeners:
      # Listener 2 (First): Permissive policy
      - name: http-permisive
        port: 8080
        protocol: HTTP
        allowedRoutes:
          namespaces:
            from: All
      # Listener 1 (Second): Restrictive policy
      - name: http-restrictive
        port: 80
        protocol: HTTP
        allowedRoutes:
          namespaces:
            from: Selector  # Should only allow routes from 'kube-system' ns
            selector:
              matchLabels:
                kubernetes.io/metadata.name: kube-system

Cilium Version

Client: 1.18.2 5bd307a 2025-09-16T09:06:09+00:00 go version go1.24.7 linux/amd64
Daemon: 1.18.2 5bd307a 2025-09-16T09:06:09+00:00 go version go1.24.7 linux/amd64

Kernel Version

Linux mimi-01 6.12.48-talos #1 SMP Wed Sep 24 12:34:42 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Kubernetes Version

Client Version: v1.33.3
Kustomize Version: v5.6.0
Server Version: v1.34.0

Regression

No response

Sysdump

No response

Relevant log output

Anything else?

No response

Cilium Users Document

  • Are you a user of Cilium? Please add yourself to the Users doc

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    kind/bugThis is a bug in the Cilium logic.
    needs/triageThis issue requires triaging to establish severity and affected area.
    kind/community-reportThis was reported by a user in the Cilium community, eg via Slack.
    on Oct 13, 2025
  2. youngnick commented on Dec 2, 2025

    @youngnick
    Contributor

    Thanks @czepiec, this is definitely a bug and will be investigated.

  3. github-actions commented on Feb 1, 2026

    @github-actions

    This issue has been automatically marked as stale because it has not
    had recent activity. It will be closed if no further activity occurs.

  4. added
    staleThe stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale.
    on Feb 1, 2026
  5. github-actions commented on Feb 15, 2026

    @github-actions

    This issue has not seen any activity since it was marked stale.
    Closing.

  6. removed
    staleThe stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale.
    on Feb 21, 2026
  7. github-actions commented on Apr 22, 2026

    @github-actions

    This issue has been automatically marked as stale because it has not
    had recent activity. It will be closed if no further activity occurs.

  8. added
    staleThe stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale.
    on Apr 22, 2026
  9. added a commit that references this issue on Apr 27, 2026
    d4fab94
  10. 15 remaining items

  11. added a commit that references this issue on Jul 15, 2026
    184e94c
  12. added a commit that references this issue on Jul 16, 2026
    54aa8fc
  13. added a commit that references this issue on Sep 25, 2026
    6409ac1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentCilium agent related.feature/k8s-gateway-apikind/bugThis is a bug in the Cilium logic.kind/community-reportThis was reported by a user in the Cilium community, eg via Slack.needs/triageThis issue requires triaging to establish severity and affected area.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions