Fix fenrir findings across wolfProvider#387
Fix fenrir findings across wolfProvider#387JeremiahM37 wants to merge 7 commits intowolfSSL:masterfrom
Conversation
7c896b2 to
de5677f
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #387
Scan targets checked: wolfprovider-bugs, wolfprovider-src
No new issues found in the changed files. ✅
aidangarske
left a comment
There was a problem hiding this comment.
Please don't just fix without adding test suites and verifying the actual failures here. We should write unit tests, validate these fail correctly, then fix so we know these are fixed and now tested.
6e03c3b to
4370f76
Compare
The fixes in this PR are primarily defensive hardening, so direct testing is limited. Added tests that validate the fixed code paths. |
3530b82 to
0efbcaf
Compare
0efbcaf to
1d0fb43
Compare
dgarske
left a comment
There was a problem hiding this comment.
🐺 Skoll Code Review
Overall recommendation: APPROVE
Findings: 4 total — 3 posted, 1 skipped
Posted findings
- [Medium] test_digest_multi_update declared/registered outside WP_HAVE_DIGEST guard —
test/unit.h:120, test/unit.c:205 - [Medium] RSA TLS implicit rejection writes 48 bytes without defensive outSize check —
src/wp_rsa_asym.c:501 - [Medium] CMAC free does not call wc_CmacFree unlike GMAC's wc_AesFree addition —
src/wp_cmac.c:90-95
Skipped findings
- [Low] Inconsistent chunk max values could benefit from named constants
Review generated by Skoll via openclaw
| mask &= wp_ct_int_mask_gte(rc, 1); | ||
|
|
||
| /* Constant-time select: real result or random fallback. */ | ||
| for (i = 0; i < WOLFSSL_MAX_MASTER_KEY_LENGTH; i++) { |
There was a problem hiding this comment.
🟡 [Medium] RSA TLS implicit rejection writes 48 bytes without defensive outSize check
💡 SUGGEST question
The implicit rejection code always writes WOLFSSL_MAX_MASTER_KEY_LENGTH (48) bytes to out in the constant-time select loop (line 501), regardless of outSize. While the size query path (line 414) returns 48, ensuring callers allocate enough, there is no defensive check that outSize >= WOLFSSL_MAX_MASTER_KEY_LENGTH before the loop. A misuse (e.g., caller passes a smaller buffer) would cause an out-of-bounds write. The old code had similar assumptions but the new 48-byte unconditional write makes it more explicit. This is the TLS pre-master secret path where 48 bytes is always expected, so it's low practical risk.
Suggestion:
| for (i = 0; i < WOLFSSL_MAX_MASTER_KEY_LENGTH; i++) { | |
| Add a defensive check before the implicit rejection block: | |
| if (ok && outSize < WOLFSSL_MAX_MASTER_KEY_LENGTH) { | |
| ok = 0; | |
| } |
| @@ -91,7 +91,7 @@ static void wp_cmac_free(wp_CmacCtx* macCtx) | |||
| { | |||
There was a problem hiding this comment.
🟡 [Medium] CMAC free does not call wc_CmacFree unlike GMAC's wc_AesFree addition
💡 SUGGEST convention
The PR correctly added wc_AesFree(&macCtx->gmac.aes) in wp_gmac_free to properly release wolfSSL AES resources. However, the analogous wp_cmac_free (also modified in this PR to use OPENSSL_clear_free) does not call wc_CmacFree on the Cmac struct. wolfSSL's wc_CmacFree exists and is used in the codebase (e.g., wp_kbkdf.c:521). While the OPENSSL_clear_free zeroes memory, it doesn't run wolfSSL's cleanup for the internal AES state (which may hold hardware crypto handles on some platforms). Since this PR already touches wp_cmac_free, it would be consistent to add the wolfSSL cleanup call here too.
Suggestion:
| { | |
| static void wp_cmac_free(wp_CmacCtx* macCtx) | |
| { | |
| if (macCtx != NULL) { | |
| #ifndef HAVE_FIPS | |
| wc_CmacFree(&macCtx->cmac); | |
| #endif | |
| OPENSSL_cleanse(macCtx->key, macCtx->keyLen); | |
| OPENSSL_clear_free(macCtx, sizeof(*macCtx)); | |
| } | |
| } |
Description
Fixes F-174, F-175, F-176, F-186, F-187, F-188, F-260, F-261, F-262, F-263, F-272, F-273, F-274, F-400, F-399, F-505, F-506, F-507, F-508, F-509, F-831, F-832, F-833, F-834, F-1626, F-1627, F-1628, F-1635, F-1639, F-1640, F-1641, F-1642, F-1643
inputs
copy-paste errors
derive (constant-time)
implicit rejection
New Tests
incorrectly matches "rsa-factor1" on master
accepted on master