GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Include TrustManager / KeyManager instances in TLS session id context computations by chrisvest · Pull Request #18256 · netty/netty

Conversation

@chrisvest

@chrisvest chrisvest commented Nov 3, 2026

Copy link
Copy Markdown
Member

Motivation:

The session_id_context fix for GHSA-6xv6-9mgg-mfvc derived the session_id_context from the ClientAuth mode, the certificate chain and the trusted certificates. Configurations backed by a TrustManagerFactory, KeyManagerFactory, TrustManager or KeyManager can not be digested, so a random salt was mixed in for them. That kept them safe, but it also meant sessions could never be resumed between two contexts built from the very same TrustManager / KeyManager objects, such as SNI virtual hosts or a context that is rebuilt to reload certificates.

Comparing such objects by System.identityHashCode is not safe, as identity hash codes are not unique, and a collision would let a session be resumed on a context with a different trust configuration.

Modifications:

  • Add SecureObjectIdentityHash, which associates 256 bits of SecureRandom entropy with the identity of an object, for as long as the object is alive. It uses a new WeakIdentityHashMap, as the JDK has no map with both weak keys and identity semantics (at least not in its public API).
  • Add SessionIdContextBuilder, which digests (SHA-256) a domain separation seed, the ClientAuth mode, the installed OpenSslCredentials, the local identity material (key and certificate chain, or the identity of the KeyManagerFactory / KeyManager) and the trust material (trusted certificates, or the identity of the TrustManagerFactory / TrustManager). When a plain TrustManager / KeyManager is configured, its identity is used instead of the identity of the wrapper factory the builder creates for it, so configuring the same manager twice gives the same result.
  • Let SslContextBuilder and QuicSslContextBuilder record the configured material in a SessionIdContextBuilder, and pass it on to ReferenceCountedOpenSslServerContext, OpenSslServerContext and QuicheQuicSslContext, which use it to set the session_id_context.
  • Contexts created through the deprecated SslContext.newServerContext(...) methods and OpenSslServerContext constructors use a random session_id_context, as before.
  • Deprecate the protected-static SslContext.deriveSessionIdContext(...), which is replaced by SessionIdContextBuilder.
  • Add tests for WeakIdentityHashMap, using IdentityHashMap as an oracle for randomized tests and checking that keys are weakly held, and for SecureObjectIdentityHash.

Result:

Sessions can be resumed between server contexts in the same JVM that use the same TrustManager / KeyManager (or factory) instances and are otherwise configured identically. Contexts that differ in ClientAuth mode, trust or key configuration still get distinct session_id_context values.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@chrisvest
Include TrustManager / KeyManager instances in TLS session id context…
b6c6a69
… computations

Motivation:

The session_id_context fix for GHSA-6xv6-9mgg-mfvc derived the
session_id_context from the `ClientAuth` mode, the certificate chain and the
trusted certificates. Configurations backed by a `TrustManagerFactory`,
`KeyManagerFactory`, `TrustManager` or `KeyManager` can not be digested, so a
random salt was mixed in for them. That kept them safe, but it also meant
sessions could never be resumed between two contexts built from the very
same `TrustManager` / `KeyManager` objects, such as SNI virtual hosts or a
context that is rebuilt to reload certificates.

Comparing such objects by `System.identityHashCode` is not safe, as identity
hash codes are not unique, and a collision would let a session be resumed
on a context with a different trust configuration.

Modifications:

- Add `SecureObjectIdentityHash`, which associates 256 bits of `SecureRandom`
  entropy with the identity of an object, for as long as the object is
  alive. It uses a new `WeakIdentityHashMap`, as the JDK has no map with both
  weak keys and identity semantics (at least not in its public API).
- Add `SessionIdContextBuilder`, which digests (SHA-256) a domain separation
  seed, the `ClientAuth` mode, the installed `OpenSslCredentials`, the local
  identity material (key and certificate chain, or the identity of the
  `KeyManagerFactory` / `KeyManager`) and the trust material (trusted
  certificates, or the identity of the `TrustManagerFactory` / `TrustManager`).
  When a plain `TrustManager` / `KeyManager` is configured, its identity is used
  instead of the identity of the wrapper factory the builder creates for it,
  so configuring the same manager twice gives the same result.
- Let `SslContextBuilder` and `QuicSslContextBuilder` record the configured
  material in a `SessionIdContextBuilder`, and pass it on to
  `ReferenceCountedOpenSslServerContext`, `OpenSslServerContext` and
  `QuicheQuicSslContext`, which use it to set the `session_id_context`.
- Contexts created through the deprecated `SslContext.newServerContext(...)`
  methods and `OpenSslServerContext` constructors use a random
  `session_id_context`, as before.
- Deprecate the protected-static `SslContext.deriveSessionIdContext(...)`, which is replaced by
  `SessionIdContextBuilder`.
- Add tests for `WeakIdentityHashMap`, using `IdentityHashMap` as an oracle for
  randomized tests and checking that keys are weakly held, and for
  `SecureObjectIdentityHash`.

Result:

Sessions can be resumed between server contexts in the same JVM that use
the same `TrustManager` / `KeyManager` (or factory) instances and are otherwise
configured identically. Contexts that differ in `ClientAuth` mode, trust or
key configuration still get distinct `session_id_context` values.
@chrisvest chrisvest added this to the 4.2.21.Final milestone Nov 3, 2026
@chrisvest
chrisvest requested a review from normanmaurer November 3, 2026 23:59
@chrisvest chrisvest added the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Nov 3, 2026
@chrisvest
chrisvest requested a review from franz1981 November 4, 2026 00:01
@chrisvest

chrisvest commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@franz1981 The algorithm used in WeakIdentityHashMap might be kinda sparse. I'm wondering if I should implement a denser one, perhaps like what I did in https://codeberg.org/chrisvest/stormpot/src/branch/main/src/main/java/stormpot/internal/IdentityHashSet.java

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@testlens-app

testlens-app Bot commented Nov 4, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: b6c6a69
▶️ Tests: 175608 executed
⚪️ Checks: 28/28 completed


Learn more about TestLens at testlens.app/docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest
chrisvest merged commit 8a3e299 into netty:4.2 Nov 5, 2026
29 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest
chrisvest deleted the 4.2-tls-session-id-context branch November 5, 2026 18:12
@chrisvest

chrisvest commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

5.0 port #18283

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest chrisvest removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Nov 5, 2026
@netty-project-bot netty-project-bot mentioned this pull request Nov 5, 2026
Auto-port 5.0: Include TrustManager / KeyManager instances in TLS session id context computations #18284
Closed
@netty-project-bot

netty-project-bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #18284

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chrisvest added a commit that referenced this pull request Nov 5, 2026
@chrisvest
Port 5.0: Include TrustManager / KeyManager instances in TLS session …
71e59e3
…id context computations (#18256) (#18283)

Motivation:

The session_id_context fix for GHSA-6xv6-9mgg-mfvc derived the
session_id_context from the `ClientAuth` mode, the certificate chain and
the trusted certificates. Configurations backed by a
`TrustManagerFactory`, `KeyManagerFactory`, `TrustManager` or
`KeyManager` can not be digested, so a random salt was mixed in for
them. That kept them safe, but it also meant sessions could never be
resumed between two contexts built from the very same `TrustManager` /
`KeyManager` objects, such as SNI virtual hosts or a context that is
rebuilt to reload certificates.

Comparing such objects by `System.identityHashCode` is not safe, as
identity hash codes are not unique, and a collision would let a session
be resumed on a context with a different trust configuration.

Modifications:

- Add `SecureObjectIdentityHash`, which associates 256 bits of
`SecureRandom` entropy with the identity of an object, for as long as
the object is alive. It uses a new `WeakIdentityHashMap`, as the JDK has
no map with both weak keys and identity semantics (at least not in its
public API).
- Add `SessionIdContextBuilder`, which digests (SHA-256) a domain
separation seed, the `ClientAuth` mode, the installed
`OpenSslCredentials`, the local identity material (key and certificate
chain, or the identity of the `KeyManagerFactory` / `KeyManager`) and
the trust material (trusted certificates, or the identity of the
`TrustManagerFactory` / `TrustManager`). When a plain `TrustManager` /
`KeyManager` is configured, its identity is used instead of the identity
of the wrapper factory the builder creates for it, so configuring the
same manager twice gives the same result.
- Let `SslContextBuilder` and `QuicSslContextBuilder` record the
configured material in a `SessionIdContextBuilder`, and pass it on to
`ReferenceCountedOpenSslServerContext`, `OpenSslServerContext` and
`QuicheQuicSslContext`, which use it to set the `session_id_context`.
- Contexts created through the deprecated
`SslContext.newServerContext(...)` methods and `OpenSslServerContext`
constructors use a random `session_id_context`, as before.
- Deprecate the protected-static
`SslContext.deriveSessionIdContext(...)`, which is replaced by
`SessionIdContextBuilder`.
- Add tests for `WeakIdentityHashMap`, using `IdentityHashMap` as an
oracle for randomized tests and checking that keys are weakly held, and
for `SecureObjectIdentityHash`.

Result:

Sessions can be resumed between server contexts in the same JVM that use
the same `TrustManager` / `KeyManager` (or factory) instances and are
otherwise configured identically. Contexts that differ in `ClientAuth`
mode, trust or key configuration still get distinct `session_id_context`
values.
@lhotari lhotari mentioned this pull request Nov 17, 2026
[improve][build] Upgrade Netty to 4.2.21.Final to restore the aarch64 glibc floor and pick up bug fixes apache/pulsar#27654
Merged
1 of 11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@normanmaurer normanmaurer Awaiting requested review from normanmaurer
@franz1981 franz1981 Awaiting requested review from franz1981

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.2.21.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@chrisvest @netty-project-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.