From: Luca Boccassi Date: Mon, 29 Jun 2026 13:01:08 +0000 (+0100) Subject: fido2: reject zero-length HMAC secret X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a3bf0f2f860ff9e73c9062d9f3c400bc672496ac;p=thirdparty%2Fsystemd.git fido2: reject zero-length HMAC secret The CTAP2 HMAC-SECRET output should never be zero length, so enforce that at both retrieval sites. Follow-up for 1c0c4a43c6118aa4057222789e4b777b61e4bb27 --- diff --git a/src/shared/libfido2-util.c b/src/shared/libfido2-util.c index 4a0d7e6d647..07bea6658ec 100644 --- a/src/shared/libfido2-util.c +++ b/src/shared/libfido2-util.c @@ -622,6 +622,8 @@ static int fido2_use_hmac_hash_specific_token( return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to retrieve HMAC secret."); hmac_size = sym_fido_assert_hmac_secret_len(a, 0); + /* Should never be zero, sanity check */ + assert(hmac_size > 0); hmac_copy = memdup(hmac, hmac_size); if (!hmac_copy) @@ -1160,6 +1162,8 @@ int fido2_generate_hmac_hash( return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to retrieve HMAC secret."); secret_size = sym_fido_assert_hmac_secret_len(a, 0); + /* Should never be zero, sanity check */ + assert(secret_size > 0); secret_copy = memdup(secret, secret_size); if (!secret_copy)