Uh oh!
There was an error while loading. Please reload this page.
Deduplication and type checking - #1159
Conversation
stenslae
commented
Aug 11, 2026
- Added authorized_key type checking extract the embedded key type directly from the SSH wire-format blob rather than using wolfSSH_QueryKey().
- Added a makeKey function pointer to CompositeTradOps.
- Deduplicated ECDSA Encoding
- Introduced WOLFSSH_MLDSA_COMPOSITE_ID_CASES for redundant switch cases.
- Centralized maximum public key sizing behind a new WOLFSSH_MLDSA_MAX_PUB_KEY_SZ macro
- Switched to dynamically allocating MlDsaKey and large public key buffers in wolfSSH_MakeMlDsaCompositeKey() and GetOpenSshKeyMlDsaComposite() when WOLFSSH_SMALL_STACK is defined.
- Added test coverage
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1159
Scan targets checked:wolfssh-bugs, wolfssh-src
Findings: 5
5 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
fc3c6e8 to
8000746Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1159
Scan targets checked:wolfssh-bugs, wolfssh-src
Findings: 7
7 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
8000746 to
818f77bCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1159
Scan targets checked:wolfssh-bugs, wolfssh-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
818f77b to
6f506d2Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1159
Scan targets checked:wolfssh-bugs, wolfssh-src
Findings: 4
4 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
| /* Declared type length (12) matches the token and the 8 bytes that | ||
| * follow are the token's own prefix, so the XMEMCMP can't reject on | ||
| * content: only the typeStrSz > keyCandSz - 4 bound can. */ | ||
| static const char truncType[] = "rsa-sha2-256"; |
There was a problem hiding this comment.
🔵 [Low] Truncated-blob test never reaches the bound it claims to cover · Weak or missing assertions
The line token rsa-sha2-256 is mapped by AuthKeysTokenKeyType() to ssh-rsa, so keyTypeSz is 7 while the blob declares 12; typeStrSz != keyTypeSz rejects first and the typeStrSz > keyCandSz - 4 bound in CheckAuthKeysLine() stays untested. Deleting that bound leaves the suite green.
Fix: Use a non-aliased token whose length equals the declared type length, e.g. token "ssh-rsa" with blob { 0,0,0,7, 's','s','h' }.
| /* ML-DSA listed first (post-quantum priority), then ECDSA, ED25519, RSA. */ | ||
| static const char cannedKeyAlgoNames[] = | ||
| #ifndef WOLFSSH_NO_MLDSA_COMPOSITES | ||
| #if !defined(WOLFSSH_NO_MLDSA87) && defined(HAVE_ED448) |
There was a problem hiding this comment.
🔵 [Low] WOLFSSH_NO_MLDSA_COMPOSITES not applied to cannedKeyAlgoClient · Logic errors
The new WOLFSSH_NO_MLDSA_COMPOSITES option guards cannedKeyAlgoNames and cannedKeyAlgoNamesHostKey but not cannedKeyAlgoClient, so composite IDs still match in DoUserAuthRequestPublicKey() and DoExtInfoServerSigAlgs() while WS_GetCompositeParams() now always returns WS_NOT_COMPILED.
Fix: Wrap the six composite ID entries in cannedKeyAlgoClient with #ifndef WOLFSSH_NO_MLDSA_COMPOSITES.
| * content: only the typeStrSz > keyCandSz - 4 bound can. */ | ||
| static const char truncType[] = "rsa-sha2-256"; | ||
| static const byte truncatedBlob[] = { | ||
| 0x00, 0x00, 0x00, 0x0c, 'r', 's', 'a', '-', 's', 'h', 'a', '2' |
There was a problem hiding this comment.
🔵 [Low] Truncated-blob test never reaches the new out-of-bounds guard in CheckAuthKeysLine · Missing edge-case coverage on a function the PR also changed
The vector declares a 12-byte type length while the normalized line type ssh-rsa is 7, so typeStrSz != keyTypeSz short-circuits first and the typeStrSz > keyCandSz - 4 guard at auth.c:332 is never exercised. That guard is the only thing preventing XMEMCMP from reading past the decoded keyCand heap allocation.
Fix: Use a vector where the declared type length equals the line type length but exceeds keyCandSz - 4, e.g. line type ssh-ed25519 with blob {0,0,0,11,'x','x','x','x'}.
| ret = WS_FATAL_ERROR; | ||
| /* Skip, don't abort: an option-prefixed line puts a | ||
| * non-base64 token here (e.g. "no-pty ssh-rsa ..."). */ | ||
| ret = WSSHD_AUTH_FAILURE; |
There was a problem hiding this comment.
🔵 [Low] Fail-soft malformed-line handling applied only to the Base64 branch · Privilege escalation in wolfsshd
Base64 decode failure now yields WSSHD_AUTH_FAILURE so the scan continues, but the sibling tokenization failure at lines 293–298 still returns WS_FATAL_ERROR, which makes SearchKeysFile abort the whole file. A single whitespace-free non-comment line in authorized_keys therefore denies auth for every key listed after it; the new SearchForPubKey malformed-line test uses a two-token line and does not cover this.
Fix: Return WSSHD_AUTH_FAILURE for tokenization failures as well, and add a single-token-line case to test_SearchForPubKey.