Skip to content

Resource overrun in server::Handle::data() #725

Description

@dsche

We have observed a rather worrying memory exhaustion behaviour in russh==0.61, triggered by the following use case:

  1. Create a Server that listens to connections.
  2. On a new connection, grab a session.handle(), and pump it with data (something that can happen if SSH is used to proxy data transfers).
  3. Observe that even if handle.data(channel, response).await returns, this is not a guarantee that the output buffer is flushed or even limited. In our case, we have attempted to transfer ~3GiB worth of data, all of which ended up in memory, potentially leading into OOMs.

Our conjecture is that the culprit is server::Session::data() hands the data directly off to Encryped::data_with_writer(), which, inturns, executes channel.pending_data.push_back((buf0, None, 0));. channel.pending_data is an unbounded VecDeque, with no checks on its maximum size, and this applies no backpressure on the sender.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions