Skip to content

echoserver: wipe and bound the key load buffer - #1340

Open
ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:echo-keyload
Open

ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:echo-keyload

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

The echoserver's key load buffer held host private keys but was wiped
only in small-stack builds, and the key list parse could read past it.

  • KeyLoadBufFree() wipes the buffer in every build, and the ML-DSA key
    buffer is wiped before each free.
  • LoadPublicKeyBuffer() searches for delimiters only within the buffer.
  • The sample key lists are copied in only when they fit.

Issue: F-8859, F-10605, F-10600, F-10565, F-14765

keyLoadBuf held host private keys but was wiped only under
WOLFSSH_SMALL_STACK. KeyLoadBufFree() now wipes it in every build and
frees it only when it came from the heap.

- Route every keyLoadBuf exit through KeyLoadBufFree()
- Wipe the ML-DSA key buffer in LoadMlDsaHostKeys() before each free

Issue: F-8859, F-10605
LoadPublicKeyBuffer() searches for its delimiters only up to the end
of the buffer, so a -j file without a final newline is rejected
instead of read past. The sample password, public key, and none lists
are copied into keyLoadBuf only when they fit.

- Add FindDelimiter() in place of the unbounded WSTRCHR() calls
- Add CopyToKeyLoadBuf(), which refuses a string with no room for its
  terminator and still accepts an empty one
- Warn when a -j file's keys are not all loaded
- Fix the comment claiming every sample key is ssh-rsa

Issue: F-10600, F-10565, F-14765
Copilot AI balanced review requested due to automatic review settings October 22, 2026 20:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Scan targets checked: wolfssh-src, wolfssh-bugs
Coverage: 1 of 1 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: Lite

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