The client, scpclient and sftpclient accept a plain host key only when
a "host type key" line of ~/.ssh/known_hosts holds it. An unknown or
changed key is refused, printing its fingerprint and the line to add.
-Y accepts any key, with a warning.
- Check that an x509v3 host certificate names the host by DNS or IP
subjectAltName, or by common name without one; -X waives a mismatch
- Pass -Y in the tests and CI jobs that connect to a throwaway server
- Seed known_hosts for openssh-interop.test from sshd's host keys
- Add client-hostkey.test for unknown, known, stale and changed keys
Issue: F-7620
modes_store() records whether tcgetattr() read the stdin modes.
modes_clear() and modes_reset() do nothing when it did not, and a
failed raw-mode tcsetattr() leaves nothing for modes_reset() to restore.
Issue: CID-661743, CID-661746
GetConfigInt() checks each step against 0x7FFFFFFF, so the value, the
time multiplier and the running total are now int, the same width as
the limit. The return type stays long for the callers.
Issue: CID-661742
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
DefaultUserAuth() holds a failed attempt to a per-user minimum, modeled
on OpenSSH sshd: 5 ms plus up to 4.29 ms from a keyed hash of the
username, doubled while the time already spent exceeds it, and skipped
past 5 s. It sleeps and rechecks until the minimum has passed. The
library itself stays non-blocking.
- wolfSSHD_AuthInit() draws the per-daemon key before any fork
- the hash is SHA-256, else SHA-512 or SHA-384; with none, the floor
- Windows times the wait with QueryPerformanceCounter
- tests for the delay range, the doubling, an early-waking sleep, and
a failing request
Issue: F-11938
CheckPasswordPAM takes the WOLFSSHD_AUTH argument that
CallbackCheckPassword requires, so a --with-pam build compiles again.
It is still a stub and returns WSSHD_AUTH_FAILURE for every password.
Issue: F-11676
SetupUserTokenWin frees its WCHAR copy of the user name in the common
cleanup with authInfo and the LSA handle, so a public key probe no
longer leaks it on Windows.
Issue: F-8854
Comment-only change: each comment now describes what its code does.
No code tokens change.
- kex: server f is our output, not the peer key; the ML-KEM-768 f is
the ciphertext; the client hybrid also covers P-256 and P-384
- scp: base path and fd referents, NEW_REQUEST state, unchanged index,
oversize rejection, and where the symlink checks are not atomic
- error.h: WS_DH_SIZE_E and WS_DISCONNECT meanings, GetErrorString()
- api: stream_read WS_EXTDATA, channel-open built-in refusals, write
ctx, SFTP write offset, agent reply status, userauth returns
- misc: off_t guess, wSelect, handle cap, sftpclient, wolfsshd notes
Issue: F-9422, F-10564, F-11637, F-11638, F-11639, F-11640, F-12555,
F-12556, F-13915, F-14207, F-14399, F-15514, F-15515, F-15516,
F-16055, F-16056, F-16057, F-16757, F-16758, F-16759, F-16760,
F-16761, F-16762, F-16763, F-17054, F-17055, F-17868, F-17869
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
Windows wolfsshd does not look up a user's groups, so a Match Group
block could never apply and its restrictions were skipped. The config
load now rejects a Group selector there, as it does other unsupported
Match selectors.
- WOLFSSHD_NO_MATCH_GROUP gates the rejection, set for _WIN32
- add sshd_match_group_win_test.ps1 to the Windows check workflow
Issue: F-15559
"ChrootDirectory none" now means no chroot, as in OpenSSH, instead of
a relative chdir() target. The keyword still counts as set, so a Match
block using it exempts a user from a global ChrootDirectory.
- match "none" case-insensitively, as OpenSSH does
- add sshd_chroot_none_test.sh: global and Match cases against an
empty global chroot
Issue: F-16811
"AuthorizedKeysFile none" now turns off the authorized keys file, as
in OpenSSH, instead of naming ~/none, a file the user controls. The
value stays "none" through Match composition, and SearchForPubKey
refuses it before resolving any path.
- match "none" case-insensitively, as OpenSSH does
- OpenSSH certificates still check against TrustedUserCAKeys
- X.509 certificates do not fall back to CA-only under "none"
- a "none" node passes the wolfSSH_TrustedSystemCAKeys startup gates
- add sshd_authkeys_none_test.sh: key in ~/none, X.509 CA-only and
system CA gate cases, each set globally and in a Match block
Issue: F-15558
CheckPasswordHashUnix() hashes into a heap struct crypt_data when
configure finds crypt_r(), and wipes the whole struct on return, so
neither the result nor crypt's working state is left behind. Builds
without it, such as macOS, keep crypt() and its result wipe.
- configure probes crypt_r() through <crypt.h> as HAVE_CRYPT_R
Issue: F-8842
The shell child frees its session and the server context before it
drops to the user, so the host private key and the session keys are
wiped from its image ahead of the exec. It keeps copies of the user
name and command it still needs. A short read of a key file wipes
the buffer before freeing it.
Issue: F-8841, F-14227
The wide-character copies of the peer's command are zeroed before
they are freed, in SHELL_Subsystem() and in SetupConsole(). A
CreateProcessW() failure in SetupConsole() now runs its cleanup
before returning WS_FATAL_ERROR.
Issue: F-8851, F-10596
Account lookups go through wolfSSHD_GetPwnam(), which fills a
caller-owned store with getpwnam_r() and wipes it on release. Shadow
entries are read the same way with getspnam_r() where libc has it.
The crypt() result is wiped on every path.
- auth.c and the session lookup in HandleConnection use the store
- configure probes the five-argument getspnam_r() as HAVE_GETSPNAM_R
- ScanShadowFile() wipes the line the loop exit reads
- the getpwnam/getspnam test hooks default to NULL, the real lookup
- test_GetPwnam checks the store, the wipe, and the errno contract
Issue: F-11683, F-11684, F-13439, F-8842, F-12646
SCP_Subsystem() changes to pw_dir after dropping privileges, as the
shell and SFTP do, so a relative remote path resolves from home rather
than from the daemon's working directory, inside a chroot too. When
home is unreachable, SCP and the shell start from "/", as OpenSSH does.
Both log that only outside a chroot.
- sshd_scp_home_test.sh uploads to "." and finds the file in home
Issue: F-15502
A shell child killed by a signal now reports 128 plus the signal as
its exit status. A failure after the fork kills and reaps the child
and closes the parent's descriptors to it, and the resize context is
cleared before the terminal it points at is closed.
- SHELL_AbortChild() serves the post-fork setup failures, which now
run before the parent drops privileges so it can still kill the child
- -r with no command now fails at the argument check in main()
- sshd_exit_signal_test.sh checks a plain exit and a SIGKILL
Issue: F-13327, F-14203, F-15571, F-14204
wolfSSH_DoModes() now returns -1 without touching the terminal when
tcgetattr() fails, instead of applying an uninitialized termios. A
failed tcsetattr() is reported the same way, and wolfsshd logs it.
- api.c: DoModes fails on a pipe and sets ECHO on a pty
Issue: F-10546
ConfigLoad() reads lines of up to 1023 bytes and drains the rest of a
longer one, so its tail is never parsed as a line of its own.
- skip an over-long comment whole and fail the load on an over-long
directive, also one pushed out by leading whitespace
- ignore whitespace past the end of the buffer
- drop the one-byte peek past a full buffer, which the drain replaces;
it failed every over-long comment
- add a long-line load test
Issue: F-14395
Match User and Match Group now take a comma separated list of exact
names and apply when any entry equals the user or one of the user's
groups.
- reject '*', '?', '!' and empty entries in a Match name list
- add parser cases and a Match list lookup test
Issue: F-11661
HandleInclude() now checks the first character of the pattern for a
'*', so a pattern with no directory part, such as "Include *.conf",
is expanded rather than opened as a literal file. The '*' may match
an empty sequence, but the fixed prefix and postfix may not overlap.
- skip names with a leading '.' unless the pattern starts with '.',
as glob(3) does
- add tests for foo*, *foo, f*o, a*a and the overlapping ab*ba
- add a leading-wildcard pattern that matches nothing
Issue: F-10550, F-14632
GetConfigInt() now requires the whole value to be decimal digits, so
"Port 22abc" fails to load instead of reading 22. LoginGraceTime takes
the sshd_config(5) time format, number and unit groups summed as
seconds, so "1h30m" is 5400 and "2junk" is rejected.
- accept the s, m, h, d and w units in either case, zero-padded
groups, and a bare trailing number as seconds, as OpenSSH does
- reject values above 0x7FFFFFFF, per group and in the sum
- write the bad Include fixture as "LoginGraceTime bad", since a
zero-padded time is now valid
- add Port, Protocol and LoginGraceTime cases to the parser test
Issue: F-10549, F-17100
The password prompt reads stdin with fgets(), and a buffered stdin
keeps its own copy of the line in libc for the life of the process.
The clients make stdin unbuffered before any stdin I/O, so the typed
password lands only in the buffer ClientUserAuth() wipes.
- the wolfssh app, and the example client, sftp client and scp client
whether or not -P was given, as keyboard-interactive reads stdin too
- ClientUnbufferStdin() acts once per process and reports a failure
- scripts/sshclient.test sends the session data right after the
password, with no sleep
Issue: F-15669
ClientUserAuth() hands the library its static password buffer, and the
library sends from it after the callback returns. The clients now wipe
it, and the example's keyboard-interactive responses, as soon as
connect returns instead of holding them for the whole session.
- ClientClearPassword() in both common.c copies, called after connect
in the wolfssh app, the example client and the sftp client
- the password arm wipes before each prompt and on failure, so a retry
keeps no tail of a longer password
- the keyboard arm wipes its scratch copy after each response
- tests: regress and auth cases for the retry tail, the wipe and a
failed read
Issue: F-8846
auth.c called the library-internal ConstantCompare(), which does not
resolve when the library is built with --disable-inline. Call
wolfSSH_ConstantCompare() instead.
Issue: F-7514
Restructure the two sites that left a redundant check in one build
configuration, and suppress a warning that only appears in a
configuration cppcheck invents.
- wolfsshd.c: set the -h host key file in the else of the cert store
conflict check instead of retesting ret.
- internal.c CompositeEccSign: run wc_ecc_sig_to_rs from an else shared
by the small-stack allocation check and the plain stack arrays.
- wolfsftp.c: suppress constStatement on WWRITE; cppcheck's -DWWRITE
configuration turns the arguments into a comma expression.
The known_hosts search skips an entry whose host matches but whose key
type differs, so a host pinned with one type that presents another was
reported as an unknown host. The check now remembers that the host is
known with another type and says so before offering to add the new one,
as OpenSSH does.
- note the first other-type entry's key type and line in the loop
- print a warning with that entry, the host and the new fingerprint
before the add prompt; a later same-type entry still matches or
rejects as before
- reject a server key type that is not printable ASCII before it is
printed or stored
- regress.c: add TestKnownHostsOtherType
Issue: ZD-22634
ConfigLoad() reports a line too long for its buffer and fails the load.
A cut line used to take effect with whatever fitted, since what is left
of it is read as a line of its own and a leftover of two bytes or less
is skipped as blank. The buffer is 1024 bytes now, so a long path or
forced command still loads.
- one byte is read past a full buffer, so a line that ends exactly
there, at a newline or the end of the file, is not taken for a cut one
- the size is WOLFSSHD_MAX_LINE_SIZE in configuration.h, shared with
the test
- test_configuration covers a long line, lines that exactly fill the
buffer, and a line cut to leave a blank-looking remainder
Issue: ZD-22623
A ForceCommand other than a bare "internal-sftp" now denies the SFTP
subsystem, and any ForceCommand denies SCP, as sshd_config(5) describes
it: a forced command applies to shell, command, and subsystem execution.
The session dispatch checks the configured command alongside a
certificate's, so either one on its own confines the session.
- the subsystem arm and both SCP arms consult the configured
ForceCommand, not only a certificate's force-command
- "internal-sftp" followed by options denies SFTP, since no option is
applied, while the shell still refuses it as "internal-sftp"
- every site testing for "internal-sftp" now shares one predicate
- root's transfer refusal no longer points at ForceCommand internal-sftp,
which does not permit SCP
- tests require a ForceCommand to deny SFTP and SCP, read the daemon's
decisions from its log, and pair a configured internal-sftp with a cert
Issue: ZD-22623
Issue: F-10597
An unresolved user took the global methods, so a name a Match User
block covers advertised a different list depending on whether the
account existed. DefaultUserAuthTypes() now composes the blocks that
select on the name alone, with no group list, when the account does
not exist.
- a Match Group block still cannot apply to a name with no account, so
it fails closed to the unmatched methods
- any other failure to resolve the user, or to compose its blocks,
advertises no methods rather than the global ones, so a Match block
that disabled a method is never skipped
- test_configuration stubs the account lookup and covers a lookup
error, an unreadable group list and a resolved account as well as the
Match User and Match Group blocks
Issue: ZD-22617
DefaultUserAuthTypes() resolved the requested user before any
authentication, so a username with no local account produced an empty
"methods that can continue" name-list. It now falls back to the global
configuration's methods when the user does not resolve, so the
USERAUTH_FAILURE reply no longer says which accounts exist.
- an unresolved user still cannot authenticate, since the same failed
lookup rejects every method it tries
- test_configuration covers the advertisement for an unknown user,
comparing against the global mask so it tracks the configuration
Issue: ZD-22617
The password backends check the password as a C string, so "\0junk"
was checked as "" while its nonzero length passed the
PermitEmptyPasswords check. RequestAuthentication now refuses any
password with a NUL before the policy check and the backends.
- test_RequestAuth_embeddedNulPasswordRejected puts the NUL first,
last and mid-password, and checks the fake crypt still runs
Issue: F-16096
The -p option of wolfssh, client, wolfscp, wolfsftp and echoserver now
goes through a strtol check, so a value that is not wholly a number in
range exits with an error instead of wrapping into a different port.
- apps/wolfssh: ClientParsePort(), shared with ClientParseDestination(),
which also rejects an empty "ssh://host:" port instead of defaulting
- examples: a ClientParsePort() in examples/client/common.c; port 0 is
rejected in every build, not only with a main driver
- echoserver: accepts 0 to 65535, keeping 0 for the test harness
- add TestClientParsePort and an empty URI port case to regress.test
Issue: F-14763, F-14767, F-14768, F-12552
SHELL_Subsystem copied pw_shell into an 80-byte buffer before execv(),
so a longer path ran whatever its first 79 bytes named. The child now
passes pw_shell to execv() directly, and builds the login argv[0] from
its basename so a long path no longer falls back to "-sh".
- add sshd_long_shell_test.sh, which logs in as a throwaway user whose
shell path is longer than 80 bytes and checks the shell's $0
Issue: F-14757
Where open() cannot refuse a final-component symlink, no pre-check can
stop a link swapped in before the open, and the fstat gate accepts a
root-owned target. wolfSSHD_ConfigSavePID now writes no PID file there
instead of relying on a racy lstat.
- test_ConfigSavePID gets a variant for that build that expects no file
Issue: F-14764
A client refuses shell, exec, subsystem and pty-req channel requests
and direct-tcpip opens before any callback runs (RFC 4254 6.2, 6.5,
7.2). CHANNEL_OPEN_CONFIRMATION and CHANNEL_OPEN_FAILURE are a
protocol error unless the channel's own open is still outstanding.
- SshInit() installs the default WS_TermResize for servers only.
- Drop the Windows clients' raw-HANDLE resize context; nothing uses it.
- Move the channel request builders out of the server-only test block.
Issue: F-10582, F-13923, F-15533, F-15572, F-14434
The POSIX StartSSHD() now returns EXIT_FAILURE when ret holds an error,
and main() passes that on. A config check (-t) of a bad config, a
failed host key load, or a bad -p now exit 1 instead of 0.
- set ret when the accept loop cannot allocate a connection, so that
stop also exits non-zero
- PendingConnection() returns negative on a select() error other than
EINTR, and the accept loop sets ret from it instead of quit
- log "Closing down wolfSSHD" whenever the accept loop exits, not
only on quit, so the error exits still log it
- add sshd_exit_status_test.sh, which checks -D -t exit codes for a
valid config and three startup failures
Issue: F-16053
StartSSHD() no longer stores the NewConnection() result in ret, the
accept loop's condition. A failed fork() or CreateThread() now drops
that one connection, and the daemon goes on listening.
- add sshd_fork_fail_test.sh with an LD_PRELOAD shim that fails the
first connection's fork() with EAGAIN
- run it from run_all_sshd_tests.sh on leased port +7
Issue: F-16052
RFC 4254 sec 6.5 lets only one shell, exec or subsystem request succeed
per channel. DoChannelRequestSession() now refuses any request after
the first grant without asking a callback, so the granted session and
its command stand.
- a refusal before any grant leaves the channel with no command
- ssh.h documents the refusal; wolfsshd's own check is defence in depth
- regress.c sends a second exec, shell and subsystem after a granted
exec, and a second exec over a generic-callback grant
- unit.c expects a shell after an exec to be refused and checks that a
refused exec's command is scrubbed
A pty session has no stderr pipe, so the shell loop must start with
stderrEmpty set. The drain test now runs "exit 3" in a pty shell and
expects the session to end with that status rather than wait for a
stderr EOF that never comes.
A child that exits with its error output still in the pipe must have
all of it relayed. The child grows its stderr pipe and queues the
whole payload before exiting, so the result does not depend on the
pipe size or on which cat is installed.
- forty passes, each compared byte for byte with the payload
- a client failure is reported as one, not as a truncation
- fixtures readable by a login user other than the invoker
- skips without perl
- listed in extra_test_cases and local_sshd_tests
The shell loop waits on the child's stderr the way it already waits on
its stdout. A child that exits with error output still in the pipe had
the rest relayed only by the single read below the loop -- one
bufferful, however much was waiting -- so the peer saw a truncated
error stream and no error. A pty session has no stderr of its own.
Neither pipe holds the loop once the peer closes the channel.
The Windows path of apps/wolfssh and examples/client sets the volatile
quit with InterlockedOr8() once readPeer() returns, repeats
CancelSynchronousIo() on the readInput() thread until it has exited,
and only then closes the handles and frees the session. readInput()
checks quit around its console read and inside its send retries, and
returns quietly when it is set.
Issue: F-11662
readInput() and readPeer() in apps/wolfssh and examples/client clear
their stack buffer with wc_ForceZero() before returning, so neither
what was typed into the session nor the last of its output is left on
a finished thread's stack. On POSIX the main thread cancels
readInput() inside read(), so a pthread cleanup handler does the wipe
for it.
- readInput() holds only the buffer and the cleanup handler; the loop
is readInputLoop(), since glibc's pthread_cleanup_push() is a setjmp
and gcc -Wclobbered flags the locals of the function holding it.
Issue: F-10594, F-12647
readInput() in apps/wolfssh and examples/client sends again from
where a short wolfSSH_stream_send() stopped until the whole chunk is
taken, and waits out WS_WINDOW_FULL the way it waits out a rekey.
readPeer() in both writes stdout and stderr through a WriteAll() that
loops over short writes.
- A send clamped to the peer's window or packet size no longer drops
the rest of the chunk, and the WS_WINDOW_FULL that follows the clamp
no longer ends the stdin thread.
- The Windows stderr path writes the bytes read instead of a "%s".
Issue: F-8830, F-10548, F-10555
wolfSSH_AGENT_SignRequest() writes the sign request and reads the reply
through the whole-message helpers the relay uses, so a short write is
followed up and a reply is read to its declared length before it is
parsed. The setup callback's WS_AgentCbError result becomes
WS_AGENT_CXN_FAIL, and an ECDSA key's reply room fits the SSH blob.
- A short write, a hang-up, or a failed setup is WS_AGENT_CXN_FAIL;
cleanup runs only after a setup that succeeded, and the client
callbacks close their socket when connect() fails.
- PrepareUserAuthRequestEcc() reserves r and s as mpints a pad byte over
the curve size, and BuildUserAuthRequestEcc() hands the agent that
room, checks the reply's algorithm name, and bounds it by outputSz.
- A NULL sig, or a NULL digest or key blob with a size, is
WS_BAD_ARGUMENT; agent.h documents the contract and return codes.
- api: the mock agent's short write is followed up, a reply read a byte
at a time is reassembled, and a failed setup and NULL buffers are
refused.
- regress: the mock agents answer as a stream; ECDSA user auth for each
curve at, under, and over the largest blob, and a wrong curve name
refused; a failed setup refused with nothing sent.
Issue: F-13325, F-14629, F-14631
The summary prints "N run, N passed, N skipped" from a PASSED counter
incremented at each success site. TOTAL counts every test reached, skips
included, so printing it under the label "passed" overstated the pass
count by exactly the number of skips.
- pair each orphan SKIPPED bump with a TOTAL bump, and count the
local-only tests skipped against an external host by name, so the
printed numbers are commensurable and the skip count cannot go stale
- count the host key gate's WOLFSSH_NO_HOSTKEY_PERMS exit as a pass: it
prints PASSED and returns with TOTAL already charged, so leaving it
uncounted would fail the new assertion on every build with that macro
- assert that passed plus skipped equals ran and, without --match, that
ran equals the known test count, so a miscounting skip site or a name
no call site reaches fails the run
- verified in the container: a full run reports 32 run, 30 passed, 2
skipped against 30 PASSED lines, and --exclude sshd_forcedcmd_test.sh
reports 32 run, 29 passed, 3 skipped against 29
run_all_sshd_tests.sh validates --match and --exclude against test_cases
plus a new extra_test_cases naming the tests called in place, and every
call goes through one should_skip(). A match runs its test where it
sits, with the daemon it needs around it, so one path now serves the
whole suite. test_cases named 12 of the 32 tests the runner drives.
- gate the x509, UPN and ML-DSA daemon starts on the match, so selecting
another test does not start them
- take the bulk skip for the tests needing a local daemon only on a full
run, where its fixed count is right
- reject an unrecognized --exclude, and a --match that reached no call
site: a local-only name selects nothing against an external host,
which would otherwise exit 0 having run no test at all
- keep every test call inside one compound, so RUN_COMPLETE still fails
a run that a shell expansion error cut short, and abort naming any
run_test call listed in neither array
- verified in the container: a full run gives 32 run, 30 passed, 2
skipped, and --match sshd_chroot_fail_test.sh gives 1 run, 1 passed,
starting only the daemon that test needs
An LD_PRELOAD interposer fails one SetupChroot() step at a time and
records each chroot() plus every chdir() made after one, so a step that
ran when it should have been skipped shows up in the record. The daemon
stops after the first failed step, and nothing asserted that.
- three cases: chdir faulted, chroot faulted, and an unfaulted chroot
into "/" that must still complete and run its command
- keep the fault injection in the interposer, with no fault code in the
daemon or the library
- register it after the privilege-drop test, the other test that needs
its own root-launched daemon
- skip when the example client is not built, and set the EXIT trap
before building the interposer so no exit path leaves it behind