fix: resolve server panic and auth failure on client connection#185
Merged
fix: resolve server panic and auth failure on client connection#185
Conversation
Fix two bugs that caused bssh-server to crash or reject authenticated clients on every incoming connection: 1. block_on panic in async runtime: new_client_with_addr (sync trait) called Handle::block_on(is_banned()) inside the tokio runtime, triggering "Cannot start a runtime from within a runtime". Replaced with a non-blocking try_is_banned() using RwLock::try_read(). 2. Session not registered with SessionManager: All SshHandler constructors initialized session_info with a local SessionInfo that was never inserted into SessionManager's sessions map. This caused authenticate_session() to return SessionNotFound after successful key/password verification. Fixed by initializing session_info as None and creating sessions through SessionManager during auth.
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.
Summary
Fix two critical bugs that caused
bssh-serverto crash or reject every client connection since v2.0.1:Panic on connect:
new_client_with_addrcalledblock_on()inside the tokio async runtime to check the auth rate limiter ban list, causing an immediate panic ("Cannot start a runtime from within a runtime"). AddedAuthRateLimiter::try_is_banned()using non-blockingRwLock::try_read().Auth success → reject: All
SshHandlerconstructors created a localSessionInfothat was never registered withSessionManager. After pubkey/password verification succeeded,authenticate_session()returnedSessionNotFound, rejecting the client. Fixed by deferring session creation to the auth flow viaSessionManager::create_session().Test plan