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

Add russh::server::run_on_socket to facilitate dropping privileges immediately after socket binding #231

Merged
merged 1 commit into from
Jan 26, 2024

Conversation

samuela
Copy link
Contributor

@samuela samuela commented Jan 24, 2024

Securing SSH servers is not straightforward. Most state-of-the-art systems utilize privilege dropping after they bind to a socket in order to minimize their attack surface, including OpenSSH. Currently russh does not support this pattern since socket binding and the main server event loop are tied to a single function, russh::server::run.

This PR introduces a function russh::server::run_on_socket which is identical to russh::server::run except that it accepts a tokio::net::TcpListener in place of a socket address, allowing end-users to bind to a socket and perform other intermediate actions before handing over control to the main server event loop. russh::server::run's behavior is left untouched, so the change is fully backwards compatible.

@Eugeny
Copy link
Member

Eugeny commented Jan 26, 2024

Thank you!

@all-contributors add @samuela for code

@Eugeny Eugeny merged commit 273fd88 into warp-tech:main Jan 26, 2024
4 checks passed
Copy link
Contributor

@Eugeny

I've put up a pull request to add @samuela! 🎉

@samuela samuela deleted the samuela/run_on_socket branch January 26, 2024 13:56
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

Successfully merging this pull request may close these issues.

None yet

2 participants