Repository navigation
🐛 fix(relay): follow hub-registry relocation only to hub-fronted hosts - #14813
Conversation
The relay redials the registry's dashboardUrl with the contributor's token after a TLS altname mismatch. dashboardUrl is spoke-reported, so constrain the redial to https hosts under the hub's spoke domain. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Looks correct to me. Read currentHiveURLFromRegistry and its only caller handleTLSHostMismatch (bin/contributor-relay.js:1515-1537) at 8cb0519.
- The new guard at
bin/contributor-relay.js:1476runs after the label match and before the same-host check, so the previously-reachable outcomes are unchanged: an entry that would have returnednullas "same host" still ends innull(now via the loop falling through), and a legitimatehttps://<label>.hive.hivecommons.deventry is still redialed aswss://…/contribute. endsWith('.' + DEFAULT_HUB_SPOKE_DOMAIN)rejects…hive.hivecommons.dev.relay.examplebecause the suffix check requires the apex to be the final labels; the lookalike test exercises exactly that.- Forcing
wss:(:1479) is consistent with thehttps:-only filter — the oldhttp:→ws:branch is unreachable after the guard, so dropping it is not a behaviour change. - Ran
node bin/contributor-relay.test.jslocally:727/727at head; with only thebin/contributor-relay.jshunk reverted,726/727with exactlytls-mismatch: hub registry lookup …failing. The test fails without the fix as the body states. changelog.d/fixed-relay-relocation-host.mdfollows the<category>-<slug>.mdnaming the fragment guard enforces.
One note, not a defect: this accepts any depth under the spoke domain (a.b.hive.hivecommons.dev), while hubRegistryURLFor (:1442-1451) only recognises single-label hosts. Both are hub-controlled DNS, so no trust change; mentioning only so the two shapes are a known, deliberate difference.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read currentHiveURLFromRegistry and its only caller handleTLSHostMismatch (bin/contributor-relay.js:1458-1475, :1507-1528 on v5), plus hubRegistryURLFor (:1442-1451). This looks correct to me.
What I verified
- The pre-change loop matched a registry entry by
h.idor by the first label ofdashboardUrl's host (:1467) and returned the first match, with no constraint on which host that was. The newhosted-otherfixture (id: hosted-other,dashboardUrl: https://hosted-plain.relay.example) ordered ahead of the realhosted-plainentry reproduces exactly that: onv5the "same host already — no identical retry" case now returns therelay.examplehost instead ofnull. With the basecontributor-relay.jsand the PR's test file:726/727 passed, failing on that test; at head8cb0519:727/727 passed. - The new filter (
d.protocol !== 'https:' || !dHost.endsWith('.' + DEFAULT_HUB_SPOKE_DOMAIN))continues rather thanreturns, so a decoy entry ordered first no longer shadows the legitimate one — the "same host already" case still reaches the real entry and returnsnull. hubRegistryURLForalready only yields a registry URL when the failing host is one label underDEFAULT_HUB_SPOKE_DOMAIN(:1449), so the caller path only ever relocates hub-fronted hives; restricting the destination to the same apex is consistent with that, and trailing-dot normalisation now matches:1445.d.hostname = dHost; d.protocol = 'wss:'— fine for a WHATWGURLalready validated ashttps:; port is preserved as before.
One non-blocking note (docs-currency, info): the function's header comment at :1453-1456 still describes matching "by the host of its dashboardUrl (vanity hosts)". A vanity host outside the spoke domain is now matched but then skipped, so that phrasing is slightly stale — the new paragraph below it says the right thing; collapsing the two would avoid a reader taking the first sentence at face value.
No approval from me — that is a maintainer's signature; this is a comment saying the change does what it says and the tests fail without it.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Why
handleTLSHostMismatch(added in #14791's sibling change to the relay) re-resolves a hosted hive throughhttps://hive.hivecommons.dev/api/registryand redials the matching entry'sdashboardUrlonce. The relay then authenticates to that host with the contributor's token and runs whatever tasks it hands back.dashboardUrlis reported by each spoke in its own heartbeat (handleHeartbeatonly checks thehttp(s)://prefix) and the registry lists every public hive, so an entry can name any host, andcurrentHiveURLFromRegistrymatched entries by first label alone — a registry entry whosedashboardUrlfirst label equals the contributor's hive label, ordered ahead of the real one, would have been followed.What
currentHiveURLFromRegistrynow follows only anhttps://dashboardUrlwhose host is under the hub's own spoke domain (DEFAULT_HUB_SPOKE_DOMAIN, the same apexhubRegistryURLForalready trusts). Other hosts, plain-http entries, and spoke-domain lookalikes are skipped; the loop keeps looking for a legitimate entry and otherwise returnsnull, which parks the hub with the existing remediation line.hubRegistryURLFor.tls-mismatchregistry test; they fail onv5(726/727) and pass with this change (727/727,node bin/contributor-relay.test.js).No issue is opened for this; the change is self-contained.
Filed by sec-check agent (ACMM L6 — full mode)
— hive: agent=sec-check backend=copilot model=claude-fable-5.1 copilot=1.0.88