Skip to content

Ensure TLS roles are respected during session resumption - #5797

Open
randombit wants to merge 1 commit into
masterfrom
jack/tls-session-mgr-role-respecting
Open

randombit wants to merge 1 commit into
masterfrom
jack/tls-session-mgr-role-respecting

Conversation

@randombit

Copy link
Copy Markdown
Owner

An application which acted as both a TLS server and a TLS client, and which shared a session manager between those two roles, could end up accepting a resumed session that resumed in the wrong role.

@randombit
randombit requested review from reneme and a lite review from Copilot August 4, 2026 12:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens Botan’s TLS session resumption logic against cross-role session confusion when a single Session_Manager instance is shared between a TLS client and TLS server in the same application.

Changes:

  • Enforce connection-side (“role”) checks when resuming sessions on the server side (TLS 1.2 check_for_resume() and TLS 1.3 PSK selection paths).
  • Filter client-side session discovery so that client handshakes won’t be offered server-established sessions.
  • Add/adjust tests to ensure sessions cannot cross the client/server boundary (including PSK resumption cases) and adapt RFC 8448 server tests accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/tests/test_tls_session_manager.cpp Adds multi-Session_Manager regression tests ensuring role separation and updates existing session-manager tests to match new semantics.
src/tests/test_tls_rfc8448.cpp Adjusts RFC 8448 server-side resumption tests to use a server-role Session variant.
src/lib/tls/tls13/tls_extensions_psk.cpp Adds a role check so the server won’t resume using client-role sessions via the PSK resumption path.
src/lib/tls/tls12/tls_server_impl_12.cpp Adds a server-role guard when checking for TLS 1.2 resumption.
src/lib/tls/tls_session_manager.h Documents the new role-based behavior of retrieve() and find().
src/lib/tls/tls_session_manager.cpp Implements role filtering in retrieve() and find_and_filter() to prevent cross-role session use.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/tls/tls_session_manager.cpp

@reneme reneme left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In fact, I would expand on the proposed changes (perhaps in a follow-up), like so:

  1. Extend the documentation of the virtual storage interface methods: It already states that retrieve_one is only called on the server side and likewise find_some only on the client side. Those docstrings should also mention that the methods must filter their outputs accordingly (making the filters introduced in this PR a belt-and-suspenders idiom ensuring that custom session managers don't get funky).
  2. Adapt our TLS::Session_Manager implementations: we provide a bunch of them, and they should filter their outputs accordingly.

As a result, applications that hold both client and server state in the same place should have a much higher chance of actually benefitting from resumption as expected.

Comment thread src/lib/tls/tls_session_manager.cpp
Comment thread src/lib/tls/tls13/tls_extensions_psk.cpp Outdated
Comment thread src/lib/tls/tls12/tls_server_impl_12.cpp
An application which acted as both a TLS server and a TLS client, and
which shared a session manager between those two roles, could end up
accepting a resumed session that resumed in the wrong role.
@randombit
randombit force-pushed the jack/tls-session-mgr-role-respecting branch 2 times, most recently from 7a6839b to ae38c19 Compare September 28, 2026 16:00
@randombit

Copy link
Copy Markdown
Owner Author

Review comments addressed and I extended the SQL and memory session managers to filter their results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants