]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fido2: reject zero-length HMAC secret
authorLuca Boccassi <luca.boccassi@gmail.com>
Mon, 29 Jun 2026 13:01:08 +0000 (14:01 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 30 Jun 2026 10:49:53 +0000 (11:49 +0100)
The CTAP2 HMAC-SECRET output should never be zero length, so enforce
that at both retrieval sites.

Follow-up for 1c0c4a43c6118aa4057222789e4b777b61e4bb27

src/shared/libfido2-util.c

index 4a0d7e6d6475429ae1d4a1ce9e66b14fa326f13c..07bea6658ec45ac9b7679d0fd6ccbbd270243fd7 100644 (file)
@@ -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)