fix(networking): Add absolute FQDNs (trailing dot) to VirtualHost domains#56008
fix(networking): Add absolute FQDNs (trailing dot) to VirtualHost domains#56008istio-testing merged 5 commits intoistio:masterfrom
Conversation
…ains **Description:** This PR fixes an issue where Istio's outbound route configuration (`RouteConfiguration`) did not include the absolute/fully qualified domain name (FQDN) variant (e.g., `my-service.my-ns.svc.cluster.local.`) in the `domains` list for `VirtualHost` entries. Updated the TestGenerateVirtualHostDomains test to verify new functionality **Problem:** When clients make requests using the absolute FQDN (with the trailing dot) in the `Host` header, Envoy would fail to match this against the specific `VirtualHost` domains generated by Istio. This caused such requests to fall back to the wildcard (`*`) virtual host, typically resulting in routing to the `PassthroughCluster` or `BlackHoleCluster` instead of the intended service cluster and associated Istio policies (like VirtualServices, DestinationRules). Example scenario from issue report: - `curl http://foo.bar.svc.cluster.local/` -> Correctly matches `outbound|80||foo.bar.svc.cluster.local` - `curl http://foo.bar.svc.cluster.local./` -> Incorrectly matches `PassthroughCluster` **Solution:** The `generateVirtualHostDomains` function in `pilot/pkg/networking/core/route.go` has been modified to explicitly add the absolute FQDN variant (`hostname + "."`) to the list of generated domains for each service hostname and alias, provided the name is not an IP address.
|
😊 Welcome @ankushagarwal! This is either your first contribution to the Istio istio repo, or it's been You can learn more about the Istio working groups, Code of Conduct, and contribution guidelines Thanks for contributing! Courtesy of your friendly welcome wagon. |
|
Hi @ankushagarwal. Thanks for your PR. I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
Looks like this is certainly legal according to the RFC: https://www.rfc-editor.org/rfc/rfc3986#section-3.2.2. I'm curious why we haven't allowed this in the past; I'll let @ramaraochavali @hzxuzhonghu or @howardjohn explain this fence for me :) |
howardjohn
left a comment
There was a problem hiding this comment.
This makes sense to me. I cannot think of what this would break but I suppose its possible there is some edge case not considered... may be best put an on-by-default feature flag around this just in case?
| for _, s := range all { | ||
| // Check if 's' is an IP address. We don't add trailing dots to IPs. | ||
| isIP := net.ParseIP(s) != nil | ||
| // Add the absolute FQDN variant (with trailing dot) if it's not an IP address. |
There was a problem hiding this comment.
nit: does this make sense under GenerateAltVirtualHosts since its basically an alt host?
There was a problem hiding this comment.
I think it makes sense to move there
|
LGTM. Add feature flag with default true |
|
Thank you for the feedback @ramaraochavali and @howardjohn - moved to GenerateAltVirtualHosts and added a default true feature flag - |
sridhargaddam
left a comment
There was a problem hiding this comment.
Please add a release note.
pilot/pkg/features/pilot.go
Outdated
| "If set to true, Istio will add the absolute FQDN variant (e.g., my-service.my-ns.svc.cluster.local.) "+ | ||
| "to the domains list for VirtualHost entries. Defaults to true, enabling the addition.", |
There was a problem hiding this comment.
Since the default value is true, lets modify the description to...
| "If set to true, Istio will add the absolute FQDN variant (e.g., my-service.my-ns.svc.cluster.local.) "+ | |
| "to the domains list for VirtualHost entries. Defaults to true, enabling the addition.", | |
| "If set to false, Istio will not add the absolute FQDN variant (e.g., my-service.my-ns.svc.cluster.local.) to the domains list for VirtualHost entries.", |
|
@ankushagarwal: The following test failed, say
DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
Added release notes, fixed lint, updated the description of the flag |
sridhargaddam
left a comment
There was a problem hiding this comment.
Thank you @ankushagarwal
…ains (istio#56008) * fix(networking): Add absolute FQDNs (trailing dot) to VirtualHost domains **Description:** This PR fixes an issue where Istio's outbound route configuration (`RouteConfiguration`) did not include the absolute/fully qualified domain name (FQDN) variant (e.g., `my-service.my-ns.svc.cluster.local.`) in the `domains` list for `VirtualHost` entries. Updated the TestGenerateVirtualHostDomains test to verify new functionality **Problem:** When clients make requests using the absolute FQDN (with the trailing dot) in the `Host` header, Envoy would fail to match this against the specific `VirtualHost` domains generated by Istio. This caused such requests to fall back to the wildcard (`*`) virtual host, typically resulting in routing to the `PassthroughCluster` or `BlackHoleCluster` instead of the intended service cluster and associated Istio policies (like VirtualServices, DestinationRules). Example scenario from issue report: - `curl http://foo.bar.svc.cluster.local/` -> Correctly matches `outbound|80||foo.bar.svc.cluster.local` - `curl http://foo.bar.svc.cluster.local./` -> Incorrectly matches `PassthroughCluster` **Solution:** The `generateVirtualHostDomains` function in `pilot/pkg/networking/core/route.go` has been modified to explicitly add the absolute FQDN variant (`hostname + "."`) to the list of generated domains for each service hostname and alias, provided the name is not an IP address. * Move the fqdn dot suffix logic to GenerateAltVirtualHosts, reorder test expected results * Add PILOT_ENABLE_ABSOLUTE_FQDN_VHOST_DOMAIN feature flag * Update tests * [release-notes] Add release note, fix lint
* upstream/master: remove 1.23 compatibility profile (istio#56023) Create ambient multinetwork flag (istio#55991) krt: make krt and kube client indexes named (istio#55999) Automator: update proxy@master in istio/istio@master (istio#56026) fix istio-revision-tag-default MutatingWebhookConfigurations is not created during installation (istio#56004) doc: fix typo in accesslog test (istio#55117) fix(networking): Add absolute FQDNs (trailing dot) to VirtualHost domains (istio#56008)
…12644) ## Summary `matchHostName` in `RoutingUtils` and `XdsNameResolver` currently rejects hostnames and patterns with a trailing dot (`.`) via `checkArgument`. A trailing dot denotes a **Fully Qualified Domain Name (FQDN)** as defined in [RFC 1034 Section 3.1](https://www.rfc-editor.org/rfc/rfc1034#section-3.1), and is a valid, well-defined representation of an absolute domain name. Rejecting it is inconsistent with the RFC. This change removes the trailing-dot rejection and adds normalization to strip the trailing dot before matching, making `example.com.` and `example.com` match equivalently. ## Background Per [RFC 1034 Section 3.1](https://www.rfc-editor.org/rfc/rfc1034#section-3.1): > "If the name ends with a dot, it is an absolute name ... For example, `poneria.ISI.EDU.`" A trailing dot simply indicates that the name is rooted at the DNS root and is semantically equivalent to the same name without the trailing dot. Treating it as invalid prevents legitimate FQDNs from being used as hostnames or virtual host domain patterns in xDS routing configuration. ## Motivation This was discovered when using gRPC Proxyless Service Mesh on a Kubernetes cluster with Istio. The issue surfaced after upgrading Istio from 1.26.8 to 1.28.3. The Istio change [istio/istio#56008](istio/istio#56008) began sending FQDN-style domain names (with trailing dots) in xDS route configuration, which caused grpc-java to throw an `IllegalArgumentException` in `matchHostName`: ```text java.lang.IllegalArgumentException: Invalid pattern/domain name at com.google.common.base.Preconditions.checkArgument(Preconditions.java:143) ``` The root cause is that grpc-java's `matchHostName` was not RFC-compliant in rejecting trailing dots — the Istio upgrade merely made it visible. The fix here is to bring grpc-java into compliance with RFC 1034, independent of any specific Istio version. ## Changes - `xds/src/main/java/io/grpc/xds/RoutingUtils.java`: Removed trailing-dot rejection and added FQDN normalization in `matchHostName`. - `xds/src/main/java/io/grpc/xds/XdsNameResolver.java`: Same as above. - `xds/src/test/java/io/grpc/xds/XdsNameResolverTest.java`: Added `matchHostName_trailingDot` test covering exact match, prefix wildcard, and suffix wildcard with trailing dot combinations. ## References - [RFC 1034 – Domain Names: Concepts and Facilities](https://www.rfc-editor.org/rfc/rfc1034) - [RFC 1035 – Domain Names: Implementation and Specification](https://www.rfc-editor.org/rfc/rfc1035) - [istio/istio#56008](istio/istio#56008) – Istio change that began sending FQDN domain names in xDS configuration
…rpc#12644) ## Summary `matchHostName` in `RoutingUtils` and `XdsNameResolver` currently rejects hostnames and patterns with a trailing dot (`.`) via `checkArgument`. A trailing dot denotes a **Fully Qualified Domain Name (FQDN)** as defined in [RFC 1034 Section 3.1](https://www.rfc-editor.org/rfc/rfc1034#section-3.1), and is a valid, well-defined representation of an absolute domain name. Rejecting it is inconsistent with the RFC. This change removes the trailing-dot rejection and adds normalization to strip the trailing dot before matching, making `example.com.` and `example.com` match equivalently. ## Background Per [RFC 1034 Section 3.1](https://www.rfc-editor.org/rfc/rfc1034#section-3.1): > "If the name ends with a dot, it is an absolute name ... For example, `poneria.ISI.EDU.`" A trailing dot simply indicates that the name is rooted at the DNS root and is semantically equivalent to the same name without the trailing dot. Treating it as invalid prevents legitimate FQDNs from being used as hostnames or virtual host domain patterns in xDS routing configuration. ## Motivation This was discovered when using gRPC Proxyless Service Mesh on a Kubernetes cluster with Istio. The issue surfaced after upgrading Istio from 1.26.8 to 1.28.3. The Istio change [istio/istio#56008](istio/istio#56008) began sending FQDN-style domain names (with trailing dots) in xDS route configuration, which caused grpc-java to throw an `IllegalArgumentException` in `matchHostName`: ```text java.lang.IllegalArgumentException: Invalid pattern/domain name at com.google.common.base.Preconditions.checkArgument(Preconditions.java:143) ``` The root cause is that grpc-java's `matchHostName` was not RFC-compliant in rejecting trailing dots — the Istio upgrade merely made it visible. The fix here is to bring grpc-java into compliance with RFC 1034, independent of any specific Istio version. ## Changes - `xds/src/main/java/io/grpc/xds/RoutingUtils.java`: Removed trailing-dot rejection and added FQDN normalization in `matchHostName`. - `xds/src/main/java/io/grpc/xds/XdsNameResolver.java`: Same as above. - `xds/src/test/java/io/grpc/xds/XdsNameResolverTest.java`: Added `matchHostName_trailingDot` test covering exact match, prefix wildcard, and suffix wildcard with trailing dot combinations. ## References - [RFC 1034 – Domain Names: Concepts and Facilities](https://www.rfc-editor.org/rfc/rfc1034) - [RFC 1035 – Domain Names: Implementation and Specification](https://www.rfc-editor.org/rfc/rfc1035) - [istio/istio#56008](istio/istio#56008) – Istio change that began sending FQDN domain names in xDS configuration
…rpc#12644) ## Summary `matchHostName` in `RoutingUtils` and `XdsNameResolver` currently rejects hostnames and patterns with a trailing dot (`.`) via `checkArgument`. A trailing dot denotes a **Fully Qualified Domain Name (FQDN)** as defined in [RFC 1034 Section 3.1](https://www.rfc-editor.org/rfc/rfc1034#section-3.1), and is a valid, well-defined representation of an absolute domain name. Rejecting it is inconsistent with the RFC. This change removes the trailing-dot rejection and adds normalization to strip the trailing dot before matching, making `example.com.` and `example.com` match equivalently. ## Background Per [RFC 1034 Section 3.1](https://www.rfc-editor.org/rfc/rfc1034#section-3.1): > "If the name ends with a dot, it is an absolute name ... For example, `poneria.ISI.EDU.`" A trailing dot simply indicates that the name is rooted at the DNS root and is semantically equivalent to the same name without the trailing dot. Treating it as invalid prevents legitimate FQDNs from being used as hostnames or virtual host domain patterns in xDS routing configuration. ## Motivation This was discovered when using gRPC Proxyless Service Mesh on a Kubernetes cluster with Istio. The issue surfaced after upgrading Istio from 1.26.8 to 1.28.3. The Istio change [istio/istio#56008](istio/istio#56008) began sending FQDN-style domain names (with trailing dots) in xDS route configuration, which caused grpc-java to throw an `IllegalArgumentException` in `matchHostName`: ```text java.lang.IllegalArgumentException: Invalid pattern/domain name at com.google.common.base.Preconditions.checkArgument(Preconditions.java:143) ``` The root cause is that grpc-java's `matchHostName` was not RFC-compliant in rejecting trailing dots — the Istio upgrade merely made it visible. The fix here is to bring grpc-java into compliance with RFC 1034, independent of any specific Istio version. ## Changes - `xds/src/main/java/io/grpc/xds/RoutingUtils.java`: Removed trailing-dot rejection and added FQDN normalization in `matchHostName`. - `xds/src/main/java/io/grpc/xds/XdsNameResolver.java`: Same as above. - `xds/src/test/java/io/grpc/xds/XdsNameResolverTest.java`: Added `matchHostName_trailingDot` test covering exact match, prefix wildcard, and suffix wildcard with trailing dot combinations. ## References - [RFC 1034 – Domain Names: Concepts and Facilities](https://www.rfc-editor.org/rfc/rfc1034) - [RFC 1035 – Domain Names: Implementation and Specification](https://www.rfc-editor.org/rfc/rfc1035) - [istio/istio#56008](istio/istio#56008) – Istio change that began sending FQDN domain names in xDS configuration
Description:
This PR fixes an issue where Istio's outbound route configuration (
RouteConfiguration) did not include the absolute/fully qualified domain name (FQDN) variant (e.g.,my-service.my-ns.svc.cluster.local.) in thedomainslist forVirtualHostentries.Updated the TestGenerateVirtualHostDomains test to verify new functionality
Problem:
When clients make requests using the absolute FQDN (with the trailing dot) in the
Hostheader, Envoy would fail to match this against the specificVirtualHostdomains generated by Istio. This caused such requests to fall back to the wildcard (*) virtual host, typically resulting in routing to thePassthroughClusterorBlackHoleClusterinstead of the intended service cluster and associated Istio policies (like VirtualServices, DestinationRules).Example scenario from issue report:
curl http://foo.bar.svc.cluster.local/-> Correctly matchesoutbound|80||foo.bar.svc.cluster.localcurl http://foo.bar.svc.cluster.local./-> Incorrectly matchesPassthroughClusterSolution:
The
generateVirtualHostDomainsfunction inpilot/pkg/networking/core/route.gohas been modified to explicitly add the absolute FQDN variant (hostname + ".") to the list of generated domains for each service hostname and alias, provided the name is not an IP address.Fixes #56007