Skip to content

Conversation

@PetitBaguette
Copy link
Contributor

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, 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:

"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 began sending FQDN-style domain
names (with trailing dots) in xDS route configuration, which caused grpc-java to throw an
IllegalArgumentException in matchHostName:

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

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 4, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@kannanjgithub
Copy link
Contributor

Please sign the EasyCLA to be able to contribute to the repo.

@PetitBaguette
Copy link
Contributor Author

@kannanjgithub Thank you for the instructions. I have signed the CLA.

@@ -354,15 +354,24 @@ private void updateResolutionResult(XdsConfig xdsConfig) {
*/
@VisibleForTesting
static boolean matchHostName(String hostName, String pattern) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is actually unused now for some time. Can you remove it and its calling tests? Instead make unit tests for RoutingUtils which is the actively used code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have applied the requested changes.

All CI checks have passed, with the exception of grpc-java-testing-pr (grpc-testing), which indicates that it needs a /gcbrun command from a collaborator.

Please let me know if there are any other points I should address.

@kannanjgithub kannanjgithub added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Feb 5, 2026
@grpc-kokoro grpc-kokoro removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Feb 5, 2026
@kannanjgithub kannanjgithub added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Feb 5, 2026
@kannanjgithub
Copy link
Contributor

/gcb

@grpc-kokoro grpc-kokoro removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Feb 5, 2026
@kannanjgithub
Copy link
Contributor

/gcbrun

@PetitBaguette
Copy link
Contributor Author

@kannanjgithub Thank you for running the command. I noticed that all CI checks have passed now. Is there anything else I need to do to get this merged?

@kannanjgithub kannanjgithub merged commit 0ef1b39 into grpc:master Feb 9, 2026
17 checks passed
@PetitBaguette PetitBaguette deleted the fix/xds_fqdn branch February 9, 2026 12:08
jdcormie pushed a commit to jdcormie/grpc-java that referenced this pull request Feb 11, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants