Repository navigation
fix(comm)!: bind the websocket server certificate to the peer ID the client dials - #2076
Conversation
|
Hey @mbrandenburger 👋 thanks for the PR! This comment updates automatically as you push changes -- think of it as your PR's live scoreboard! 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:
You'll need to sign your commits with GPG (e.g. ✅ 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! |
SaidAltury-ibm
left a comment
There was a problem hiding this comment.
thank you @mbrandenburger , one small doc comment
SaidAltury-ibm
left a comment
There was a problem hiding this comment.
thank you @mbrandenburger , LGTM
|
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. |
…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>
8643caf to
b0faaf0
Compare
Resolves #2000.
What changed
MultiplexedProviderandSimpleProvidernow take the peer ID from the server's verified leaf certificate right after the dial, and close the connection when it differs frominfo.RemotePeerID.verifyServerPeerIDinws/auth.gouses the samepeerIDFromCertificateas the server side, so nothing had to be exported. No stream data orStreamMetais sent before the check.GetNewHostalready requires mutual TLS, so production nodes never take this path.NewClientStreammethods,stream.RemotePeerID,MultiplexedProviderandNewConfig, plusdocs/platform/view/services/comm/websocket.mdandmultiplexer.md.The issue suggests a
VerifyConnectioncallback inclient.OpenStreamplus 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
TestClientStreamBindsServerCertificateToRemotePeerIDis 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 thatSimpleProviderrejects V too. It fails with the check disabled, and the cached-connection case fails when the cache is keyed by URL alone."serverID","server","remote") now dial the server's real peer ID through aserverPeerIDhelper.go test -race ./platform/view/services/comm/...,make checksandmake integration-tests-fsc-pingpong(WebSocket and WebSocket with replication) pass.Breaking change
A client stream now fails with
peer identity binding failedwhen 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'sfsc.identity. Real peer IDs come fromExtractPKI(resolver.ID)withwebsocket.PKIDSynthesizer, which matches the certificate derivation, and the transport keypair is alwaysfsc.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/websocketand only reaches it through NWO topologies, so it is unaffected. No exported API changes.