Skip to content

Harden COSE decoding, key attachment, scratch buffer and zeroization paths and close MISRA findings - #97

Open
aidangarske wants to merge 53 commits into
wolfSSL:mainfrom
aidangarske:fenrir-fixes-17413-17445-13637-14972-14973-14974-14994-17424-18398
Open

aidangarske wants to merge 53 commits into
wolfSSL:mainfrom
aidangarske:fenrir-fixes-17413-17445-13637-14972-14973-14974-14994-17424-18398

Conversation

@aidangarske

Copy link
Copy Markdown
Member
  • Decoders skipped or mis-bounded some header maps, recipient bodies and PSA claims. Skipped maps are now validated and bounded, duplicate labels are rejected, and truncated or empty containers report a malformed message.
  • Several APIs accepted inputs that RFC 9052 and RFC 9053 rule out, such as a detached payload when the message carries its own, or a missing or mismatched key attachment. These now fail closed with an argument error.
  • Every create, verify and decrypt API now rejects a scratch buffer that overlaps any input or output, including the returned header, payload pointer and length objects. The check is one O(1) address comparison under deviation D-11.4-001.
  • HMAC contexts, the ECDH-ES HKDF PRK, AES key wrap contexts and cached ML-DSA private vectors are wiped after use, and the zeroize tests count each expected wipe.
  • A failed public CBOR encode or decode leaves the cursor unchanged. A failed HPKE-0-KE recipient open still runs the content cipher, so a wrong key and a tampered tag fail the same way.
  • The CBOR float encoders require IEEE 754 binary32 and binary64 at build time. They also check the stored byte order at run time and return WOLFCOSE_E_UNSUPPORTED on a mismatch.
  • MISRA cleanups: explicit size_t, uint64_t and int conversions, dead initializers removed, library byte arrays initialized from hex bytes, and const inputs copied before non-const wolfCrypt calls.
  • The Rule 14.2 status-guarded loop deviation is proven by scripts/check_loops.py, which reads clang's AST and fails closed on any loop it cannot prove. A second AST check keeps library byte arrays off string literals. Both run in the MISRA workflow with self-tests.
  • No public API signature changes. The new rejections return WOLFCOSE_E_INVALID_ARG or WOLFCOSE_E_CBOR_MALFORMED for inputs that were already invalid.
F-17413, F-13637, F-17424, F-14972, F-14973, F-14974, F-18398, F-14994, F-18434, 
F-14976, F-14995, F-17461, F-17462, F-15038, F-17463, F-17464, F-17465, F-17466, F-17467, F-17468, F-17469, F-18437, F-18399, F-18475, F-17445, F-18473, F-14977, 
F-14978, F-14980, F-15104, F-14979, F-17509, F-17516, F-17517, F-17495, F-18429, 
F-18474, F-18461, F-17471, F-15047, F-15048, F-15049, F-17460, F-15050, F-15112, 
F-18397, F-18425, F-15043, F-15045, F-18439, F-18476, F-15103, F-14996

@aidangarske aidangarske self-assigned this Nov 30, 2026
@aidangarske
aidangarske force-pushed the fenrir-fixes-17413-17445-13637-14972-14973-14974-14994-17424-18398 branch from a95f518 to fc577b2 Compare November 30, 2026 19:56

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants