Conversation
Contributor
Author
|
Closing, see #1823 |
vlastee
pushed a commit
to vlastee/SSH.NET
that referenced
this pull request
Sep 25, 2026
SendMessage checked the key exchange wait handle before acquiring the socket write lock. When a server-initiated re-exchange started in that window, the client's SSH_MSG_KEXINIT could be sent first, after which the already in-flight data message violated RFC 4253 section 7.1. Strict servers (e.g. ProFTPD mod_sftp) then fail the exchange or drop the connection. SendMessage now re-checks the wait handle while holding the write lock and goes back to waiting when a re-exchange has started in the meantime. The packet is also built entirely under the write lock, so a completing re-exchange can no longer swap the client cipher, MAC or compression state in the middle of building a packet. The race does not reproduce against the OpenSSH test server (which is why the attempt in sshnet#1774 stayed green): OpenSSH queues non key exchange output while a re-exchange is in progress and tolerates the client data that slips in. ProFTPD mod_sftp does not, so this adds an integration test which reproduces the failure with concurrent SFTP uploads against a ProFTPD server configured to re-key every 1 MB. Without the fix the test failed 7 out of 8 runs; with it, it passes consistently. Fixes sshnet#1764.
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.
No description provided.