Skip to content

fix(lib-pairing): normalise the paired endpoint in the key, target and deny check - #177

Merged
pditommaso merged 2 commits into
masterfrom
fix/pairing-normalise-endpoint
Nov 26, 2026
Merged

pditommaso merged 2 commits into
masterfrom
fix/pairing-normalise-endpoint

Conversation

@pditommaso

Copy link
Copy Markdown
Contributor

Problem

A service pairs by opening the pairing socket and declaring its own address in the endpoint query parameter. That string went verbatim into:

  • the pairing store key (PairingServiceImpl.makeKey)
  • the channel routing target (PairingChannel.clientTarget, which stripped only the scheme)
  • the deny-host check (PairingWebSocket.isDenyHost, a case-sensitive contains)

So https://platform.acme.com/api, https://PLATFORM.acme.com/api and https://platform.acme.com:443/api/ were three separate pairings, each answered by whoever registered it. In Wave, where the tenant of a private record is meant to be the canonical endpoint (wave ADR 20261029-workspace-ownership §2.3), a separate pairing for another spelling of an already-paired Platform lets its owner share that Platform's tenant while answering its own membership checks. denyHosts could also be bypassed with a change of case (FOO.NGROK.APP).

Change

  • New PairingEndpoint.normalise: lowercases the scheme and host, drops the default port and any trailing slash, keeps the path's case. This is the same rule as Wave's normalisePlatformEndpoint.
  • It's applied in makeKey, clientTarget and isDenyHost, so every spelling of one address resolves to one pairing record and one set of clients, and the deny list matches the canonical form.
  • PairingRecord.endpoint keeps the spelling the client declared.

Upgrade

Endpoints already in canonical form, which is most of them, hash to the same key as before, so their records are found. A record paired under a non-canonical spelling is no longer found under the new key. The next heartbeat sees it missing and closes the session, and the client reconnects and pairs again. The pairing id and key pair change for those clients only.

Bumps lib-pairing to 1.3.0. Not tagged [release]; add it when merging if this should publish.

Not addressed

A second registration under an endpoint that's already paired joins the existing record and is added as another client of the same target. That was already true for the exact spelling. This change extends it to the variant spellings instead of giving them a pairing of their own. Authenticating who may pair an endpoint is a separate fix.

Testing

Compiles (:lib-pairing:compileTestGroovy); tests not run locally. New PairingEndpointTest covers normalisation, key stability for canonical endpoints, one key and one target per address, and a case-insensitive deny-host test in PairingWebSocketTest.

🤖 Generated with Claude Code

…d deny check

The pairing store key and the channel routing target used the endpoint
exactly as the client declared it, so spellings of one address differing
only in case, default port or trailing slash were paired, and answered,
separately. A Platform paired under such a spelling got its own pairing
next to the real one. denyHosts matched case-sensitively, so a change of
case slipped past it.

Add PairingEndpoint.normalise and use it in PairingServiceImpl.makeKey,
PairingChannel.clientTarget and PairingWebSocket.isDenyHost. Endpoints
already in canonical form keep their key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@munishchouhan munishchouhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The approach is right, and I verified the part that matters: getPairingRecord goes through makeKey, so normalising there makes the lookup spelling-tolerant — which is exactly what lets Wave's tenant key normalise safely in seqeralabs/wave#1319. Keeping PairingRecord.endpoint as the client declared it is the right call too.

Requesting changes for three small things, two of which have a traced path to a worse state than before the PR. None is architectural; I'd approve with them in.

Worth knowing the stakes: wave#1319 is blocked on this publishing as lib-pairing:1.3.0, and it hashes normalise into Wave's private build ids, which are persisted and handed to clients. A silent fallback costs a re-pair here; over there it costs a changed id.

CI being green is consistent with all three — none of them has a test.

…s, empty endpoint

- Lowercase scheme and host with Locale.ROOT, so a Turkish default locale
  no longer breaks the URI rebuild and falls back to the raw spelling
- Lowercase denyHosts entries too, so a mis-cased entry still blocks
- Route an empty endpoint to the 'service:' target instead of an NPE
- Document that the output of PairingEndpoint.normalise is frozen

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pditommaso
pditommaso merged commit bc88cd0 into master Nov 26, 2026
12 checks passed
munishchouhan added a commit that referenced this pull request Nov 26, 2026
#177 bumped VERSION to 1.3.0 but its merge commit carried no [release] marker, so
the Release step of Libseqera CI was skipped and 1.3.0 was never published. This
commit carries the marker; publish.sh is idempotent and gated by the VERSION file,
so it publishes 1.3.0 and nothing else.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants