Skip to content

fix(comm)!: bind the websocket server certificate to the peer ID the client dials - #2076

Merged
mbrandenburger merged 2 commits into
hyperledger-labs:mainfrom
mbrandenburger:fix/ws-client-peer-binding
Oct 14, 2026
Merged

mbrandenburger merged 2 commits into
hyperledger-labs:mainfrom
mbrandenburger:fix/ws-client-peer-binding

Conversation

@mbrandenburger

Copy link
Copy Markdown
Member

Resolves #2000.

What changed

  • The client binds the server certificate to the dialed peer ID. Both MultiplexedProvider and SimpleProvider now take the peer ID from the server's verified leaf certificate right after the dial, and close the connection when it differs from info.RemotePeerID. verifyServerPeerID in ws/auth.go uses the same peerIDFromCertificate as the server side, so nothing had to be exported. No stream data or StreamMeta is sent before the check.
  • The multiplexed cache is keyed by URL and peer ID. The cert is checked once, when the connection is dialed, so a connection is reused only for the peer it was checked for. A connection that fails the check is never cached, and callers sharing an in-flight dial share the same key, so they expect the same peer.
  • Plaintext is not checked. Without TLS there is no certificate to bind to. GetNewHost already requires mutual TLS, so production nodes never take this path.
  • Docs. Godoc on both NewClientStream methods, stream.RemotePeerID, MultiplexedProvider and NewConfig, plus docs/platform/view/services/comm/websocket.md and multiplexer.md.

The issue suggests a VerifyConnection callback in client.OpenStream plus a separate cache fix. One check in the providers covers both providers and the cache in one place. The cost is that the client finishes the TLS handshake and websocket upgrade before it rejects the server, instead of aborting during the handshake.

Tests

  • TestClientStreamBindsServerCertificateToRemotePeerID is the issue's reproduction with its assertions reversed. It dials peer V at a server presenting peer A's trusted certificate, and checks that a fresh dial fails and is not cached, that a cached connection to A does not carry a stream for V, and that SimpleProvider rejects V too. It fails with the check disabled, and the cached-connection case fails when the cache is keyed by URL alone.
  • Tests that dialed made-up peer IDs over TLS ("serverID", "server", "remote") now dial the server's real peer ID through a serverPeerID helper.
  • go test -race ./platform/view/services/comm/..., make checks and make integration-tests-fsc-pingpong (WebSocket and WebSocket with replication) pass.

Breaking change

A client stream now fails with peer identity binding failed when the server's TLS certificate does not belong to the dialed peer ID, for example when a resolver's identity is not the remote node's fsc.identity. Real peer IDs come from ExtractPKI(resolver.ID) with websocket.PKIDSynthesizer, which matches the certificate derivation, and the transport keypair is always fsc.identity, so correctly configured networks are unaffected. Setups this breaks, such as a resolver identity with a different key or a proxy that terminates TLS in front of a node, already fail the server-side binding.

Panurus does not import comm/host/websocket and only reaches it through NWO topologies, so it is unaffected. No exported API changes.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Hey @mbrandenburger 👋 thanks for the PR!
I'm your friendly PR Helper Bot 🤖 and I'll be riding shotgun on this one, keeping track of your PR's status to help you get it approved and merged.

This comment updates automatically as you push changes -- think of it as your PR's live scoreboard!
Here's the latest:


PR Checks

✅ DCO Sign-off -- All commits have valid sign-offs. Nice work!


❌ GPG Signature -- Heads up! The following commits don't have a verified GPG signature:

  • b164c5a fix(comm)!: bind the websocket server certificate to the peer ID the client dials
  • b0faaf0 fixup! fix(comm)!: bind the websocket server certificate to the peer ID the client dials

You'll need to sign your commits with GPG (e.g. git commit -S). See the Signing Guide for a step-by-step walkthrough.


✅ Merge Conflicts -- No merge conflicts detected. Smooth sailing!


✅ Issue Link -- Linked to #2000 (assigned to you).


⏳ All checks must pass before this PR can be reviewed. You've got this!

@github-actions github-actions Bot added the status: needs revision The pull request requires changes from the author before it can be reviewed or merged label Oct 13, 2026
@mbrandenburger mbrandenburger added status: needs review The pull request is ready for maintainer review and removed status: needs revision The pull request requires changes from the author before it can be reviewed or merged labels Oct 13, 2026
@mbrandenburger mbrandenburger added this to the 26Q4 milestone Oct 13, 2026

@SaidAltury-ibm SaidAltury-ibm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thank you @mbrandenburger , one small doc comment

@github-actions github-actions Bot added status: needs revision The pull request requires changes from the author before it can be reviewed or merged and removed status: needs review The pull request is ready for maintainer review labels Oct 14, 2026

@SaidAltury-ibm SaidAltury-ibm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thank you @mbrandenburger , LGTM

@mergify

mergify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@mbrandenburger
mbrandenburger enabled auto-merge (squash) October 14, 2026 10:41
…client dials

The websocket client verified the server's certificate chain and hostname
but never checked that the certificate belonged to the peer it dialed. Any
certificate that chained to a trusted CA and was valid for the dialed host
was accepted, and the stream reported the dialed peer ID as its remote.

Both stream providers now derive the peer ID from the server's verified
leaf certificate right after the dial and close the connection when it
differs from info.RemotePeerID. The multiplexed provider caches client
connections per URL and peer ID, so a connection checked for one peer
never carries a stream for another, and a connection that fails the check
is not cached. Without TLS there is no certificate and nothing is checked;
GetNewHost already requires mutual TLS.

Fixes hyperledger-labs#2000

BREAKING CHANGE: a websocket client stream fails with "peer identity
binding failed" when the server's TLS certificate does not belong to the
dialed peer ID, for example when a resolver's identity is not the remote
node's fsc.identity.

Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
…ID the client dials

Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
@mbrandenburger
mbrandenburger force-pushed the fix/ws-client-peer-binding branch from 8643caf to b0faaf0 Compare October 14, 2026 10:41
@mbrandenburger
mbrandenburger merged commit db1585e into hyperledger-labs:main Oct 14, 2026
@mbrandenburger
mbrandenburger deleted the fix/ws-client-peer-binding branch October 14, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs revision The pull request requires changes from the author before it can be reviewed or merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(view): websocket client does not bind the server certificate to the peer ID it dialed

2 participants