Bug 2175145

Summary: In FIPS mode, openssl should always run the PBKDF2 lower bounds checks or provide an indicator when the pkcs5 parameter is set to 1
Product: Red Hat Enterprise Linux 9 Reporter: Clemens Lang <cllang>
Component: opensslAssignee: Clemens Lang <cllang>
Status: CLOSED ERRATA QA Contact: Alicja Kario <hkario>
Severity: high Docs Contact:
Priority: urgent    
Version: 9.0CC: cllang, dbelyavs, hkario, ssorce
Target Milestone: rcKeywords: Triaged, ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: openssl-3.0.7-17.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 2178137 2178138 2178139 (view as bug list) Environment:
Last Closed: 2023-11-07 08:53:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2178137, 2178138, 2178139    
Attachments:
Description Flags
Reproducer for arbitrary KDFs (now supports PBKDF2 and setting the pkcs5 property for PBKDF2) none

Description Clemens Lang 2023-03-03 11:01:32 UTC
Description of problem:
SP 800-132 and FIPS 140-3 IG D.N define 4 checks that need to be performed by the module when performing PBKDF key derivation.

These checks are implemented in OpenSSL 3, but they can be bypassed by setting the "pkcs5" parameter (see https://www.openssl.org/docs/man3.0/man7/EVP_KDF-PBKDF2.html) to 1. When this parameter is set, the module must return a non-approved service indicator. Alternatively, this parameter could be ignored (i.e. always perform the checks). Note that ignoring the parameter and always running the checks will require adjusting the tests, since some of them fail.

Additionally, the OpenSSL 3 PBKDF2 self-test uses a 5 byte salt length, which is below the minimum of 16 bytes required by SP 800-132 section 5.1.


Version-Release number of selected component (if applicable):
openssl-3.0.1-46.el9_0

How reproducible:
Run the attached reproducer with the last parameter set to 1, and see that it will support a lower limit than required.

Steps to Reproduce:
1. Approved as expected:
$(head -1 kdf2.c | sed -E 's#^// ##g') && ./kdf2 PBKDF2 SHA256 HMAC 16 0 8 14 0
ERR Failed to duplicate EVP_KDF_CTX, this may be unsupported by your version of OpenSSL; using original context
OK (indicator: not implemented in provider): 0x57c04624699b881c8ec4e80f7
2. Lowering any of salt length, password length, or output key length fails the call:
$(head -1 kdf2.c | sed -E 's#^// ##g') && ./kdf2 PBKDF2 SHA256 HMAC 15 0 7 13 0
ERR Failed to set EVP_KDF_CTX parameters: error:1C800069:Provider routines::invalid key length (in function kdf_pbkdf2_set_ctx_params in providers/implementations/kdfs/pbkdf2.c:207):
ERR Failed to set EVP_KDF_CTX parameters: error:1C800070:Provider routines::invalid salt length (in function kdf_pbkdf2_set_ctx_params in providers/implementations/kdfs/pbkdf2.c:217):
ERR Failed to derive key: error:1C8000AB:Provider routines::key size too small (in function pbkdf2_derive in providers/implementations/kdfs/pbkdf2.c:326):
3. Running the same command with the pkcs5 parameter set to 1 passes:
$(head -1 kdf2.c | sed -E 's#^// ##g') && ./kdf2 PBKDF2 SHA256 HMAC 15 0 7 13 1
ERR Failed to duplicate EVP_KDF_CTX, this may be unsupported by your version of OpenSSL; using original context
OK (indicator: not implemented in provider): 0x712fad9de3f4c1ee726ca5932

Actual results:
Setting the pkcs5 parameter to 1 allows behavior that is not valid in FIPS mode.

Expected results:
Either setting the pkcs5 parameter to 1 causes an explicit indicator to show that the call was unapproved, or disabling the lower bounds checks is not possible in FIPS mode.

Comment 2 Clemens Lang 2023-03-03 11:05:33 UTC
Created attachment 1947670 [details]
Reproducer for arbitrary KDFs (now supports PBKDF2 and setting the pkcs5 property for PBKDF2)

Comment 3 Clemens Lang 2023-03-03 11:37:08 UTC
See https://github.com/openssl/openssl/pull/20429 for a patch fixing the self-test.

Comment 18 errata-xmlrpc 2023-11-07 08:53:05 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (openssl bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:6627