Skip to content

Route hostname policy admits a TLSRoute that declares no hostnames #3467

Description

The CEL in packages/system/cozystack-basics/templates/route-hostname-policy.yaml short-circuits on absence:

!has(object.spec.hostnames) || object.spec.hostnames.all(h, h == ... || h.endsWith("." + ...))

A route that does not set spec.hostnames satisfies the first operand, so it is admitted without a single hostname being checked. The policy exists to keep a tenant's routes inside its own apex, and the one shape it never inspects is the shape that names no hostname at all.

That shape is not inert under Gateway API. A TLSRoute with no spec.hostnames is not a route matching nothing; it inherits the hostnames of the listener it attaches to. The route then covers whatever that listener covers, which is exactly the boundary this policy is written to hold.

The fix I would land is to require the field to be present and non-empty before validating it:

has(object.spec.hostnames) && size(object.spec.hostnames) > 0 && object.spec.hostnames.all(h, ...)

Both policies rendered from that template share the same $celValidator string, so HTTPRoute and TLSRoute pick the change up together.

On radius: the policy only matches namespaces whose name starts with tenant-. The three first-party TLSRoutes the platform ships, kubernetes-api in default plus cdi-uploadproxy and vm-exportproxy, all declare hostnames explicitly and none of them sits in a tenant-* namespace, so they are not matched today and nothing about them changes.

One rollout note. The fix turns a currently-admitted shape into a rejected one, so before it lands it is worth checking that no chart a tenant can install emits a TLSRoute with an absent or empty hostname list.

Related but not duplicates: #3205 hardens the same family of hostname policies with case-insensitive comparison, and #3252 covers whether this group of policies should be always-on.

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug
    security/mediumMedium severity security finding
    area/networkingIssues or PRs related to networking (ingress, gateway, vpn, metallb, kube-ovn)
    on Jul 27, 2026
  2. lexfrei commented on Sep 23, 2026

    @lexfrei
    ContributorAuthor

    Fixed by #3475: the policy requires a non-empty spec.hostnames for HTTPRoute, TLSRoute and GRPCRoute.

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/networkingIssues or PRs related to networking (ingress, gateway, vpn, metallb, kube-ovn)kind/bugCategorizes issue or PR as related to a bugsecurity/fixedFix releasedsecurity/mediumMedium severity security findingtriage/not-reproducibleIndicates an issue can not be reproduced as described

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions