wolfsshd: expand AuthorizedKeysFile %u/%h/%% tokens per user#1064
Open
yosuke-wolfssl wants to merge 1 commit into
Open
wolfsshd: expand AuthorizedKeysFile %u/%h/%% tokens per user#1064yosuke-wolfssl wants to merge 1 commit into
yosuke-wolfssl wants to merge 1 commit into
Conversation
b3d1fc2 to
5235de8
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1064
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.
wolfsshd: expand AuthorizedKeysFile %u/%h/%% tokens per user
Problem
ResolveAuthKeysPathcopied an absoluteAuthorizedKeysFilepattern into theresolved path verbatim, with no token substitution (a
TODOmarked the gap).A common OpenSSH-migration config such as:
resolved to the literal
/etc/ssh/keys/%ufor every user. If a file existedat that un-substituted path, its keys were accepted for any valid system user,
collapsing per-user key isolation.
Addressed by f_5827.
Fix
ExpandAuthKeysTokens()— expands%u(user),%h(home dir), and%%(literal
%) into a bounds-checked buffer. Unrecognized tokens andover-length expansions fail closed (
WS_FATAL_ERROR) rather than reachingthe filesystem.
ResolveAuthKeysPath()now takes the connecting user and expands the patternbefore the absolute/relative decision, so both branches honor substitution and
each user resolves to a distinct path.
SearchForPubKey()→CheckPublicKeyUnix(Unix)and
CheckPublicKeyWIN(Windows). Both call sites already held it; no newgetpwnam/lookup is introduced and no shared mutable state is added.Token semantics
%u%h%%%A recognized token with no value (e.g.
%uwith a NULL user) and anyunrecognized token fail closed. A trailing lone
%is treated as a literal.Platform notes
Absolute-path detection is
/-rooted on POSIX; on Windows it additionallyrecognizes a
\-root or a drive-letter (X:) root, guarded by#ifdef _WIN32so a POSIX relative pattern beginning with
\or<letter>:is not misread.Testing
test_ResolveAuthKeysPathunit test (13 scenarios): per-user%u(
alicevsbob),%h,%%, relative, default-NULL fallback, trailing%,unrecognized token, NULL-user fail-closed, expansion over-length, relative
home-dir over-length, and platform-aware drive-letter/backslash handling.
MAX_PATH_SZmoved toconfiguration.hso the test buffer tracks the realcontract;
ResolveAuthKeysPathexposed to the tests viaWOLFSSHD_STATIC.tests catch both the verbatim-copy regression and a removed bounds check.
auth.c/configuration.ccompile with no new warnings; default test set(api-test, unit-test, testsuite) passes.
Files changed
apps/wolfsshd/auth.capps/wolfsshd/auth.happs/wolfsshd/configuration.happs/wolfsshd/test/test_configuration.c