Skip to content

wolfssh: decide known hosts the way OpenSSH asks - #1385

Open
ejohnstown wants to merge 1 commit into
wolfSSL:masterfrom
ejohnstown:known-hosts-check
Open

ejohnstown wants to merge 1 commit into
wolfSSL:masterfrom
ejohnstown:known-hosts-check

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

The wolfssh client follows StrictHostKeyChecking=ask: a missing or empty
known_hosts prompts, an unreadable one or EOF at the prompt refuses, and
a matching line accepts wherever it is in the file.

  • size the host key buffer from the blob, so ML-DSA keys fit
  • check the certificate IP only after known_hosts accepts

Issue: F-14635, F-15505, F-15508, F-15664

@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.

I reviewed this PR and didn't find any bugs. It changes how the client decides whether to trust a server's host key, so a human look would still be worthwhile.

What was reviewed:

  • The load_text_file result handling: a missing or empty known_hosts prompts, and an unreadable one refuses. An unset HOME now sets ret = -1.
  • The encSz sizing (pubKeySz+2)/3*4+1, including the MAX_PACKET_SZ bound and the type/fingerprint offsets; the scan now breaks on a match, and the client rejects only on badMatch && !found.
  • The cert IP check now runs only when ret == 0, so the IP override can no longer clear an earlier rejection. MakeParentDir creates only the last directory, with mode 0700, and the open is retried.
Extended reasoning...

The change rewrites the host key verification path in apps/wolfssh/common.c. It covers known_hosts parsing, the trust-on-first-use prompt, how a stale or mismatched entry is resolved, and the certificate IP override. It also creates ~/.ssh when it is missing. Host key verification is an authentication decision, so mistakes here can enable MITM acceptance. That alone puts it above the bar for auto-approval. The new shell and regress tests cover the ask, EOF, stale-entry and ML-DSA-87 cases, but no tests were run in this review.

@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 #1385

Scan targets checked: wolfssh-src, wolfssh-bugs
Not reviewed (no scan target covers them): scripts/sshclient.test
Coverage: 2 of 2 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

ClientPublicKeyCheck() follows StrictHostKeyChecking=ask. A missing or
empty known_hosts has no entries and prompts, creating ~/.ssh with mode
0700 on yes; one it cannot read refuses, as does EOF at the prompt. A
line holding the key accepts wherever it is in the file.

- Size the base64 host key buffer from the blob, so ML-DSA keys fit
- Keep scanning past a stale same-type line for the host
- Check the certificate IP only once known_hosts accepts, and let the
  override waive only the IP mismatch
- Cover these in regress.test and sshclient.test

Issue: F-14635, F-15505, F-15508, F-15664
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.

3 participants