Repository navigation
fix(comm)!: stop the websocket server trusting withdrawn extra CAs - #2069
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 #2063 (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 , 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. |
The server built its base ClientCAs from the extra CAs the provider held at startup. GetConfigForClient rebuilds the pool per handshake, but when the provider had no entries left it returned the base config, so a peer whose anchor was withdrawn could still connect. The base config now trusts only the configured pool, and the extra CAs come solely from the per-handshake rebuild. Config.ClientTLSConfig no longer takes an ExtraCAPoolProvider. The host adds the extra CAs per outbound stream, so a provider passed here only invited callers to keep a config that never learns new peers, and made GetNewHost parse every resolver certificate for a nil check. Also: - ExtraCAPoolProvider documents that a returned slice must not be modified, since the client caches and compares it. - The client Godoc and websocket.md say that a withdrawal affects new connections only, and websocket.md names the real config keys. - New tests: an end-to-end inbound withdrawal, the startup-anchor repro from the issue, and concurrent OpenStream calls under -race. Fixes hyperledger-labs#2063 BREAKING CHANGE: websocket.Config.ClientTLSConfig takes no arguments. Implementations and callers of the Config interface must drop the ExtraCAPoolProvider parameter. Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
6c2cb26 to
6034f0e
Compare
Resolves #2063.
What changed
tls.Configbuilt itsClientCAsfrom the extra CAs the provider held at startup.GetConfigForClientrebuilds the pool on every handshake, but once the provider had no entries left it returned that base config, so a peer whose anchor was withdrawn could still connect. The base config now trusts only the configured pool, and the extra CAs come only from the per-handshake rebuild.ClientCAsis ignored when client certificates are not required, and with no provider it was already the bare pool, so no path loses trust.Config.ClientTLSConfig()takes no provider (breaking). The host adds the extra CAs per outbound stream, so the parameter only invited callers to keep a config that never learns about new peers. It also madeGetNewHostparse every resolver certificate for a nil check. Panurus does not use this API.ExtraCAPoolProviderGodoc now says a provider must not modify a slice after returning it, because the client caches and compares it. ThecurrentRootCAsGodoc andwebsocket.mdsay a withdrawal only affects new connections, since multiplexed connections are reused.websocket.mdnow names the real config keys (fsc.p2p.opts.websocket.tls.clientRootCAsand.rootCAs).extraCAsOf, which had one caller left, gavewithExtraCAsits own test, and moved the shared end-to-end test setup into helpers.Tests
TestDynamicCAInboundWithdrawal: two real hosts. After the server's provider drops the client's certificate, a new dial fails withunknown certificate authority. On main the dial succeeds.TestServerTLSConfigClientAuth/anchor known at startup is withdrawn: the repro from the issue.TestClientOpenStreamConcurrentWithChangingExtraCAs: concurrentOpenStreamcalls while the extra CAs change, under-race.go test -race ./platform/view/services/comm/...and golangci-lint pass, andgo fix -diffis clean.Breaking change
websocket.Config.ClientTLSConfigtakes no arguments. Implementations and callers ofConfigmust drop theExtraCAPoolProviderparameter.