Commit Graph

334 Commits (2425f7c5945df94320091da343b0ed9ee1533a5e)

Author SHA1 Message Date
Yosuke Shimizu 7393aaea9b wolfsshd: reject Match blocks using unimplemented selectors 2026-06-16 15:38:16 -07:00
Yosuke Shimizu eef8281609 wolfsshd: bind certificate auth to user, fail closed without FPKI 2026-06-16 11:50:34 -07:00
John Safranek 36e276529f Fix sshd test flakiness and orphan daemon
- term size test: poll tmux output with retries instead of fixed sleeps,
  re-sending the size query each pass in case the shell was not yet ready
- term close test: scope netstat checks to the test port so unrelated
  host CLOSE_WAIT/TIME_WAIT sockets don't fail the test
- run_all_sshd_tests.sh: validate --match before starting wolfSSHd
- renewcerts.sh: build the per-user cert from a throwaway config copy so
  the tracked renewcerts.cnf is never modified in place
2026-06-15 22:05:50 -07:00
John Safranek 69f7799929 Check Include path truncation in sshd config
HandleInclude built the wildcard include path with WSNPRINTF without
checking the result, silently truncating over-long paths (flagged by
GCC 12 as -Werror=format-truncation). Merge the duplicate WSNPRINTF
calls and return WS_INVALID_PATH_E when the path does not fit.
2026-06-15 21:48:30 -07:00
John Safranek 1d86a8ed27 Bound sshd Include directive recursion
Cleanup clang-tidy misc-no-recursion finding.

- wolfSSHD_ConfigLoad: track depth on WOLFSSHD_CONFIG
  and reject loads past WOLFSSHD_MAX_INCLUDE_DEPTH (16).
- HandleInclude, HandleConfigOption, ParseConfigLine,
  wolfSSHD_ConfigLoad: annotate the call cycle with
  NOLINTNEXTLINE pointing at the bound.
- Add a recursive configuration test.
2026-06-09 17:18:39 -07:00
John Safranek 304955ff94 Move unsafe call out of signal handler
Cleanup clang-tidy bugprone-signal-handler findings.
- wolfsshd: drop fprintf from interruptCatch; the main accept
  loop logs "Closing down wolfSSHD" after seeing quit set.
- sftpclient: annotate wolfSSH_SFTP_Interrupt call in
  sig_handler with NOLINT, since the function is only a single
  byte store and is safe to call from a signal handler.
2026-06-09 17:03:02 -07:00
John Safranek 863a52be63 Add parameter names to function declarations
Clean up clang-tidy readability-named-parameter findings
across wolfSSH headers and sources.
2026-06-09 17:03:02 -07:00
Yosuke Shimizu a760b9a1d2 apps/wolfssh: fix ssh://hostname destination without explicit port 2026-06-09 11:11:37 -07:00
Yosuke Shimizu 6af538ded0 Fix 2026-06-09 11:05:54 -07:00
Yosuke Shimizu 3f981d1e8d wolfsshd: fix peer-controlled over-read in Windows pseudo-console resize 2026-06-09 11:05:54 -07:00
Yosuke Shimizu d49b15f51a SFTP path confinement and status-reply refactor 2026-06-09 10:46:17 -07:00
Yosuke Shimizu 2d0ef5aee4 wolfsshd: honor Match-block auth restrictions in DoCheckUser and RequestAuthentication 2026-06-08 14:54:28 -07:00
Yosuke Shimizu d234a2721d Add unit tests for wolfSSHD_AuthReducePermissionsUser 2026-06-04 13:20:29 -07:00
John Safranek fd334579c5 wolfsshd: fix data loss in Windows shell relay
- buffer unsent bytes on backpressure/partial send and resend
- hold loop open until buffered data flushes after child exit
2026-06-03 07:40:27 -07:00
John Safranek 9d62a4483a wolfsshd: set stdoutEmpty on PTY EOF
Lets the relay loop reach its shutdown condition after SIGCHLD
instead of relying on a -1/EIO break.
2026-06-03 07:40:27 -07:00
John Safranek c851de1708 wolfsshd: harden windowFull retry
- Guard the retry against a negative cnt_w so a non-sentinel
  send error cannot become a negative memmove offset.
- Clear windowFullExt at the stdout and childFd save sites so
  stream ownership is set unconditionally.
2026-06-03 07:40:27 -07:00
John Safranek 27439881fd wolfsshd: save shellBuffer on WS_WANT_WRITE
ChannelIdSend / extended_data_send returning WS_WANT_WRITE set
wantWrite but didn't save cnt_r, so the next read overwrote the
held bytes. Store cnt_r in windowFull at all three read sites
(stderr, stdout, pty childFd); flag windowFullExt for stderr so
the retry routes through extended_data_send.
2026-06-03 07:40:27 -07:00
John Safranek 339c39bb57 wolfsshd: track stream for windowFull retry
Stderr and stdout shared shellBuffer/windowFull, so a stderr hold
retried on stdout, and a stderr partial send let the stdout read
clobber the remainder. Tag the held bytes with windowFullExt;
retry via extended_data_send and skip the stdout read when set.
2026-06-03 07:40:27 -07:00
John Safranek 094c686142 wolfsshd: retry select() on EINTR in relay loop
SIGCHLD from the exec child interrupts select(), returning -1 and
breaking the loop. Any windowFull data awaiting a peer window adjust
was then abandoned, causing intermittent 32 KB truncations on large
exec transfers. Continue on EINTR.
2026-06-03 07:40:27 -07:00
John Safranek 2ca89137a8 wolfsshd: gate debug logging behind -d flag
- Enable wolfSSH/wolfSSL debug logging only when -d is passed
- Disable both logging facilities during cleanup
2026-05-28 08:48:13 -07:00
John Safranek 1aac6d2f5a ClientFreeBuffers: zero secrets before free
- Zero private key and password buffers in both apps/wolfssh
  and examples client.
- Also zero keyboard-interactive response buffers in the
  example client.

Issue: F-249
2026-05-21 11:42:43 -07:00
John Safranek 2dc337d34a ClientPublicKeyCheck: drop dead otherMatch guard
- otherMatch is set to 1 immediately above; guard always true.

Issue: F-3205
2026-05-21 11:42:43 -07:00
John Safranek 541f0ac42a wolfsshd: unit test for CheckAuthKeysLine
- Expose CheckAuthKeysLine under WOLFSSHD_UNIT_TEST so tests can link it.
- Add test_CheckAuthKeysLine covering match, different key, and same-length
  key differing only in the last byte.
- Route the test Log() to stderr instead of an unused local buffer.

Issue: F-4107
2026-05-20 13:03:03 -07:00
John Safranek 5f4032f831 wolfssh: config user handling fix
1. Fix where an already allocated config->user is leaked.
2. Copy the argv user name into a heap buffer.

Issue: F-4102
2026-05-20 13:03:03 -07:00
Paul Adelsbach c3640630b0 Allow empty passwords in sshd when PermitEmptyPasswords is set 2026-05-18 13:55:40 -07:00
Yosuke Shimizu 9d9fa2699d Refactor resource cleanup in windows path 2026-05-18 13:35:07 -07:00
Yosuke Shimizu fb1aa6daba Fix minor issues and Add test vectors 2026-05-14 09:36:43 -07:00
John Safranek 822c09d0eb Fix integer overflow in ParseRFC6187 name length
- Reject name lengths that would overflow m when added
  to sizeof(word32), preventing OOB reads on later checks.

Issue: F-1277
2026-05-12 21:39:33 -07:00
Yosuke Shimizu 7d7d04dc70 Fix minor issues and Add unit test for wrong padded OpenSSH key 2026-05-12 13:14:56 -07:00
John Safranek 2e1ff86799 Reject unknown host when user declines to add key
ClientPublicKeyCheck() prompted to add an unknown server's key
to known_hosts but, if the user declined, left ret at 0 and
returned WS_SUCCESS, silently accepting the unverified host.
Set ret = -1 in the else branch to mirror the otherMatch case
and abort the handshake when the user does not confirm.

Issue: F-3444
2026-05-11 22:28:44 -07:00
John Safranek aef3e8661a fix config_print to show pubKeyFile
Issue: F-214
2026-05-08 12:26:36 -07:00
John Safranek 90d5d44910 wolfsshd: zero stored hash copy before free
Issue: F-57
2026-05-08 12:26:36 -07:00
Yosuke Shimizu dc914afd73 Fix minor issues 2026-05-08 09:59:00 -07:00
Yosuke Shimizu fdf621c83a Add log for LoginGraceTime on windows, Add regress test and fix minor issues 2026-04-23 10:19:13 -07:00
Yosuke Shimizu b557998ddf Add default loginTimer 2026-04-23 10:19:13 -07:00
John Safranek 1b971ffaf4 Fix scan-build warning for undefined errno read after execv
Remove the errno check in the condition after execv(). If execv()
returns at all, it has failed, so checking ret alone is sufficient.
The errno check was flagged by clang scan-build as potentially
reading an undefined value (unix.Errno).
2026-04-22 10:27:06 -07:00
John Safranek bfbf0edbb9 7-bit Clean ASCII
Clean up the main set of files to be 7-bit clean ASCII. There were many
single and double-quotes and n-dashes.
2026-04-22 10:27:06 -07:00
John Safranek 87c0b05d72 Userauth none bypasses wolfSSHd credential check
When wolfsshd is built with WOLFSSH_ALLOW_USERAUTH_NONE, the
DefaultUserAuth() function accepted WOLFSSH_USERAUTH_NONE as a valid
auth type and forwarded it to RequestAuthentication(). Since
RequestAuthentication() only gates credential checks on PASSWORD and
PUBLICKEY types, a none request for any existing system user returned
success without verifying any credential. Removed USERAUTH_NONE as an
accepted auth type in DefaultUserAuth() so it is treated as an invalid
auth type for wolfsshd.

Affected function: DefaultUserAuth.
Issue: F-3215
2026-04-21 09:20:12 -07:00
Paul Adelsbach 80da96eebb Add negative test case for CheckPasswordHashUnix 2026-04-20 09:58:07 -07:00
John Safranek 0049c55b1b
Merge pull request #931 from yosuke-wolfssl/f_2074
Fix wolfSSHD_ConfigCopy and wolfSSHD_ConfigFree
2026-04-17 10:24:29 -07:00
Yosuke Shimizu 2608f90fa1 Fix FingerprintKey 2026-04-17 17:52:30 +09:00
Yosuke Shimizu 97a0c7b5b7 Fix wolfSSHD_ConfigCopy and wolfSSHD_ConfigFree, and Add the regression test 2026-04-17 17:31:40 +09:00
Paul Adelsbach 854a36248e Replace WMEMCMP in CheckAuthKeysLine 2026-04-13 10:19:24 -07:00
Yosuke Shimizu d0aad2be69 Fix f_405 2026-03-27 08:24:23 +09:00
Yosuke Shimizu 087fba94bb Fix f_404 2026-03-27 08:24:23 +09:00
John Safranek 2f1231d185 macOS Semaphore Cleanup
macOS uses GCD for threading and semaphores, but they aren't quite like
POSIX semaphores. macOS allows the use of named POSIX semaphores.

1. Convert the semaphores to named POSIX semaphores.
2. Simplify all calls for semaphores into single function calls of the
   wrapper API.
3. Update both examples/client/client.c and apps/wolfssh/wolfssh.c.
4. Update both to deregister the WINCH signal.
2026-03-17 19:26:32 -07:00
John Safranek 801ac0701d Non-constant-time password hash comparison
In wolfSSHd, the comparisons of the password hash and public keys were
using memcmp(). Changed to use ConstantCompare().

Affected functions: CheckPasswordHashUnix, CheckPublicKeyUnix.
Issue: F-53
2026-03-16 14:20:18 -07:00
John Safranek b048f18d8c
Merge pull request #885 from padelsbach/padelsbach/finding-401-402-403
Fix multibyte passwords, file mode and attrib reporting
2026-03-09 10:27:56 -07:00
JacobBarthelmeh 1e1140aa5a
Merge pull request #883 from ejohnstown/static-fixes
Static analysis fixes
2026-03-06 10:09:29 -07:00
John Safranek 3cfec8b3d2 Missing ForceZero on plaintext password copy
When a copy of the user's password is freed, it wasn't getting force
zeroed. It might still exist in the heap after getting freed.  Added
a call to `ForceZero()`.

Affected function: CheckPasswordUnix.
Issue: F-56
2026-03-05 10:45:37 -08:00