Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SshChannel leak via long living cancellation arg of OpenChannelAsync() #79

Open
IlyaBiryukov opened this issue Sep 6, 2023 · 0 comments
Assignees

Comments

@IlyaBiryukov
Copy link
Contributor

SshSession.OpenChannelAsync() registers a callback on its cancellation argument like this:

if (cancellation.CanBeCanceled)
{
	cancellation.Register(() => completionSource.TrySetCanceled());
	cancellation.ThrowIfCancellationRequested();
}

The callback registration is never disposed of.

If OpenChannelAsync() is successful, completionSource will reference the opened SshChannel and the SshSession. If the cancellation argument is long living, it'll root them after OpenChannelAsync() is done, potentially causing a memory leak.

There are several other places in C# SSH library with a similar pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant