20260727-fips-dev-no-post - #11031
Conversation
|
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11031
Scan targets checked: linuxkm-bugs, linuxkm-src, wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
Findings: 5
4 finding(s) posted as inline comments (see file-level comments below)
Medium (1)
Unguarded verifyCore reference in non-PIE FIPS seg_map under WOLFSSL_FIPS_DEV_NO_POST
File: linuxkm/module_hooks.c:1291
Function: seg_map (file-scope, #elif defined(HAVE_FIPS) branch)
Category: Incorrect error handling
The extern declaration of verifyCore (line 119) is now gated with !defined(WOLFSSL_FIPS_DEV_NO_POST), and the primary seg_map initializer (line 1223) got the matching && !defined(WOLFSSL_FIPS_DEV_NO_POST) guard, but the parallel seg_map used when WC_SYM_RELOC_TABLES is undefined (line 1290) was not updated to match, so it references the undeclared verifyCore symbol when building with --enable-fips=dev-no-post and PIE reloc tables disabled.
Recommendation: Add && !defined(WOLFSSL_FIPS_DEV_NO_POST) to the #if at line 1290, matching line 1223.
Referenced code: linuxkm/module_hooks.c:1291-1294 (4 lines)
This review was generated automatically by Fenrir. Findings are non-blocking.
| #ifdef WOLFSSL_CHECK_MEM_ZERO | ||
| XMEMSET(&spc, 0, sizeof(spc)); | ||
| wc_MemZero_Add("falcon sign spc", &spc, sizeof(spc)); | ||
| XMEMSET(spc, 0, sizeof(spc)); |
There was a problem hiding this comment.
🟠 [Medium] sizeof(pointer) used instead of sizeof(struct) for falcon sampler context · Incorrect sizeof/type usage
spc is declared via WC_DECLARE_VAR, which expands to a pointer under WOLFSSL_SMALL_STACK. sizeof(spc) there yields the pointer size, not sizeof(falcon_sampler_ctx), so the pre-zero and wc_MemZero_Add registration only cover a few bytes instead of the whole struct.
Fix: Use sizeof(*spc) in both calls, matching the correct usage later at ForceZero(spc, sizeof(*spc)).
| #endif | ||
|
|
||
| #ifdef WC_DH_INITIAL_RUNTIME_ENABLEMENT | ||
| static volatile int wc_dh_enabled = WC_DH_INITIAL_RUNTIME_ENABLEMENT; |
There was a problem hiding this comment.
🔵 [Low] Non-atomic global enable/disable flag for DH runtime enablement · Race conditions
wc_dh_enabled is a plain volatile int read-then-written without synchronization in wc_dh_enable/wc_dh_disable, so concurrent callers can both observe it disabled, both enable it, and later independently disable it out from under one another.
Fix: Protect the flag with an atomic compare-and-swap or mutex, or convert it to a reference count.
|
|
||
| #ifdef WC_DH_INITIAL_RUNTIME_ENABLEMENT | ||
| if (! wc_dh_enabled) | ||
| return FIPS_NOT_ALLOWED_E; |
There was a problem hiding this comment.
🔴 [High] wc_InitDhKey_ex leaves mp_ints uninitialized on runtime-disabled DH path, causing invalid free in wc_FreeDhKey · Incorrect error handling
When WC_DH_INITIAL_RUNTIME_ENABLEMENT is defined and DH is runtime-disabled, wc_InitDhKey_ex returns FIPS_NOT_ALLOWED_E before calling mp_init_multi(), leaving key->p, key->g, key->q, key->pub, and key->priv as raw uninitialized memory. Callers such as AllocKey/FreeKey in src/internal.c allocate the DhKey with a non-zeroing XMALLOC and unconditionally call wc_FreeDhKey() on init failure, which calls mp_clear() on these uninitialized mp_ints, dereferencing/freeing garbage pointers.
Fix: Call mp_init_multi() (or XMEMSET-zero the mp_int fields) before checking wc_dh_enabled, so a disabled-DH failure still leaves the key in a state safe to free.
| /* Note iv is an optional arg to wc_AesGcmInit(), so we tolerate zero ivSz | ||
| * here. | ||
| */ | ||
| if ((ret == 0) && (ivSz > 0) && (ivSz < GCM_NONCE_MID_SZ)) |
There was a problem hiding this comment.
🟠 [Medium] FIPS short-nonce rejection wrongly applied to streaming GCM decryption · Cryptographic correctness
wc_AesGcmInit now rejects ivSz < GCM_NONCE_MID_SZ with FIPS_BAD_VALUE_E, but wc_AesGcmDecryptInit forwards directly to it, so streaming decryption of legitimately short (8-byte) nonces now fails, contradicting the explicit decrypt-side exception documented in wc_AesGcmDecrypt in the same PR.
Fix: Skip the short-nonce FIPS check in wc_AesGcmInit when called via wc_AesGcmDecryptInit, mirroring the exemption in wc_AesGcmDecrypt.
tested with