Repository navigation
Read secret files through unbuffered streams - #1365
Open
ejohnstown wants to merge 1 commit into
Open
ejohnstown wants to merge 1 commit into
ejohnstown wants to merge 1 commit into
Conversation
ReadFileIntoBuffer and the wolfsshd host-key and /etc/shadow readers turn off stdio buffering right after open, so those secrets are read straight into wolfSSH's own buffers instead of being staged in a libc FILE buffer that fclose frees without wiping. Public-key lists stay buffered. - port.h: add WFSETNOBUF, setvbuf(_IONBF) for stdio ports, a no-op elsewhere - wolfsshd: add wolfSSHD_OpenSecretFile, the unbuffered secure open - test_configuration: the secret open reads no further than asked, the secure open reads ahead Issue: F-14689, F-14690
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the secret-file buffering changes.
No open issues 🎉
What changed in this PR
This PR disables stdio buffering when wolfSSH reads secret files, reducing the risk of leaving secret data in libc buffers freed without wiping.
Changes:
- Adds
WFSETNOBUF, with a no-op fallback for non-stdio ports. - Uses unbuffered streams for library file loading, daemon host private keys, and
/etc/shadow. - Adds tests verifying that secret streams avoid read-ahead while public-file streams retain buffering.
| File | Description |
|---|---|
wolfssh/port.h |
Adds the portable WFSETNOBUF macro. |
src/ssh.c |
Disables buffering before reading files into memory. |
apps/wolfsshd/wolfsshd.c |
Routes host private keys through the secret-file opener. |
apps/wolfsshd/test/test_configuration.c |
Tests secret and public stream read-ahead behavior. |
apps/wolfsshd/auth.h |
Declares the secret-file opening helper. |
apps/wolfsshd/auth.c |
Implements the helper and uses it for shadow-file reads. |
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1365
Scan targets checked: wolfssh-src, wolfssh-bugs
Not reviewed (no scan target covers them): apps/wolfsshd/auth.h
Coverage: 4 of 5 in-scope changed file(s) opened by the reviewer; not opened: apps/wolfsshd/test/test_configuration.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
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.
Private keys and /etc/shadow are read with stdio buffering off, so the
secrets are not left in a libc FILE buffer that fclose frees unwiped.
test_configuration coverage
Issue: F-14689, F-14690