wolfsshd: add StrictModes permission/ownership checks for authorized_keys and host key#1010
Open
yosuke-wolfssl wants to merge 1 commit into
Open
wolfsshd: add StrictModes permission/ownership checks for authorized_keys and host key#1010yosuke-wolfssl wants to merge 1 commit into
yosuke-wolfssl wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an OpenSSH-like StrictModes enforcement path to wolfsshd to harden key handling (authorized keys and host private keys) via permission/ownership checks, with config parsing and accompanying tests/scripts.
Changes:
- Introduces
StrictModesconfig directive (defaultyes) and plumbs it through configuration parsing/getters. - Adds
wolfSSHD_CheckFilePermissions()and enforces it forauthorized_keys(ownership + non-writable + parent chain walk) and the host private key (non-readable/writable by group/world). - Extends unit tests and adjusts the test launcher script to chmod host keys at runtime.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/wolfsshd/wolfsshd.c | Enforces StrictModes checks for host private key before loading it. |
| apps/wolfsshd/test/test_configuration.c | Adds StrictModes parse/default tests and new permission-check unit test (non-Windows). |
| apps/wolfsshd/test/start_sshd.sh | Tightens host key permissions at test runtime prior to launching wolfsshd. |
| apps/wolfsshd/configuration.h | Exposes wolfSSHD_ConfigGetStrictModes(). |
| apps/wolfsshd/configuration.c | Implements StrictModes storage/default, parsing, and getter. |
| apps/wolfsshd/auth.h | Declares wolfSSHD_CheckFilePermissions(). |
| apps/wolfsshd/auth.c | Implements permission/ownership checks and wires StrictModes into authorized_keys lookup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b077d37 to
65a5b6a
Compare
…keys and host key
65a5b6a to
feaa9e4
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1010
Scan targets checked: wolfssh-bugs, wolfssh-src
No new issues found in the changed files. ✅
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.
Description
Adds an OpenSSH
StrictModesequivalent to wolfsshd, addressed by f_4114.authorized_keysis now refused (whenStrictModesis on, the default)if the file or any parent directory up to the home directory is owned by
another user or is group/world writable — the OpenSSH
secure_filenamemodel. This blocks local key-injection via a lax umask, a botched copy, or a
writable
~/.ssh.StrictModesis on) if it isgroup/world readable or writable — protecting the server secret from
disclosure. Ownership is intentionally not enforced so a privileged daemon
can use a key owned by an unprivileged service account.
StrictModesconfig directive (defaultyes), so admins can opt outper finding-recommended OpenSSH semantics.
Tests
StrictModes yes/no/invalidparse vectors + default-on assertion intest_configuration.test_CheckFilePermissionscovering owner / group+world write / chainwalk / host-key readability / missing file / NULL path. The wrong-owner
assertion is skipped under uid 0 (root accepts root-owned files).
start_sshd.shtightens configured host keys to 600 at launch (git cannotstore 0600), handling multiple keys and tab/space separators.
Verification
--enable-sshd --enable-all), no warnings.test_configurationpasses the new cases; rebuilt under ASan+UBSan with noreports.
StrictModes yes+ 0644 host key -> refused;StrictModes no+ 0644 -> accepted.Files
apps/wolfsshd/auth.c,auth.h— helper + authorized_keys wiringapps/wolfsshd/configuration.c,configuration.h— StrictModes directive + getterapps/wolfsshd/wolfsshd.c— host-key check in SetupCTXapps/wolfsshd/test/test_configuration.c— unit testsapps/wolfsshd/test/start_sshd.sh— runtime host-key chmod