Re: [dnssd] Strategy of advertising proxy for hostname conflicts during key lease period? (draft-ietf-dnssd-advertising-proxy-00)

Esko Dijk <esko.dijk@iotconsultancy.nl> Mon, 20 June 2022 10:00 UTC

Return-Path: <esko.dijk@iotconsultancy.nl>
X-Original-To: dnssd@ietfa.amsl.com
Delivered-To: dnssd@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 808FDC157B3A for <dnssd@ietfa.amsl.com>; Mon, 20 Jun 2022 03:00:48 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.107
X-Spam-Level:
X-Spam-Status: No, score=-2.107 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=iotconsultancy.nl
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L-2sgMeMzPmL for <dnssd@ietfa.amsl.com>; Mon, 20 Jun 2022 03:00:42 -0700 (PDT)
Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20719.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::719]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 22FA4C14F725 for <dnssd@ietf.org>; Mon, 20 Jun 2022 03:00:40 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FRdBNXYUcKZTRdEfeqXitolXV1jwmlru8bEbarXAqE0p+0yyiMI52aMEA87imLjZkfwZN61yBwBV7LtGn1AdqpM3OJA1UqeKJO8YyEea3Omv2s8B1igoc2eAvIK/sMgTCOdE9dds/WTxMYYD47Gph/diFUWKWHbQuOvU03TgzZZuA/rUk9eNEQPSCTa8ImBJWydAJlH0a8hTCU5bBPcyRqrQkMTF+Z/ejURuoWUvE/OdA3uqUndBXSEiZVppgMHVbzQcg2nu5y1dt+ucKNKaQmMOT+9xN1QlMTV5sjP2y9GYZoMcdOzlAvM6U8s2v/IGrOfJ6sNm8RRqKYW3jCXRxw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AhSLZeHgpwn4cVAW65p/JRTK31a0oPggiU+/miX6CJk=; b=mVt/ny32i6tW9ORqx/vkKWWZ/JS6hcUGYGwvZ5poKplbJUQd1i9gkBvZd2bcQM2Wlyel+hJuwClEi01+zwze9o3sgLWSB9gPDuqNy/0LE52omcvl5bKAY2OQL8nS6o2E6VQZwBwPejLgGywqZdQ2tXiInHTkdAUGgwlv/uPWWuCw2pZiT/GUMFyegL5TzSKiTY88aWcikZmlwNGVnO5mhnwNM3wok/0ig78rQTF4/c/snzXfhAgNqIeXKjHgegtA/2oclfPxrf7FV9MphCHvj0sexM9rV+qrVN4N/sO9jK9HWrVbYcqfR7jstmfT9KmvPSbW9XnMcd6xcEYjhbj0cw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=iotconsultancy.nl; dmarc=pass action=none header.from=iotconsultancy.nl; dkim=pass header.d=iotconsultancy.nl; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iotconsultancy.nl; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AhSLZeHgpwn4cVAW65p/JRTK31a0oPggiU+/miX6CJk=; b=y0+RbAalzIK8CAif0PbpwraciiF1N9zjvP9RNl7gxZSAT5RJcdJjDlMN7ih0y+HzRxcFAwtppfIwCGEJRLdfAZDwq3jN/gAt2/ERmguf6u1BNc0U7uefrJvNu39AB0BOw69Zk+MNqA1Re9yunKZfToas52YTN1fyhU33byfTqvk=
Received: from DU0P190MB1978.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:3b9::20) by DB9P190MB1451.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:243::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.15; Mon, 20 Jun 2022 10:00:33 +0000
Received: from DU0P190MB1978.EURP190.PROD.OUTLOOK.COM ([fe80::50a1:9a72:f2e6:587e]) by DU0P190MB1978.EURP190.PROD.OUTLOOK.COM ([fe80::50a1:9a72:f2e6:587e%6]) with mapi id 15.20.5353.016; Mon, 20 Jun 2022 10:00:32 +0000
From: Esko Dijk <esko.dijk@iotconsultancy.nl>
To: Ted Lemon <mellon@fugue.com>
CC: "dnssd@ietf.org" <dnssd@ietf.org>
Thread-Topic: [dnssd] Strategy of advertising proxy for hostname conflicts during key lease period? (draft-ietf-dnssd-advertising-proxy-00)
Thread-Index: Adh7PAzPUxhdnq2hQTGOWDMt+PT2qAAK8Y8AACAeQUABZa7PMAAJvPSAAEIOb4AARFLZsAAIOt2AACdUtWA=
Date: Mon, 20 Jun 2022 10:00:32 +0000
Message-ID: <DU0P190MB1978B06D0403B971A22105C3FDB09@DU0P190MB1978.EURP190.PROD.OUTLOOK.COM>
References: <DU0P190MB1978D4C3F784B67C8AF39A7DFDA49@DU0P190MB1978.EURP190.PROD.OUTLOOK.COM> <CAPt1N1nFYVMYiEuhSM4Kuickvb2VBgyanEV=VgGtX996oZW5EA@mail.gmail.com> <DU0P190MB197866CA95A9ABBB013ED9D9FDA79@DU0P190MB1978.EURP190.PROD.OUTLOOK.COM> <DU0P190MB1978B2BF4465D735DF2FC24BFDAC9@DU0P190MB1978.EURP190.PROD.OUTLOOK.COM> <CAPt1N1n-cmg4bydwM56Z9EZF_si19Ve1YNbBg=4H2YksWDd++A@mail.gmail.com> <CAPt1N1kD7VT0OKoEbH6LHZh4v0goNj1jV1aTSrE4kY9pLF3pQA@mail.gmail.com> <DU0P190MB1978AE5CAB7C8A54AE5FA457FDB19@DU0P190MB1978.EURP190.PROD.OUTLOOK.COM> <CAPt1N1=KNUFi9Db4+a9edYsjmuCvoYZVupNRMnznQhPs62NFUQ@mail.gmail.com>
In-Reply-To: <CAPt1N1=KNUFi9Db4+a9edYsjmuCvoYZVupNRMnznQhPs62NFUQ@mail.gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=iotconsultancy.nl;
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 17e02de3-afd9-4c82-1b8c-08da52a3b6da
x-ms-traffictypediagnostic: DB9P190MB1451:EE_
x-microsoft-antispam-prvs: <DB9P190MB1451259CFEAA0B182FDDF944FDB09@DB9P190MB1451.EURP190.PROD.OUTLOOK.COM>
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: DqisRXXgZBmPkuQ5Jvc49CAM+EUc5Z6LjprTYOBHlNF8uLd8iS+DRkiEX48iFhVLuu3iJfxBZ7E8g155JQ1K9CTJKPzFCZ43MjefDswH/3I870cUbEZTUZEBDDHhPgztFSOuwEsnHoPzKXu/tiz7g6pkSWzQYQtl3gNQe+Onja2XUolF9UnWSbE4GYB8FrLcVhycdT8WBqovUjYI/aw8Z5IdAiI836Gq27IqeaxU1V22jeM1dhogQN3z6Nykyet38Jny0yzukIU0/0snPAp4sp8q3qLgtc4zWetSbu05ys1GkNIM4VbiR0uwPGY5L88Tc92I9SA55Aq6QUmatolYSnMs2LlYAUIhG8epBlYCrC6Bs27OdUmvYODxesHkjoL7M2R7VhxY96kgonhn+91MMWr8iU3p2SVU2grJ0skF4rPvCXdF3+YO83a2ftu5s9XKrUN2WyPMPogq8Lp3Wy1IkfuVNzSMJetLuRaxGYyhp25lWWbd7PmCCcJxeOiRGpIGqaVPUSScxEF7Q5wXucHIToh8heZb047+nroPss7mIk5pnStF0Ca4lHh5PKSG5KJpho2IoyXsUTtJ6EFfZ+OzCDMpdkM0oprPKrWPG/yuS+KPf+RFtU6ulyWE6FoZuVEkJPOa7h9/JLZTijF7VdJiP3XDRqrAgLjDr4iTicBoOZicbyatJnMb0gwBHLmirWU0y94u1YaGF0GNCvc02A2dOA==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0P190MB1978.EURP190.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230016)(136003)(346002)(396003)(376002)(366004)(39830400003)(66446008)(64756008)(478600001)(66476007)(122000001)(38070700005)(8676002)(71200400001)(86362001)(4326008)(83380400001)(66556008)(6916009)(66574015)(186003)(66946007)(76116006)(38100700002)(26005)(7696005)(53546011)(55016003)(9686003)(6506007)(5660300002)(33656002)(2906002)(8936002)(52536014)(316002)(44832011)(41300700001); DIR:OUT; SFP:1102;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: 92oR/XmrlXvGulvDehHn4JSUdPQa0DBbI9BsaTst92tHudosAR/2gaSotOfC7QY1apbGVKJTCOz54up0JP5B+vvrUUxq7x5YG6jAtbFb8825Mg/AtPHl778Oc+DiGaOrZgk0pkZFO7EPCLiha6T4VlLyACWVoOhdZQLSAc0JuD7Cpfz+SPGyLUx+Wo5WmBxgbZ4Nj3xvkbcFhBVcX6Re/Uhbw5rRU6D+EVSEUUpfeVMtTufiop3CnRiRXQwxgTyLm7msuc5jS0tImthDpQMXqSypN2Sw9ebywhCncYP/3v0qnMTqADLs3gw7RhyHruPagVFBFCVakxoiNyFsaBybajyQRQk2n9D5QILoH5ji4/n52A8jYwWl4gs2IW5guef6joZsAPJvG2115wn+LA08E/zwxkX59QdFXw+I7hCYObLAxHuzUOBE8I3MpaVdhewPHhXUJeYaetSrKPUirotb4JKCrhaZKTfmKSzSfYYxlnueZ0wsRdNKS9/di7ciC2JKmqppJUKWyiTlluyeGoi9MBOL8/Pw8Lo0yMO50gjXS3oRcnClBg0pVZMA7QCcyFp6AoAamVa/JU3BmNJ8e0rxOJssYxNv9sEkoE1e4SuIYHvuhQDGsw6n50Nvla7JuLOBRhl8sljvIg0qBai8T59TxOIjNhJ2UKX3cn6yzjcwRMLSO7tVa9i3WYal3D3GAiDTpHEG4BxHsSUk7LwVED2SoCYt3i8cMstmxEOmS2S1Sd/SRthMURun2mGTXQPoYBmDdAUlJXEUxSK+eGOpY3bW4c4CX3ZpqCMm1G6aJXawcRCD3djg09SrD+/l+i/6Rzu3GozBLLEbrP2GNGfW2ffV5rgXVn3cXd18bVtOwwIGW8CQpXQiqaRyQv3LbB3FhMej5AL+6VLOc+E5QtZiqc4Aap7pEuH6SBCDpyZU4bMz2c4UHpgg0HXiBUzRUvMfVO4oZNCwASNnG9YHtifBCFfmKcEnR4JkFjpIpMqxgYbwBXzZCE5POFBFy8+nTT8uY9Zr8rxGVxIWKJwjb2XMld1pll9D+QOtxztxgpmN6KhoCB+FPaDJ/kgo4fJ4D/6oH8s4btv94iQ2DDDagg6ccNoe9kFEWocxXjdYOwjuO6EQFmLFR06YLq8lFGPCNLw2ydyZ6+PGLrsxgAW2ZvBIfcPqqozpBg6Tg8A8A8+Z0KZXc7svXaxvzRCCGq6VUJIec1bnjgq95ztPNS9yyVevvI/jHHSfGIsE0KzCMuh8wN6Pu/5zSIFPY8zWQK8vn0a64ce2FGpK8cuVO+gi4IzUJjPTnCpEwLjOkWzGYpqo/mGv95F5LWmcv58iLAa/vl744ZYrvac49Pnhv3aJ7RWbKfSeWzL8ej7oQQKyMXsUmIDS5qyYO5k/JlysQqjV42px4SIK68ZWhkH2SRgVJlMsrIFYETEz4yos2sWScfoPgyFDYOsECxPTcs4u0AVfkylR1uNGhzZZ6AzUvLURuNyCp6uCDdZZBE5JCnPycWQGNdMFs73pLivI8nefzEZ9LdYyj2Boa7OduftPQ2GRYXDhDSEtEaDQSk2y+iDG5E1ZULbd4kFBnvjK1Uhbq9yMpBNAR9Au9ak63AyJYllcRTmcgIFaI9xcJBByCh8TBIS82aNwH8AaROYY2dr09j6nX3Q16QNPZFPtQ9W7niuRuJJpw6H6OsxV0adLNtWc0C7FYboGFtWobtpD3u7wghOFwOYOtSfx/20pamJSzyuuEFmeDC43ZxqS3oOm2x/h9fPIyR3VDS8=
Content-Type: multipart/alternative; boundary="_000_DU0P190MB1978B06D0403B971A22105C3FDB09DU0P190MB1978EURP_"
MIME-Version: 1.0
X-OriginatorOrg: iotconsultancy.nl
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: DU0P190MB1978.EURP190.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-Network-Message-Id: 17e02de3-afd9-4c82-1b8c-08da52a3b6da
X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jun 2022 10:00:32.6773 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 58bbf628-15d2-46bc-820b-863b6774d44b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: 3Lnz1E9LL0G63AAvqXdBv+vECRPjYw4fHqXP75TsKxFG9+T9BpffUGYHpiEVJQCyfcOB5i3OiHRH8iQY0pG2Y4HTw+Uhpr0/1ZI6yPk/oyY=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB1451
Archived-At: <https://mailarchive.ietf.org/arch/msg/dnssd/0iATxf1dRPNRmFxN0eFcGOUzGpI>
Subject: Re: [dnssd] Strategy of advertising proxy for hostname conflicts during key lease period? (draft-ietf-dnssd-advertising-proxy-00)
X-BeenThere: dnssd@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: "Discussion of extensions to DNS-based service discovery for routed networks." <dnssd.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/dnssd>, <mailto:dnssd-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/dnssd/>
List-Post: <mailto:dnssd@ietf.org>
List-Help: <mailto:dnssd-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/dnssd>, <mailto:dnssd-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 20 Jun 2022 10:00:48 -0000

One other thing that may be worth mentioning is that while we discussed the scenario that a client lets its service lease expire (and what happens next with queries); there’s also the case where an SRP client explicitly removes a  service.
Such action as described in SRP section 2.2.5.5.2. The key-lease is kept active then for the hostname record. But, the KEY record for the service instance name is deleted by this action -- so won’t be visible any longer in subsequent queries (e.g. for KEY or ANY records for service instance name).

> This might be a bit puzzling because we do see certain IoT frameworks using a different label for the service instance name than for the hostname.
> But this is not the usual behavior, and TBH I think it's a mistake. Not sure there's anything to be done about it. But normally this is what you'd expect to see:

Thanks, this clarifies a lot! I have seen different naming conventions for mDNS; e.g. an IoT stack that encourages API users to set a friendly name as the service instance name but also to select it different from the hostname.
Any my home router that uses “Router Admin Webif” as the instance name which seems unrelated to the hostname that it uses.  And  a smartphone that uses the same user-selected name for host & service-instance.
Appendix C/D of RFC 6763 would encourage a device maker to use a default service instance name say “BrandX Temperature Sensor” but it doesn’t say that this name needs to change as well when only a hostname conflict is detected. It rather says the opposite; to keep the name simple and clean and only once a conflict is detected you can start adding a prefix like “(2)”.

So we cannot 100% rely on a device keeping a strict relation of hostname with service instance name, in case a mDNS device would detect a conflict on the hostname -- but not a conflict on the service instance name.

> In the case of the IoT frameworks that use a different label for the service instance name, we're pretty much relying on collisions being very unlikely. I think this is a safe bet—the service instance name has something like 64
> or 128 bits of randomness (I'm not sure off the top of my head) and is required to be unique on generation, so the chances that the same label would show up on the same network in mDNS for a different service are vanishingly small.

So the issue is effectively not present in the following cases

  1.  mDNS devices where host/service names are kept aligned  (and can be user-configured)
  2.  particular IoT framework devices that include randomness in service/host names ( names aren’t supposed to be used for User Interfaces directly – and there may be many of these devices in a home)

And the only remaining category where it might be an issue is “other”. And for this category the worst that might happen is a temporary co-existence of the same service instance name, which is allowed anyhow by mDNS, followed by a service rename.
The rename case happens when the conflict is detected later on when the original device that had the expired service-lease, registers again via SRP. That SRP Update would then fail due to the AP doing the probe and finding the service name already in use.
The SRP client would then pick a new service name.   All in all this looks like an issue we can ignore for AP for now . (Though it could be mentioned somewhere in the draft.)

Best regards
Esko


From: Ted Lemon <mellon@fugue.com>
Sent: Sunday, June 19, 2022 15:28
To: Esko Dijk <esko.dijk@iotconsultancy.nl>
Cc: dnssd@ietf.org
Subject: Re: [dnssd] Strategy of advertising proxy for hostname conflicts during key lease period? (draft-ietf-dnssd-advertising-proxy-00)

On Sun, Jun 19, 2022 at 6:04 AM Esko Dijk <esko.dijk@iotconsultancy.nl<mailto:esko.dijk@iotconsultancy.nl>> wrote:
Thanks , I updated my lists based on your response – shown below.  There’s separate Options 1/2 now for the case that the Advertising Proxy (AP) does propagate KEY records for services, and for the case the AP doesn’t do this for services but only for Hosts. (Which you indicated would be sufficient and simpler to implement.)
Option 1) Incoming mDNS query , assuming that KEY records are also propagated via the Advertising Proxy:

  *   QTYPE = PTR , QNAME=<service type name> : No response
  *   QTYPE = SRV, QNAME=<service instance name> : Response with success (NoError) status and 0 answer records
  *   QTYPE = ANY, QNAME=<service instance name> : Respond with KEY record for <service instance name>
  *   QTYPE = KEY, QNAME=<service instance name> : Respond with KEY record for <service instance name>
  *   QTYPE = AAAA, QNAME=<host name>.local : Response with success (NoError) status and 0 answer records
  *   QTYPE = ANY, QNAME=<host name>.local : Respond with KEY record for <host name>.local
  *   QTYPE = KEY, QNAME=<host name>.local : Respond with KEY record for <host name>.local
Option 2) Incoming mDNS query , assuming that KEY records for services are NOT propagated via the Advertising Proxy:

  *   QTYPE = PTR , QNAME=<service type name> : No response
  *   QTYPE = SRV, QNAME=<service instance name> : No response
  *   QTYPE = ANY, QNAME=<service instance name> : No response
  *   QTYPE = KEY, QNAME=<service instance name> : No response
  *   QTYPE = AAAA, QNAME=<host name>.local : Response with success (NoError) status and 0 answer records
  *   QTYPE = ANY, QNAME=<host name>.local : Respond with KEY record for <host name>.local
  *   QTYPE = KEY, QNAME=<host name>.local : Respond with KEY record for <host name>.local
Right.
Incoming unicast DNS query:

  *   QTYPE = PTR , QNAME=<service type name> : Respond NXDOMAIN  (since the pointers for the expired-lease services are removed)
  *   QTYPE = SRV, QNAME=<service instance name> : Response with success (NoError) status and 0 answer records
  *   QTYPE = ANY, QNAME=<service instance name> : Respond with KEY record for <service instance name>
  *   QTYPE = KEY, QNAME=<service instance name> : Respond with KEY record for <service instance name>
  *   QTYPE = AAAA, QNAME=<host name>.default.service.arpa : Response with success (NoError) status and 0 answer records
  *   QTYPE = ANY, QNAME=<host name>.default.service.arpa : Respond with KEY record for <host name>.default.service.arpa
  *   QTYPE = KEY, QNAME=<host name>.default.service.arpa : Respond with KEY record for <host name>.default.service.arpa


Also right.

> the instance name is nearly always going to be the same as the hostname plus the service type and transport type labels.

This part was unclear to me; do you have an example? I thought a mDNS device would typically register something like “My Service._exampletype._udp.local” without including any hostname within the service instance name.
And with Option 2 above this service instance name would not be “defended” for the duration of the key lease which looks like a problem for service consistency within a home. (E.g. a client may have initially selected a particular instance and wants to keep using that specific one even though the service may be ‘absent’ some of the time.)
This might be a bit puzzling because we do see certain IoT frameworks using a different label for the service instance name than for the hostname. But this is not the usual behavior, and TBH I think it's a mistake. Not sure there's anything to be done about it. But normally this is what you'd expect to see:

libretto._ssh._tcp.local.     SRV    IN     0 0 22 libretto.local.

Note that service instance name is libretto._ssh._tcp.local, and the hostname is libretto.local, so the initial label in both cases is the same. This is the behavior that most DNS-SD services exhibit. I'm slightly glossing over one difference, which this HomeKit accessory shows off:

Eve\032Energy\032A02E._hap._udp.local. SRV    IN     0 0 5683 Eve-Energy-A02E.local.

So here the service instance name label and the hostname label are different in that the hostname label has dashes instead of spaces. This is because the service instance name label is not a hostname, and we care more about how it looks to the user in a UI than that the labels are identical. But still the two names clearly map to one another: if the hostname were to change, we'd expect the service instance name to change as well. My laptop's name doesn't exhibit this behavior because there are no spaces in the name. If it were e.g. "Ted Lemon's Laptop" then we would see the same service instance name difference that we see for the HomeKit accessory.

In the case of the IoT frameworks that use a different label for the service instance name, we're pretty much relying on collisions being very unlikely. I think this is a safe bet—the service instance name has something like 64 or 128 bits of randomness (I'm not sure off the top of my head) and is required to be unique on generation, so the chances that the same label would show up on the same network in mDNS for a different service are vanishingly small.

If we really think that's too big a risk to take, I can look into how hard it is to use the KEY record to defend the name, but bearing in mind that I think we ultimately (and hopefully fairly soon!) want to move in the direction of using mostly unicast discovery, it's worth considering how much effort would be worthwhile in pursuit of this goal.