Skip to content

fix(comm)!: stop the websocket server trusting withdrawn extra CAs - #2069

Merged
SaidAltury-ibm merged 1 commit into
hyperledger-labs:mainfrom
mbrandenburger:fix/2063-websocket-extra-ca-trust
Oct 13, 2026
Merged

SaidAltury-ibm merged 1 commit into
hyperledger-labs:mainfrom
mbrandenburger:fix/2063-websocket-extra-ca-trust

Conversation

@mbrandenburger

Copy link
Copy Markdown
Member

Resolves #2063.

What changed

  • Server trust on withdrawal. The base tls.Config built its ClientCAs from the extra CAs the provider held at startup. GetConfigForClient rebuilds 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. ClientCAs is 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 made GetNewHost parse every resolver certificate for a nil check. Panurus does not use this API.
  • Docs. The ExtraCAPoolProvider Godoc now says a provider must not modify a slice after returning it, because the client caches and compares it. The currentRootCAs Godoc and websocket.md say a withdrawal only affects new connections, since multiplexed connections are reused. websocket.md now names the real config keys (fsc.p2p.opts.websocket.tls.clientRootCAs and .rootCAs).
  • Cleanup. Inlined extraCAsOf, which had one caller left, gave withExtraCAs its 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 with unknown certificate authority. On main the dial succeeds.
  • TestServerTLSConfigClientAuth/anchor known at startup is withdrawn: the repro from the issue.
  • TestClientOpenStreamConcurrentWithChangingExtraCAs: concurrent OpenStream calls while the extra CAs change, under -race.
  • Mutation checks: putting the startup CAs back into the base config fails three tests, and removing the cache lock is caught by the race detector.
  • go test -race ./platform/view/services/comm/... and golangci-lint pass, and go fix -diff is clean.

Breaking change

websocket.Config.ClientTLSConfig takes no arguments. Implementations and callers of Config must drop the ExtraCAPoolProvider parameter.

@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:

  • 6034f0e fix(comm)!: stop the websocket server trusting withdrawn extra CAs

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 #2063 (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 , LGTM

@mergify

mergify Bot commented Oct 13, 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.

@SaidAltury-ibm
SaidAltury-ibm enabled auto-merge (squash) October 13, 2026 08:58
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>
@SaidAltury-ibm
SaidAltury-ibm force-pushed the fix/2063-websocket-extra-ca-trust branch from 6c2cb26 to 6034f0e Compare October 13, 2026 08:58
@SaidAltury-ibm
SaidAltury-ibm merged commit ab2b27b into hyperledger-labs:main Oct 13, 2026
@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 13, 2026
@mbrandenburger
mbrandenburger deleted the fix/2063-websocket-extra-ca-trust branch October 13, 2026 09:28
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 server keeps trusting withdrawn extra CAs, plus #2061 follow-ups

2 participants