Repository navigation
GH-952: Release IdentFilter write queue after forwarding message - #953
Merged
tomaswolf merged 1 commit intoNov 10, 2026
Merged
Conversation
Member
|
Thank you for this contribution! The code looks good, but the commit message should explain a bit more. In real operation, this can happen in an SSH client that has queued its own KEX_INIT already and then receives the peer's KEX_INIT and initializes its |
abhiramaab
force-pushed
the
fix-ident-filter-kexinit-ordering
branch
from
November 10, 2026 01:19
e5fd90f to
65a067a
Compare
Author
|
Thanks @tomaswolf! I've updated the commit message to describe the real-world client KEX_INIT scenario and force-pushed the branch. |
IdentFilter.WriteHandler.send() prematurely released its write queue guard via lastWrite.compareAndSet(result, null) inside the queue.addListener callback before calling owner().send(cmd, message). In real operation, this can happen in an SSH client that has queued its own KEX_INIT already and then receives the peer's KEX_INIT and initializes its Kex object, which sends that first KEX message, all while its own KEX_INIT is still queued. If lastWrite is prematurely reset, that subsequent KEX message bypasses the queue and reaches the output sink before KEX_INIT, violating SSH protocol packet ordering. Move lastWrite.compareAndSet(result, null) after owner().send(...) to ensure the write queue remains guarded until the message is handed off. Add regression test in IdentFilterTest.
tomaswolf
force-pushed
the
fix-ident-filter-kexinit-ordering
branch
from
November 10, 2026 16:52
65a067a to
645bfca
Compare
Member
Thanks, perfect! |
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.
Summary
Fixes #952.
IdentFilter.WriteHandler.send()prematurely released its write queue guard usinglastWrite.compareAndSet(result, null)inside thequeue.addListenercallback, before invokingowner().send(cmd, message).Under concurrent message dispatch, a subsequent call to
send()(e.g.,SSH_MSG_KEX_FIRSTduring key exchange negotiation) could observelastWrite == null, bypass the queue, and reach the output sink beforeSSH_MSG_KEXINIT, violating message ordering.Changes
lastWrite.compareAndSet(result, null)to execute afterowner().send(...)inIdentFilter.java, ensuring the write queue remains guarded until the current message is handed off.concurrentSendDuringKexInitDoesNotOvertakeinIdentFilterTest.javato verify that messages queued during identification and KEXINIT processing cannot overtake each other.Verification
./mvnw test -pl sshd-core -Dtest=IdentFilterTestpasses.checkstyle:check,formatter:validate, andimpsort:check.All checks passed with 0 violations.