Skip to content

🐛 fix(relay): follow hub-registry relocation only to hub-fronted hosts - #14813

Merged
hivecommons-hive[bot] merged 1 commit into
v5from
sec/relay-relocation-host
Oct 28, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
v5from
sec/relay-relocation-host

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Why

handleTLSHostMismatch (added in #14791's sibling change to the relay) re-resolves a hosted hive through https://hive.hivecommons.dev/api/registry and redials the matching entry's dashboardUrl once. The relay then authenticates to that host with the contributor's token and runs whatever tasks it hands back.

dashboardUrl is reported by each spoke in its own heartbeat (handleHeartbeat only checks the http(s):// prefix) and the registry lists every public hive, so an entry can name any host, and currentHiveURLFromRegistry matched entries by first label alone — a registry entry whose dashboardUrl first label equals the contributor's hive label, ordered ahead of the real one, would have been followed.

What

  • currentHiveURLFromRegistry now follows only an https:// dashboardUrl whose host is under the hub's own spoke domain (DEFAULT_HUB_SPOKE_DOMAIN, the same apex hubRegistryURLFor already trusts). Other hosts, plain-http entries, and spoke-domain lookalikes are skipped; the loop keeps looking for a legitimate entry and otherwise returns null, which parks the hub with the existing remediation line.
  • Trailing-dot hosts are normalised before comparison, matching hubRegistryURLFor.
  • Three cases added to the existing tls-mismatch registry test; they fail on v5 (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

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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 28, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#14628 🐛 fix(review): require sign-off on review-fix follow-up commits same files bin/contributor-relay.js
bin/contributor-relay.test.js

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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:1476 runs after the label match and before the same-host check, so the previously-reachable outcomes are unchanged: an entry that would have returned null as "same host" still ends in null (now via the loop falling through), and a legitimate https://<label>.hive.hivecommons.dev entry is still redialed as wss://…/contribute.
  • endsWith('.' + DEFAULT_HUB_SPOKE_DOMAIN) rejects …hive.hivecommons.dev.relay.example because the suffix check requires the apex to be the final labels; the lookalike test exercises exactly that.
  • Forcing wss: (:1479) is consistent with the https:-only filter — the old http:→ws: branch is unreachable after the guard, so dropping it is not a behaviour change.
  • Ran node bin/contributor-relay.test.js locally: 727/727 at head; with only the bin/contributor-relay.js hunk reverted, 726/727 with exactly tls-mismatch: hub registry lookup … failing. The test fails without the fix as the body states.
  • changelog.d/fixed-relay-relocation-host.md follows the <category>-<slug>.md naming 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.id or by the first label of dashboardUrl's host (:1467) and returned the first match, with no constraint on which host that was. The new hosted-other fixture (id: hosted-other, dashboardUrl: https://hosted-plain.relay.example) ordered ahead of the real hosted-plain entry reproduces exactly that: on v5 the "same host already — no identical retry" case now returns the relay.example host instead of null. With the base contributor-relay.js and the PR's test file: 726/727 passed, failing on that test; at head 8cb0519: 727/727 passed.
  • The new filter (d.protocol !== 'https:' || !dHost.endsWith('.' + DEFAULT_HUB_SPOKE_DOMAIN)) continues rather than returns, so a decoy entry ordered first no longer shadows the legitimate one — the "same host already" case still reaches the real entry and returns null.
  • hubRegistryURLFor already only yields a registry URL when the failing host is one label under DEFAULT_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 WHATWG URL already validated as https:; 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

@hivecommons-hive
hivecommons-hive Bot merged commit a2236e6 into v5 Oct 28, 2026
81 of 84 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the sec/relay-relocation-host branch October 28, 2026 03:22
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#148138cb0519` sha256:ad29cff1d84160a5297b05c10974382edbfbe2e267c3dcaa2ce00312c974d3d5 — download from the dashboard or `hivectl review evidence #14813`.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants