Fix known_hosts port-aware matching and negation veto semantics - #73
Merged
supermarsx merged 1 commit intoJul 15, 2026
Conversation
supermarsx
deleted the
smx/propose-fix-for-known_hosts-security-vulnerability-2026-07-15
branch
July 15, 2026 22:15
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.
Motivation
Description
KnownHosts::verifyto useformat_host(host, port)so exact plaintext entries match only the port-correct form.host_matchesto evaluate patterns only against the port-aware candidate (viaformat_host) while preserving the two-pass negation-veto semantics.verify_hashedto HMAC the port-aware candidate so hashed entries no longer match across ports.bare_host_does_not_match_nonstandard_port,negation_vetoes_nonstandard_port_bracket_pattern, andhashed_bare_host_does_not_match_nonstandard_portto cover the fixed cases.Testing
cargo fmt --check, which succeeded.cargo test -p spt-trust known_hosts::tests, and theknown_hostsunit suite passed (all included tests succeeded).cargo test -p spt-trustwhere theknown_hoststests passed but the full crate test run was interrupted due to environment-dependent CRL/network tests stalling; those unrelated tests did not affect theknown_hostsregression coverage.Codex Task