Multicast DNS conflict resolution using the Time Since Received (TSR) EDNS option
Ted Lemon
Apple Inc.
One Apple Park Way
Cupertino
California
95014
USA
mellon@fugue.com
秦良
Leonqin0101@gmail.com
4 March 2024
Internet
Internet Engineering Task Force
This document specifies a new conflict resolution mechanism for DNS, for use in cases where the advertisement is being proxied, rather than advertised directly, e.g. when using a combined DNS-SD Advertising Proxy and SRP registrar. A new EDNS option is defined that communicates the time at which the set of resource records on a particular DNS owner name was most recently updated.
Introduction
Unlike the Domain Name System [RFC1034], with its authority servers and delegation of authority, Multicast DNS has no single source of authority. Because of this, mDNS has a mechanism, conflict resolution (Section 9 of [RFC6762]) for detecting and fixing conflicts in mDNS advertisements.
The current goal of mDNS conflict resolution is to prevent a new service being advertised from taking the place of an existing service with the same name that is already being advertised. This goal, however, assumes that the entity advertising an mDNS service is in fact authoritative for that service. In the case of an Advertising Proxy [I-D.sctl-advertising-proxy], this is not the case: the source of truth for the service being advertised is an SRP [I-D.ietf-dnssd-srp] client.
On a link with more than one SRP registrar, an SRP client may register with one SRP registrar, and then subsequently update its registration on a different SRP registrar. Both SRP registrars may be acting as advertising proxies. If so, the original server may still be advertising the old SRP registration using mDNS. If the information in the new SRP registration is identical to that in the old registration, this is not a problem. However if some information has changed (e.g., a new IP address has been added, or a TXT record updated), then the new registration will be seen to be in conflict with the old registration.
In the case of such a supposed conflict, the current behavior of mDNS is for the older (stale) registration to win, and the newer (current) information to be discarded. This behavior, which is entirely correct for services that are advertising on their own behalf, is exactly wrong when a service registration is being proxied.
Current Behavior
When a new service is to be advertised, the server that wishes to advertise its service typically registers the service with a central mDNS registrar on the host on which it is running. This mDNS registrar may have an internal database of services already registered, and may detect a conflict with one of those services. This can be true whether the conflicting database entry is data for which the mDNS registrar is authoritative, or data it has received via mDNS and cached.
In the case of such a conflict, no network transaction is required: the mDNS registrar detects it locally. It addresses the conflict in one of two ways. The first alternative is that the mDNS registrar will report the conflict to the server as an error, which the server must fix. Alternatively, the server may have indicated that the mDNS mDNS registrar should automatically choose a new name for it, in which case the mDNS registrar does so automatically, without notifying the server.
Once any locally-detectable conflicts have been resolved, the mDNS registrar probes (see Section 8.1 of [RFC6762]) local network to see if any other host has already registered a service the conflicts with the proposed new service. If such a service is present on the network, the mDNS registrar follows the same process previously described, either reporting the error to the server or automatically choosing a new name.
The effect of this approach is that generally whichever server first registers a service under a particular name wins. If a server comes along later and registers the same service with conflicting information, the newcomer’s information is rejected.
Problem Statement
The current behavior works well for services registering on their own behalf. However, for example in the case of an SRP registrar, it works poorly: an SRP registrar acting as an advertising proxy proxies the contents of its registration dataset(s) using mDNS. The source of truth for information in such datasets is whatever service has registered with the SRP registrar, not the SRP registrar itself.
In the case of an advertising proxy proxying an SRP dataset, what we want is not the oldest information, but the newest. When the SRP client is able to continue registering with the same SRP registrar, this works well: stale data is automatically removed and replaced with current data. However, if more than one SRP registrar is available, and for some reason the original SRP registrar with which the registration was completed is still operating but no longer reachable (e.g., in the case of a network partition), the SRP client will wind up registering with a different SRP registrar. Similarly, if the SRP service is being advertised using an anycast address, there is no guarantee that the SRP renewal will be delivered to the same SRP registrar.
When the SRP client registers with a different SRP registrar, the behavior we get with the current conflict resolution approach is that the SRP client will be given a new name, and both the old (stale) advertisement (A) and the new (more recent) advertisement (A’) will be discoverable as separate services.
This creates a new burden on consumers of such services: they need to parse through the whole list of services of their type, using metadata from the TXT record in the service instance data, if possible, to determine that service A and service A’ are the same service. If no such information is present in the TXT record, the only way to determine that one of these two registrations is stale is to attempt to use the advertised service, which may no longer be reachable if, for example, the change that produced the conflict was an IP address change. When the SRP lease for the stale service expires, that service's advertisement will be removed, and the service will no longer be discoverable under the original name, even if the IP address hasn't changed.
This document proposes an enhancement to the current conflict resolution algorithm for mDNS, which allows an mDNS proxy to report the time at which it received the registration it is newly advertising. This is done using a new Time Since Received RR, which is attached to the name of the registration.
Time Since Received EDNS Option
The Time Since Received (TSR) EDNS option references a specific RR in the answer, authority or additional sections of an mDNS message. This option specific to an owner name, not to an individual RRset. When a service registration is successful, the mDNS registrar records the wall clock time at which the registration request was received. This may be the current time, or a time specified by a proxy service that is doing the registration. This time is only recorded if the service requesting the registration specifies it; otherwise, the time of receipt is not recorded. The registrar also has the public key that was used in the registration.
The TSR EDNS option consists of three fields: the RR offset (two byte integer in network byte order), a key hash (32 bytes), and a time offset (four bytes).
The RR offset points to the first name in a given section of the mDNS Message for which the TSR is in effect. The first answer is at offset 0, the second answer at offset 1 and so on. Or if there is only one answer but also an authority record, the first authority record is at offset 2. If following that record there is a record in the additional section (including the OPT RR itself), that record would be at offset 3. Questions can't have TSRs associated with them, and hence the counting starts with the first answer, not the first question.
If there are multiple records in the mDNS Message with the same owner name, only one TSR option is emitted for that name, and it applies to every RR in the mDNS Message with that owner name. It is not possible in the SRP protocol for two updates at two different times to contain records that apply to the same name.
The second field, the key hash, is an SHA-256 hash (TBD) of the public key that was used to authenticate the SRP update that most recently updated the RRs on the owner name to which the TSR option applies.
The TSR time offset field contains the difference, in seconds, between the the time at which the TSR record is being generated and the time of receipt for recorded for that owner name. If this difference is greater than seven days (7 * 24 * 60 * 60), the mDNS registrar MUST use a value of seven days rather than the larger value.
mDNS Registrar Behavior
When sending an mDNS message
When constructing an mDNS message, the mDNS registrar includes one TSR option for each unique owner name for any RR added to the mDNS message for which the mDNS registrar is authoritative and which was registered using SRP.
When processing an mDNS message
When an mDNS registrar receives an mDNS message query, it processes it as usual, unless it discovers a conflict. When data in the mDNS message conflicts with data in the mDNS querier's authority database, as described in Section 8.1 of [RFC6762], this is considered to be a conflict.
When a conflict detected for which a TSR record in the mDNS message is applicable, and the local record was also registered using SRP, the registrar checks to see if the key hashes match. If they do not, then the conflict is processed as usual. If either the mDNS record or the local authoritative record does not contain TSR information, the conflict is processed as usual.
When both versions of the data have TSR records, and the key hashes match, if the record in the mDNS response is more recent, the local authoritative data is discarded from the authority dtheatabase and the SRP registrar function is notified that that data is stale.
If, however, the version of the data received in the mDNS response is less recent than the authoritative data, the registrar ignores the data in the mDNS response.
mDNS querier behavior when processing an mDNS message
As with with the mDNS registrar case, when an mDNS querier receives an mDNS Message, it compares TSR information in the local cache with the TSR information in the message. If TSR information is present in both locations, and the data in the mDNS message is more recent, the information in the cache is replaced with the information in the mDNS message. Otherwise, the information in the mDNS message is ignored.
Note that some mDNS registrars only answer internal queries out of cache, and populate their cache using information they receive both from their own mDNS announcements and answers and from information received in responses sent by other mDNS registrars. In addition to the behavior described for mDNS registrars, such mDNS registrars MUST also implement the behavior described here for queriers with respect to cache updates.
The effect of network latency on time computations
Because TSR computations are affected by network latency, comparisons can’t be considered accurate. It is therefore necessary to tolerate some amount of error. In practice, however, it should generally not be the case that two advertising proxies receive SRP updates from the same SRP client at nearly the same time. So it should always be the case either that there is a clear ordering to the timestamps, or that there is no conflict in the data. For example with anycast, a retransmission could go to a different SRP registrar, but in this case both servers would simultaneously receive identical data, so the close ordering or even equality of the timestamps should not affect the outcome.
Internal Handling of TSR data
The TSR option that is sent on the wire is expressed in seconds relative to the time of receipt of the registration. In order to derive the time to send in a TSR option, the registrar must remember the time at which the registration occurred. This time is recorded as an absolute time, not a relative time. We refer to this as the time of receipt. When constructing a TSR option, the registrar computes the difference between the current time and the time of receipt, which must always be in the past. This difference, which should be a positive integer, is converted to seconds, and that unsigned value is then used to synthesize the TSR RR.
Timeliness of Conflict Resolution
It is expected that if a conflict exists, it will be recent, and will be resolved quickly. Different hosts may be able to record shorter or longer time differences. However, because of this expectation of recentness, mDNS registrars should never need to report a TSR of longer than seven days. It’s reasonable to expect that every mDNS implementation should be able to remember time intervals of at least seven days.
Legacy Behavior
y mDNS registrars and queriers that do not support the TSR option are expected to ignore the option, so they will behave as if no TSR option was sent. This may result in such registrars temporarily caching stale data. However, in the normal course of processing, more recent data will win. In cases where it does not, the Reconfirm process which is part of [RFC6762] already works to clear stale data: since we expect SRP servers to implement TSR, by the time a Reconfirm is attempted, all authoritative stale data should have been cleared.
When to Use TSR
TSR is only relevant for mDNS proxies. Regular (non-proxy) mDNS registrants are not expected to use it, since it will produce the wrong behavior for this use case. An mDNS registrant that is a proxy MUST explicitly request that a TSR be used for conflict resolution. mDNS registrars MUST NOT record a time of receipt unless the registrant has specifically requested it.
Registrant API considerations
When an mDNS proxy registers a service and requests the use of a time of receipt, the proxy MUST specify when it received the registration. In order to support this, the API is required not only to allow the registrant to specify that TSR conflict resolution is wanted, but must also provide a way for the proxy to specify an absolute time at which the registration was received.
This is important, for example, in the case of SRP Replication [I-D.lemon-srp-replication], where an SRP registrar may receive a registration from a peer during startup synchronization. This registration will have occurred at some significant amount of time in the past, and so it would be incorrect for the mDNS proxy receiving the registration to use the time that the mDNS proxy registers the service as the time of receipt.
Security Considerations
The TSR option is an optimization: it ameliorates an edge case for mDNS proxies. A malicious host on the same link could use the TSR option to win conflict resolution processes. However, because TSR is only used by proxies, this technique will not work for normal mDNS service registrations: in that case, normal mDNS conflict resolution is done, and the attacker gains no benefit from using TSR.
Whether or not an mDNS registration has a recorded time of receipt, an attacker can deny service by announcing its own conflicting data and then answering the subsequent probe as described in Section 9 of [RFC6762]. Because it does not include a TSR record in its authority section, it can win the simultaneous conflict resolution process that follows its bogus announcement.
So the TSR-based conflict resolution process creates no new vulnerability. Addressing the existing vulnerability is out of scope for this document. Protocols that rely on mDNS MUST NOT assume that mDNS service is secure or private. If security (authentication, authorization and/or secrecy) are needed, these must be provided at the application layer, or by using DNSSEC rather than mDNS for service discovery.
IANA Considerations
IANA is requested to allocate a new OPT RR option code from the DNS EDNS0 Option Codes (OPT) registry for the 'Time Since Received' Option. The Name shall be 'mDNS-TSR'. The value shall be allocated by IANA. The meaning shall be 'Multicast DNS Time Since Received". Reference shall refer to this document, once published. IANA shall determine the registration date.
Informative References
Normative References
[RFC1034]
[RFC6762]
[I-D.sctl-advertising-proxy]
[I-D.ietf-dnssd-srp]
[I-D.lemon-srp-replication]