Skip to content

Race conditions between creating and sending messages #1115

Open

Description

@yieldi

I get a lot of "Received ieof for nonexistent channel" messages sent from openSSH server when connecting as paramiko client. These messages are due to an EOF being sent after already closing the channel it is sent on. It results in the entire transport being shutdown.

The root cause is a race condition when closing a connection and a shutdown_write in Channel:

shutdown_write                      close
------                              -----
lock()
m = create EOF msg
unlock()
                                      lock()
                                      internal_close
                                      m1 = create shutdown msg # (None because already created)
                                      m2 = close message
                                      unlock()
                                      send m1, m2  # (None, close)
send m # (EOF)

By putting an extra lock around the close, shutdown, _request_failed, and _handle_close I don't see the issue anymore. However, I think it is still possible to have race conditions between send and close (create a message to send, then close is interleaved, then send the send message).

However, it seems like there was a good reason that locks like that didn't exist in the first place what ideas do you have for fixing the race condition?

Activity

  1. DavidQing commented on Jun 15, 2023

    @DavidQing

    Hi, I have been using paramiko-ng but it currently don't support Jammy Jellyfish due to rsa-sha2-256 and rsa-sha2-512 change. I want to switch back to paramiko but this bug is still causing failures.
    Is there a way to pull in the changes in ploxiln#101 to paramiko?
    Thanks

  2. bskinn commented on Jun 25, 2023

    @bskinn
    Contributor

    Looks like #1137 was the original inspiration for the work in ploxiln#101.

    @DavidQing, bitprophet is in the middle of modernizing the key/auth systems (see #387 #23), which will be occupying much of his paramiko time for a while, spanning the next couple of minor releases.

    This seems like something of great enough a magnitude that it will have to wait until after the key/auth work is done. So, it will likely be some months before this can be addressed. The fact that #1137 is available will hopefully speed this one up.

    Keep an eye on this issue for activity; and, if you have any additional information about the details of the race condition, please add them to the thread here.

  3. sdodsley commented on Dec 19, 2023

    @sdodsley

    @bskinn any news on when this will be resolved?

  4. nmorad commented on Jan 20, 2025

    @nmorad

    @bskinn Any updates on this bug?

  5. AlonMarko commented on Nov 3, 2025

    @AlonMarko

    @bskinn
    is there an update on this bug atm?

  6. bskinn commented on Nov 3, 2025

    @bskinn
    Contributor

    Hi all, apologies for the slow reply. No updates, unfortunately, bitprophet has been in a prolonged run with time to spare only for significant security fixes.

    Thank you for posting to indicate that the issue is still relevant, it will help prioritize when the time comes.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions