Using KBKDF with KMAC causes dereference of NULL function pointer #24410
Labels
branch: master
Merge to master branch
branch: 3.2
Merge to openssl-3.2
branch: 3.3
Merge to openssl-3.3
severity: important
Important bugs affecting a released version
triaged: bug
The issue/pr is/fixes a bug
When using KMAC with KBKDF without a key (or a zero-length key), a
NULL function pointer is dereferenced. Here are the breadcrumbs that lead to
the SEGV:
https://github.com/trail-of-forks/openssl/blob/104c9b57ce9fafcdc2650259e726633566b9c479/providers/implementations/kdfs/kbkdf.c/#L305
https://github.com/trail-of-forks/openssl/blob/104c9b57ce9fafcdc2650259e726633566b9c479/providers/implementations/kdfs/kbkdf.c/#L269
https://github.com/trail-of-forks/openssl/blob/104c9b57ce9fafcdc2650259e726633566b9c479/providers/implementations/macs/kmac_prov.c/#L353
https://github.com/trail-of-forks/openssl/blob/104c9b57ce9fafcdc2650259e726633566b9c479/crypto/evp/digest.c/#L427-L428
The main reason for this is because if the key is not set or zero-length then the digest is not initialized before usage: https://github.com/trail-of-forks/openssl/blob/104c9b57ce9fafcdc2650259e726633566b9c479/providers/implementations/kdfs/kbkdf.c/#L421-L426
Here is a test-case that shows the SEGV:
tested on 0fff6a2
Backtrace:
Related note:
The text was updated successfully, but these errors were encountered: