Commit Graph

2678 Commits (8d97ee9250d4b83fefa0479a99516da45e31ad45)

Author SHA1 Message Date
John Safranek 0b37d43239 Add x509 interop CI workflow
- Build PKIX-SSH and run wolfSSHd against the PKIX-SSH ssh/sftp
  clients using x509 user certs.
- Posts an issue if the test fails.
2026-05-28 08:48:13 -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
Yosuke Shimizu 4ae8eee109 Add tests for DoUserAuthRequestRsa and DoUserAuthRequestRsaCert 2026-05-27 14:44:10 -07:00
Yosuke Shimizu b9dfa042bf Add scpDirDepth as depth guard and Add unit tests 2026-05-27 14:06:18 -07:00
Yosuke Shimizu 3b867e7313 Add unit tests and regress tests 2026-05-27 11:13:54 -07:00
John Safranek fd29780c8e DoProtoId: case-sensitive SSH- prefix match
- Per RFC 4253 4.2 use WSTRNCMP instead of WSTRNCASECMP for
  prefix and full-ID comparisons.
- Update client tests; add server test vectors expecting
  rejection of lowercase/mixed case.

Issue: F-2865
2026-05-21 11:42:43 -07:00
John Safranek be4aa445d5 DoNewKeys: reject NEWKEYS with non-empty payload
- Reject SSH_MSG_NEWKEYS when len != 0 per RFC 4253 7.3.
- Update wolfSSH_TestDoNewKeys to take buf/len/idx instead
  of assuming NULL/0, and add a non-zero len test case.

Issue: F-2079
2026-05-21 11:42:43 -07:00
John Safranek 63a63cf0fb CERTMAN_VerifyCerts_buffer: reject certsCount=0
- Without the guard, inner loops short-circuit and WS_SUCCESS
  is returned without any verification.
- Add test case covering the new and existing bad-arg paths.

Issue: F-409
2026-05-21 11:42:43 -07:00
John Safranek 80c3a0e61a wolfSSH_DoControlSeq: tighten escBuf bounds
- Guard escBuf[i] read when getArgs consumes all input without a command.
- Cap WMEMCPY against WOLFSSL_MAX_ESCBUF; escBufSz can exceed 16.
- Update escBufSz on WS_WANT_READ resume so CSI leftovers survive
  multi-fill reads.

Issue: F-250
2026-05-21 11:42:43 -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 bcbb8e1ad7 DoKexInit: enforce zero KEXINIT reserved field
- Per RFC 4253 7.1 the reserved field is uint32 0, not a length
  prefix; reject non-zero values with WS_PARSE_E.
- Add regression test.

Issue: F-869
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 b45aed9639 DoKexInit: set ret on host-key algo mismatch
- Replace mid-function return so end-of-function cleanup runs.

Issue: F-3204
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
John Safranek e8793bb268 UTF-8 -> 7-bit ASCII cleanup
1. replace section symbol with 'sec'
2. replace right arrow with '->'
3. replace m-dash with '--'
4. replace less-than-equatal-to with '<='
2026-05-18 14:35:58 -07:00
Yosuke Shimizu 67496a385d Fix minor issues and Add unit tests 2026-05-18 14:02:52 -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
John Safranek b583c0a225 Update wolfSSL version in ML-KEM and Thread tests
1. Update WOLFSSL_REF to v5.9.1-stable in the ML-KEM and single-thread
   tests (interop-mlkem.yml, singlethread-check.yml).
2. Drop kyber.yml; its coverage is a strict subset of interop-mlkem.yml.
   Fold its push and workflow_dispatch triggers into interop-mlkem.yml so
   ML-KEM still runs on master/release pushes and via manual dispatch.
3. Drop liboqs from the ML-KEM test. It isn't in configure.ac any more.
2026-05-18 11:04:51 -07:00
John Safranek 162dd7fbc6 Test ForceZero of secrets in free and DH KEX
- Add retain-on-free and size-tracking capture allocators to inspect
  freed buffers post-free.
- Verify SshResourceFree zeroes ssh->k, ssh->keys, and ssh->peerKeys
  before wolfSSH_free releases the struct.
- Verify KeyAgreeDh_client wipes ssh->handshake->x even when wc_DhAgree
  fails (ForceZero is unconditional).
- Verify KeyAgreeDh_server zeroes the MAX_KEX_KEY_SZ y_ptr allocation
  under WOLFSSH_SMALL_STACK via 0xCC poisoning.
- Expose KeyAgreeDh_client / KeyAgreeDh_server via wolfSSH_Test* hooks
  under WOLFSSH_TEST_INTERNAL.

Issues: F-2488, F-2492, F-2493, F-2875
2026-05-14 14:42:20 -07:00
Yosuke Shimizu fb1aa6daba Fix minor issues and Add test vectors 2026-05-14 09:36:43 -07:00
John Safranek 4b948e68cf sftp: NULL fName after free in all readdir variants
- Apply the prior FATFS fix across Nucleus, MQX, Windows,
  Zephyr, Harmony, and user-filesystem readdir paths.
- Prevents double-free crash when SFTPNAME_free runs on a
  name struct after readdir returns an error.
2026-05-13 16:25:46 -07:00
Jan Goldacker 0169eb4544 Fix SFTP_GetAttributes with fatfs for root 2026-05-13 15:32:25 -07:00
Jan Goldacker 0838634aab set fName to NULL after free
otherwise wolfSSH_SFTPNAME_free would crash afterwards
2026-05-13 15:31:30 -07:00
Jan Goldacker c68829901d stop on end-of-dir 2026-05-13 15:31:30 -07:00
John Safranek c2f40e0743 Convert FatFS date/time to Unix timestamp in SFTP
- Add SetAttrTime() helper to decode fdate/ftime into a Unix
  timestamp via mktime() and assigns it to atr->atime/mtime.
- Use it from both SFTP_GetAttributes() (was using raw fdate) and
  SFTP_GetAttributes_Handle() (was using raw ftime, losing the date).
2026-05-13 14:03:00 -07:00
Yosuke Shimizu 7d4fa32ce5 Fix minor issues and add unit test for IdentifyAsn1Key 2026-05-13 09:12:20 -07:00
John Safranek bd75cb4069 Pin expectMsgId after KEXDH_GEX_GROUP
- Set expectMsgId to MSGID_KEXDH_GEX_INIT so the server rejects
  any other KEX message at this stage (RFC 4419 sec 3).
- Reject NULL ssh->handshake in the entry check now that the
  success path dereferences it.

Issue: F-3668
2026-05-12 21:39:33 -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
John Safranek 11e407f7db Zero lastBlock buffers in GenerateKey
- Add ForceZero on lastBlock in both remainder paths
- Prevents leftover key-derivation material on the stack

Issue: F-2494
2026-05-12 21:39:33 -07:00
John Safranek 8854fd70a9 Zero key buffers on load failure
- ForceZero newKey before WFREE in DoPemKey/DoOpenSshKey,
  covering both locally-allocated and caller-supplied buffers.
- ForceZero PEM file buffer after read in wolfSSH_ReadKey_file
- Track newKeySz for caller-supplied buffer path

Issue: F-2885, F-3211, F-3212
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 6e6995980e Fix integer underflow in SFTP RecvRead bound check
- Replace `strSz > maxSz - WOLFSSH_SFTP_HEADER - idx`
  with `strSz > WOLFSSH_MAX_SFTP_RW` to prevent unsigned
  wraparound and downstream WMALLOC size overflow.
- Apply to both POSIX and Windows variants.

Issue: F-3682
2026-05-11 22:28:44 -07:00
John Safranek 8231703875 Fix Ed25519 user-auth verify and add unit test
- Map ed25519 verify_msg_final errors to WS_CRYPTO_FAILED
  and status==0 to WS_ED25519_E (no longer overwritten)
- Expose DoUserAuthRequestEd25519 via test shim
- Add unit test covering valid and tampered signatures

Issue: F-3445
2026-05-11 22:28:44 -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 b7c644f92a github/workflows: upgrade actions to Node.js 24 versions 2026-05-11 22:27:00 -07:00
Yosuke Shimizu a5eb03c01b Add integration test for wrong ECC signature scenario 2026-05-11 16:25:21 -07:00
John Safranek 60de6ff9c5 rekey: trigger highwater on per-key packet count
- Track txMsgCount/rxMsgCount per key epoch and reset on NEW_KEYS;
  seq/peerSeq still wrap freely per RFC 4253 Sec 6.4.
- Extend HighwaterCheck to fire highwaterCb when packet count crosses
  msgHighwaterMark (default 2^31, RFC 4344 Sec 3.1).
- Add wolfSSH_CTX_SetMsgHighwater / SetMsgHighwater / GetMsgHighwater.
- Consolidate receive-path HighwaterCheck into DoPacket so byte- and
  packet-count thresholds share a single canonical fire site.

Issue: F-246
2026-05-11 12:29:21 -07:00
John Safranek 978ef5c609 DoDisconnect/DoUnimplemented: validate payload
- Replace raw ato32() with GetUint32() to check len.
- Return WS_BUFFER_E on short payload instead of reading
  past buffer end.
- DoDisconnect: parse the description and language identifier
  strings with GetSkip() so a truncated record returns
  WS_BUFFER_E instead of being treated as success.

Issue: F-413
2026-05-08 12:26:36 -07:00
John Safranek aef3e8661a fix config_print to show pubKeyFile
Issue: F-214
2026-05-08 12:26:36 -07:00
John Safranek 9ea6c7930d free unicodeOldName on error paths
WS_MoveFileA allocated unicodeOldName but did not free it when the
follow-up mbstowcs_s calls failed. Check the conversion result after
filling unicodeOldName, and free it before returning when the sizing
call for unicodeNewName fails.

Affected function: WS_MoveFileA.
Issue: F-50
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 a8a443214b Add independent ciper and MAC algorithms negotiation for each direction, And add regress test 2026-05-08 10:26:22 -07:00
Yosuke Shimizu 1843f84d91 Fix cursor mode handling 2026-05-08 10:16:51 -07:00
Yosuke Shimizu 788ab6d282 Delete unnecessary statement 2026-05-08 10:16:51 -07:00
Yosuke Shimizu a2d4973060 Fix mac comparison in VerifyMac 2026-05-08 10:16:51 -07:00
Yosuke Shimizu dc914afd73 Fix minor issues 2026-05-08 09:59:00 -07:00
John Safranek ee59f314d3 sftp: check DoStatus return in DoName
Capture the return value, clear state unconditionally, and report
parse failure or non-OK server status via ssh->error instead of
discarding the result.

Issue: CID 572873
2026-05-07 10:04:14 -07:00
John Safranek e931db6668 sftp: check ParseAttributes return in RecvOpen
Set ret = WS_BAD_FILE_E and jump to cleanup on parse failure
instead of ignoring the return value.

Issue: CID 645982
2026-05-07 10:04:14 -07:00