Normalize SRV target host names to lower case during SRV polling

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Unknown
    • 3.11.2
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Dotnet Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      During SRV polling, DnsMonitor compares returned host names against the parent domain case-sensitively. An SRV record whose target data uses mixed case is silently dropped from the topology.

      DNS names are case-insensitive (RFC 4343), and the SDAM specification requires host name normalization under Hostnames are normalized to lower-case.

      Root cause

      The initial seedlist path and the polling path reach the same comparison by different routes, and only one of them normalizes case.

      Initial discovery — ConnectionString.ValidateResolvedHosts parses each resolved host through EndPointHelper.TryParse (ConnectionString.cs:1492), which lower-cases (EndPointHelper.cs:203). The seed side was lower-cased by the same call during connection string parsing (ConnectionString.cs:792). Both operands are folded, so the ordinal comparison in HasValidParentDomain (ConnectionString.cs:1519, :1525) is correct.

      Polling — DnsMonitor.GetValidEndPoints (DnsMonitor.cs:130-155) takes srvRecord.EndPoint straight from the resolver and strips the trailing dot by hand, never going through EndPointHelper. It then calls ConnectionString.HasValidParentDomain(lookupDomainName, endPoint) via IsValidHost (DnsMonitor.cs:159). _lookupDomainName _was lower-cased — it comes from ClusterSettings.EndPoints (MultiServerCluster.cs:143, LoadBalancedCluster.cs:190). So a raw, possibly mixed-case target is compared ordinally against a lower-cased anchor.

      Impact

      A returned host such as Mongodb1.Example.Com fails the parent domain check and is excluded from the topology. It fails quietly: per the SRV polling spec, a verification failure MUST NOT raise an error, so the only signal is the SdamInformationEvent logged at DnsMonitor.cs:150 ("Invalid host returned by DNS SRV lookup"). The result is a silently smaller topology after a polling refresh.

      Severity is limited by how uncommon mixed-case SRV target data is in practice.

      Suggested fix

      Normalize the host in GetValidEndPoints before validation — either lower-case it alongside the existing trailing-dot strip, or route it through EndPointHelper.TryParse as the seedlist path does. The latter keeps a single normalization point for both paths.

      Notes

      Pre-existing; not introduced by DRIVERS-3329 / CSHARP-6077 work. Found while reviewing the srvAllowedHostsSuffix spec PR (mongodb/specifications#1950), which adds an explicit normalization requirement for returned host names to the Initial DNS Seedlist Discovery spec.

      No spec test covers this: the build.10gen.cc fixtures only return lower-case targets. DEVPROD-42090 tracks adding a mixed-case SRV record for DNS tests.

            Assignee:
            Adelin Mbida Owona
            Reporter:
            Adelin Mbida Owona
            None
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: