Zero EncryptedInfo in ProcessChainBufferCRL and reset info->set on parse - #11046
Zero EncryptedInfo in ProcessChainBufferCRL and reset info->set on parse#11046yosuke-wolfssl wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Ready to approve
The changes are narrowly scoped, directly address an unsafe uninitialized-state path, and include targeted regression tests that exercise the affected code paths.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Fixes a reachable uninitialized-read / uninitialized-callback path when parsing PEM CRLs in certificate chains by ensuring EncryptedInfo state is deterministically initialized and cannot retain stale “encrypted” flags across parses.
Changes:
- Zero-initialize
EncryptedInfoinProcessChainBufferCRL()before callingPemToDer(). - Reset
info->seton entry towc_EncryptedInfoParse()as defense-in-depth against stale state. - Add regression tests covering the CRL-in-chain fall-through and a deterministic
wc_PemToDer()CRL case with a dirtiedinfo.set.
File summaries
| File | Description |
|---|---|
| wolfcrypt/src/asn.c | Ensures EncryptedInfo parse always starts with set = 0, preventing stale “encrypted” state from influencing PemToDer() behavior. |
| src/ssl_load.c | Zeroes stack EncryptedInfo in the CRL chain parsing path to avoid reading stack residue. |
| tests/api.c | Adds coverage for the CRL fall-through path and a targeted regression test for stale info.set with CRL_TYPE. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11046
Scan targets checked: wolfcrypt-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
No new issues found in the changed files. ✅
Problem
ProcessChainBufferCRL()declared a stackEncryptedInfoand passed it toPemToDer()without zeroing it — unlike every other caller in the tree. A PEM CRL carries noProc-Type:header, sowc_EncryptedInfoParse()returns without ever writinginfo->set, leavingPemToDer()to read stack residue. When that residue is non-zero:encrypted_keyis set spuriously.info->passwd_cbis then invoked through the uninitialized pointer, with an uninitialized argument, on a path that should never touch password callbacks.Reachable from the public
wolfSSL_CTX_load_verify_buffer()withWOLFSSL_FILETYPE_PEM.--enable-wpasalone enables all three required macros (WOLFSSL_WPAS,HAVE_CRL,WOLFSSL_ENCRYPTED_KEYS) — the configuration used to link wpa_supplicant/hostapd.Fix (
src/ssl_load.c)WOLFSSL_MSG("Trying a CRL"); + XMEMSET(&info, 0, sizeof(info)); ret = PemToDer(buff, sz, CRL_TYPE, &der, NULL, &info, NULL);Defense in depth in
wolfcrypt/src/asn.c:wc_EncryptedInfoParse()now clearsinfo->seton entry, so no future caller can be bitten by a stale flag.sethas exactly two references tree-wide, so nothing relied on it persisting across a parse.Closes f-7352.
Tests (
tests/api.c)test_wolfSSL_CTX_load_verify_buffer_pem_crl— first coverage of the CRL-in-chain fall-through. Loadsca-cert.pem+crl/crl.pemas one PEM buffer and asserts the CRL actually reached the cert manager.test_wc_PemToDerpassing a deliberately dirtiedinfo.set = 1withCRL_TYPE. This is the deterministic regression guard: it needs no sanitizer and runs in ordinary builds. Appended last and re-zeroed so it cannot contaminate the existing assertions.Verification
--enable-all--enable-wpas --enable-opensslextramake check, both configsNegative controls: reverting the
asn.creset makes the newwc_PemToDercase fail withNO_PASSWORD(-176) and nothing else. Forcing worst-case residue with both fixes reverted aborts the suite with SIGBUS on the indirect call, confirming the reported impact. ASan + UBSan clean; no warnings under-Werror.