Properly handle SSL handshake updates#1885
Merged
cshannon merged 1 commit intoapache:mainfrom Apr 8, 2026
Merged
Conversation
Handle different handshake state changes in NIOSSL transports
jbonofre
approved these changes
Apr 8, 2026
This was referenced Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Handle different handshake state changes in NIOSSL transports
Edit:
Here is some more info on the fixes now that CVE-2026-39304 is published:
The quick version is this was a bug related to if a client requests a key update or handshake renegotiation depending on TLS version. The code was not handling the
NEED_WRAP,NEED_TASKorFINISHEDstatus correctly during renegotiation which can cause issues including OOM or stuck connections depending on the TLS version used. The code assumed after the initial handshake was done that was it. The updates here now correctly detect those states after the initial handshake and process.Summary of issues/changes:
NEED_WRAPand the server needs to respond by calling wrap(), even if there is no application data to send because that triggers the background handshake data to be sent to the client. Our NIO SSL code previously didn't check for this, so wrap() was only called if there was application data to publish back (ie messages to send or heart beats etc). If wrap() is never called (no app data, no heart beating) this can lead to updates building up in memory if a lot of updates are sent by a client.NEED_TASKstatus, which is also never handled. So on a TLSv1.2 connection there is no leak but the transport/connection is just stuck and can't do anything. The update now correctly processesNEED_TASKNEED_UNWRAP, but handshake updates can happen concurrently with application data. This means it's possible for the broker to receive data that needs to be processed while the handshake status state isNEED_UNWRAP. Before this update, it would skip processing any data in the buffer if the state wasNEED_UNWRAPwhich was incorrect.FINISHED, we need to advance the state toNOT_HANDSHAKINGand trigger one more read to see if there is more data to process.