Security
- Enforce the RFC 7518 section 3.3 minimum 2048-bit RSA modulus in
cjose_jwk_create_RSA_randomandcjose_jwk_create_RSA_spec; note that sub-2048-bit RSA keys are now rejected at creation/import time (#36, ported from cisco#136); thanks @kunqn - Additional hardening and correctness fixes from a follow-up bug-hunt audit:
- Free the RSA factor/CRT
BIGNUMs and reject an incomplete private-key parameter set on JWK import (OpenSSL >= 1.1) instead of silently dropping and leaking them; adds a regression test - Take the JWS import copy-helper length as
size_tso the (deliberatelysize_t) compact serialization dot-scan offsets are no longer truncated back throughint - Parse the shared
"unprotected"header incjose_jwe_import_json(it was silently dropped), restoring symmetry withcjose_jwe_export_json - Decode/encode a top-level scalar JSON value in
cjose_header_set_raw/cjose_header_get_raw(JSON_DECODE_ANY/JSON_ENCODE_ANY), so e.g. an RFC 7797"b64":falseheader round-trips - Propagate
_cjose_jws_build_cserfailure out ofcjose_jws_export(it returnedtruewith a possibly-NULL*compact) and seterrwhen the serialization components are missing - Clear
erron a successfulalg:"none"cjose_jws_importso it is not left holding theINVALID_ARGrecorded while rejectingnoneas a signing algorithm - Free the RSA
BIGNUMs ifRSA_set0_keyis refused, and free theRSAin_RSA_newwhen the JWK allocation fails, closing two out-of-memory leaks on the RSA key path (OpenSSL >= 1.1) - Free the temporary string in
_cjose_json_stringnwhenjson_stringfails (jansson <= 2.6) - Guard the base64 encode size calculation against
size_toverflow, matching the decode side - Reject an empty
"crit"header list in_cjose_header_validate_crit(RFC 7515 section 4.1.11) - Skip the zeroing
memsetin_cjose_jwe_mallocfor a zero-byte request (memset(NULL, 0, 0)is undefined behaviour ifmalloc(0)returned NULL) - Drop a duplicated
enc_ivbase64url conversion in_cjose_convert_to_base64(no-op cleanup) - Size the AES-CBC plaintext buffer in
size_tto avoid a signed-intoverflow nearINT_MAX - Drop a dead store of the end pointer after the final write in
concatkdfotherinfo assembly - Run the base64 decode length sanity check before publishing the output pointer, so its (currently unreachable) failure path cannot leave
*outputdangling at freed memory - Lower-bound the
ktyargument incjose_jwk_name_for_ktyso a value belowCJOSE_JWK_KTY_RSAcannot index the key-type name table out of bounds - Correct the documented contract of
cjose_const_memcmp(equal/not-equal, not ordered) and note that_cjose_strndupcopies exactlylenbytes (it is not POSIXstrndup)
- Free the RSA factor/CRT
Bugfixes
- Initialize the decoded buffer lengths up front in the JWK import error paths; reading them uninitialized broke the clang
-Werrorbuild since v0.6.2.6 (#32); thanks @kraj - Use a portable thread-local storage specifier in
error.cso the OpenSSL error buffer builds with MSVC.
The RPM packages below are signed with the following RSA PGP key:
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBGh53lgBCADCyoOkfnE5h5rBLlf02oFpI/z2vUXK5W4T56xnNPu0/iIOxbBk
YX9rSypZFhfjv28lhGgelWEg28Ab/Yxs6l0obCgDEuFUDQ5Dv+N+YSMy67vtLwYW
9LM5p9fMN9bXOa62PwvtzRzh+xRyRBcIfMacGJC+SqUK6QhzC0lNwCsr1OaWjzon
mkaodwrloNMxEZVvFn63PvuQDZ3wwQty+0XpYiiChMssGBn6nmPDQJ7pDtQDkhfD
Z5FKY6K7AQJ4fneiVCLGngPBwTXBGcfWa+Y0HCS2ghQwDO6jYXd5GjowVDTjfMK3
QJ3e26Ox9X3V0Fl04R1i5EthEkAWGfy1lksvABEBAAG0HU9wZW5JREMgPHN1cHBv
cnRAb3BlbmlkYy5jb20+iQFRBBMBCgA7FiEEFdjWJA1IGDkAITSxnyZY1L0OSOMF
Amh53lgCGwMFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQnyZY1L0OSONG
Jgf+II0wG96R0g28Kp+R4AYzSdX0CEqr6OhwHHw4cFpLsHxZNhojo7I4OnLKEdfc
lFl37rE+hG3QpzD/b4S/fpPjd4hcLkguBQxtdxqZZVAIT8HWbveHRkI8MNnjOPwv
Hy6jBncMs1IT/URV2si/Q34+PLo8tvo/lXNa16svVl2DoYXO8MCszgCE1bx055EF
XPh4Teu5Y4OLHECSicMxrmN746dAD121zy4bLLx9mZ0erhLjvkj1vkFmlHFKyvwY
/pbSqXs9hW/wweW1oQ/xEIJWWS71PeoutUBjr0WC4sILnR5PBPZplgNh297Qex6g
qaW3io0tCH9KxU1tXYn/iL/hbQ==
=mlOy
-----END PGP PUBLIC KEY BLOCK-----