Skip to content

examples: check host keys against known_hosts - #1386

Merged
philljj merged 6 commits into
wolfSSL:masterfrom
ejohnstown:example-hostkey-check
Nov 21, 2026
Merged

philljj merged 6 commits into
wolfSSL:masterfrom
ejohnstown:example-hostkey-check

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

The example clients, portfwd and tpmcertclient refuse a host key that
~/.ssh/known_hosts does not hold, printing the line to add; -Y accepts
any key with a warning. Stacked on #1385; only the last three commits
are new here.

  • an x509v3 host certificate must name the host; -X waives a mismatch
  • tests and CI pass -Y; client-hostkey.test covers unknown, known,
    stale and changed keys

Issue: F-7620, F-10587, F-10588

@ejohnstown
ejohnstown force-pushed the example-hostkey-check branch 2 times, most recently from 3470a73 to a89c603 Compare November 11, 2026 22:49
@ejohnstown

Copy link
Copy Markdown
Contributor Author

@claude review

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings marked 🟡 are optional suggestions and need no follow-up push.

Comment thread examples/client/common.c Resolved
Comment thread examples/client/common.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1386

Scan targets checked: wolfssh-src, wolfssh-bugs
Not reviewed (no scan target covers them): .github/workflows/interop-mlkem.yml, .github/workflows/network-contention-test.yml, .github/workflows/scp-test.yml, .github/workflows/sftp-test.yml, .github/workflows/test-fatfs.yml, .github/workflows/tpm-ssh.yml, .github/workflows/windows-cert-store-test.yml, .github/workflows/windows-sftp.yml, README.md, apps/wolfssh-options.c, apps/wolfsshd/test/error_return.sh, apps/wolfsshd/test/run_all_sshd_tests.sh, apps/wolfsshd/test/sshd_authkeys_none_test.sh, apps/wolfsshd/test/sshd_bad_sftp_test.sh, apps/wolfsshd/test/sshd_chroot_fail_test.sh, apps/wolfsshd/test/sshd_chroot_none_test.sh, apps/wolfsshd/test/sshd_empty_password_test.sh, apps/wolfsshd/test/sshd_exec_test.sh, apps/wolfsshd/test/sshd_forcedcmd_test.sh, apps/wolfsshd/test/sshd_fork_fail_test.sh and 38 more
Coverage: 11 of 11 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1386

Scan targets checked: wolfssh-src, wolfssh-bugs
Not reviewed (no scan target covers them): .github/workflows/interop-mlkem.yml, .github/workflows/network-contention-test.yml, .github/workflows/scp-test.yml, .github/workflows/sftp-test.yml, .github/workflows/test-fatfs.yml, .github/workflows/tpm-ssh.yml, .github/workflows/windows-cert-store-test.yml, .github/workflows/windows-sftp.yml, README.md, apps/wolfssh-options.c, apps/wolfsshd/test/error_return.sh, apps/wolfsshd/test/run_all_sshd_tests.sh, apps/wolfsshd/test/sshd_authkeys_none_test.sh, apps/wolfsshd/test/sshd_bad_sftp_test.sh, apps/wolfsshd/test/sshd_chroot_fail_test.sh, apps/wolfsshd/test/sshd_chroot_none_test.sh, apps/wolfsshd/test/sshd_empty_password_test.sh, apps/wolfsshd/test/sshd_exec_test.sh, apps/wolfsshd/test/sshd_forcedcmd_test.sh, apps/wolfsshd/test/sshd_fork_fail_test.sh and 38 more
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Lite

Comment thread examples/client/common.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1386

Scan targets checked: wolfssh-src, wolfssh-bugs
Not reviewed (no scan target covers them): .github/workflows/interop-mlkem.yml, .github/workflows/network-contention-test.yml, .github/workflows/scp-test.yml, .github/workflows/sftp-test.yml, .github/workflows/test-fatfs.yml, .github/workflows/tpm-ssh.yml, .github/workflows/windows-cert-store-test.yml, .github/workflows/windows-sftp.yml, README.md, apps/wolfssh-options.c, apps/wolfsshd/test/error_return.sh, apps/wolfsshd/test/run_all_sshd_tests.sh, apps/wolfsshd/test/sshd_authkeys_none_test.sh, apps/wolfsshd/test/sshd_bad_sftp_test.sh, apps/wolfsshd/test/sshd_chroot_fail_test.sh, apps/wolfsshd/test/sshd_chroot_none_test.sh, apps/wolfsshd/test/sshd_empty_password_test.sh, apps/wolfsshd/test/sshd_exec_test.sh, apps/wolfsshd/test/sshd_forcedcmd_test.sh, apps/wolfsshd/test/sshd_fork_fail_test.sh and 38 more
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer

No new issues found in the changed files.

💬 1 finding(s) from an earlier review are still open and were not re-posted:

  • Host certificate name check is chosen by the server's key-type label, not the negotiated algorithm — examples/client/common.c:698

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Lite

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1386

Scan targets checked: none
Unchanged since last review (not re-run): wolfssh-src, wolfssh-bugs
Not reviewed (no scan target covers them): .github/workflows/interop-mlkem.yml, .github/workflows/network-contention-test.yml, .github/workflows/scp-test.yml, .github/workflows/sftp-test.yml, .github/workflows/test-fatfs.yml, .github/workflows/tpm-ssh.yml, .github/workflows/windows-cert-store-test.yml, .github/workflows/windows-sftp.yml, README.md, apps/wolfssh-options.c, apps/wolfsshd/test/error_return.sh, apps/wolfsshd/test/run_all_sshd_tests.sh, apps/wolfsshd/test/sshd_authkeys_none_test.sh, apps/wolfsshd/test/sshd_bad_sftp_test.sh, apps/wolfsshd/test/sshd_chroot_fail_test.sh, apps/wolfsshd/test/sshd_chroot_none_test.sh, apps/wolfsshd/test/sshd_empty_password_test.sh, apps/wolfsshd/test/sshd_exec_test.sh, apps/wolfsshd/test/sshd_forcedcmd_test.sh, apps/wolfsshd/test/sshd_fork_fail_test.sh and 38 more

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed stale reviews from themself November 12, 2026 17:37

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

@ejohnstown
ejohnstown force-pushed the example-hostkey-check branch 2 times, most recently from 52a959a to e14beae Compare November 18, 2026 16:55
@philljj philljj self-assigned this Nov 19, 2026
Comment thread examples/client/common.c Resolved
@ejohnstown
ejohnstown force-pushed the example-hostkey-check branch 2 times, most recently from 16e7180 to fdd0e30 Compare November 19, 2026 21:19
@ejohnstown
ejohnstown requested a review from philljj November 20, 2026 22:06
The client, scpclient and sftpclient accept a plain host key only when
a "host type key" line of ~/.ssh/known_hosts holds it. An unknown or
changed key is refused, printing its fingerprint and the line to add.
-Y accepts any key, with a warning.

- Check that an x509v3 host certificate names the host by DNS or IP
  subjectAltName, or by common name without one; -X waives a mismatch
- Pass -Y in the tests and CI jobs that connect to a throwaway server
- Seed known_hosts for openssh-interop.test from sshd's host keys
- Add client-hostkey.test for unknown, known, stale and changed keys

Issue: F-7620
portfwd links the example client's common code and registers its host
key check, with the SSH server's host name as the context. -Y accepts
any key, with a warning.

- Pass -Y in fwd.test and fwd-bulk.test
- Cover a refused unknown key in client-hostkey.test

Issue: F-10587
tpmcertclient links the example client's common code and registers its
host key check, with the -h host as the context. The library verifies
the chain to the -A CA; the check requires the leaf to name the host.

- Test the name check in testsuite.test with keys/ certificates
- Add a tpm-ssh job refusing the certificate when asked for localhost

Issue: F-10588
The test quoted the whole wolfsftp command line as one word, so the
shell found no such program and its exit status 127 passed as the
expected refusal. Quote each argument instead, and fail when the client
can't be run.
The plain host key parsers check the blob's name against the negotiated
algorithm; the certificate parsers skipped it. A server could then name
a certificate as a plain key, and a host key callback that reads the
name, as the example clients do, never checked it against the host.

- Test a misnamed chain in test_ParseECCPubKeyCert, and name the P-384
  curve mismatch case for P-384
ClientPublicKeyCheck() takes a ClientHostCtx with the port as well as
the host. Off port 22 it looks up [host]:port, as OpenSSH writes it,
and takes a bare host line only when no [host]:port line has a key of
that type. The refusal prints the [host]:port line to add.

- a name field may be a comma list or a hashed |1|salt|hash name
- client, scpclient, sftpclient, portfwd and tpmcertclient pass the port
- client-hostkey.test covers port, fallback, comma and hashed names

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1386

Scan targets checked: wolfssh-src, wolfssh-bugs
Not reviewed (no scan target covers them): .github/workflows/interop-mlkem.yml, .github/workflows/network-contention-test.yml, .github/workflows/scp-test.yml, .github/workflows/sftp-test.yml, .github/workflows/test-fatfs.yml, .github/workflows/tpm-ssh.yml, .github/workflows/windows-cert-store-test.yml, .github/workflows/windows-sftp.yml, README.md, apps/wolfssh-options.c, apps/wolfsshd/test/error_return.sh, apps/wolfsshd/test/run_all_sshd_tests.sh, apps/wolfsshd/test/sshd_authkeys_none_test.sh, apps/wolfsshd/test/sshd_bad_sftp_test.sh, apps/wolfsshd/test/sshd_chroot_fail_test.sh, apps/wolfsshd/test/sshd_chroot_none_test.sh, apps/wolfsshd/test/sshd_empty_password_test.sh, apps/wolfsshd/test/sshd_exec_test.sh, apps/wolfsshd/test/sshd_forcedcmd_test.sh, apps/wolfsshd/test/sshd_fork_fail_test.sh and 37 more
Coverage: 9 of 11 in-scope changed file(s) opened by the reviewer; not opened: examples/portfwd/portfwd.c, tests/sftp.c

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@philljj
philljj merged commit 49b90dc into wolfSSL:master Nov 21, 2026
222 checks passed
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.

4 participants