fix: close host key fail-open paths - #259
Merged
Merged
Conversation
Keep accept-new from degrading to unchecked verification when no default known_hosts path can be determined by adding process-lifetime host key pinning. Fail closed when an existing known_hosts path is unreadable or not a regular file, protect check-then-record with an advisory lock file, and make unsupported @cert-authority handling configurable with a reject policy. Validation: CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --lib ssh::tokio_client::host_verification; CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo check --lib --tests; CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo clippy --lib --tests -- -D warnings. Closes #242
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
Close the remaining accept-new host key verification fail-open paths by keeping process-local pins when persistent trust state is unavailable, failing closed for unusable known_hosts files, and serializing file-backed TOFU updates with an advisory lock.
What changed
AcceptNewInMemoryso the defaultaccept-newmode no longer falls back to unconditionalNoCheckwhen no default known_hosts path can be determined.@cert-authoritylines configurable withBSSH_CERT_AUTHORITY_POLICY=rejectwhile preserving the existing warn-and-TOFU default.docs/architecture/ssh-client.mdto state the actual host key guarantees.Test plan
CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --lib ssh::tokio_client::host_verificationCARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo check --lib --testsCARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo clippy --lib --tests -- -D warningsCloses #242