RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2094956 - Overriding default property query settings doesn't work for some operations (FIPS mode)
Summary: Overriding default property query settings doesn't work for some operations (...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: openssl
Version: 9.0
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: rc
: ---
Assignee: Clemens Lang
QA Contact: Hubert Kario
URL:
Whiteboard:
Depends On:
Blocks: 2161694
TreeView+ depends on / blocked
 
Reported: 2022-06-08 17:26 UTC by Hubert Kario
Modified: 2023-05-09 10:30 UTC (History)
1 user (show)

Fixed In Version: openssl-3.0.7-2.el9
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 08:20:36 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openssl openssl pull 18576 0 None open APPS: dsaparam, gendsa: Support setting properties 2022-06-15 11:46:47 UTC
Github openssl openssl pull 18717 0 None open Various apps: support setting properties 2022-07-05 09:51:09 UTC
Red Hat Bugzilla 2129063 0 medium CLOSED Rebase to the latest openssl 3.0.x series 2023-06-27 06:24:43 UTC
Red Hat Issue Tracker CRYPTO-7518 0 None None None 2022-06-14 09:17:24 UTC
Red Hat Issue Tracker RHELPLAN-124688 0 None None None 2022-06-08 17:33:02 UTC
Red Hat Product Errata RHSA-2023:2523 0 None None None 2023-05-09 08:20:52 UTC

Description Hubert Kario 2022-06-08 17:26:16 UTC
Description of problem:
When the system is in FIPS mode, the default property query enforces use of fips certified algorithms. Sometimes though it's necessary to operate on files which are not compatible with FIPS requirements. OpenSSL provides the property query mechanism to override it. Unfortunately, while it works for some operations (like x25519 key gen) it doesn't work for all, like RSA signatures

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

How reproducible:
always

Steps to Reproduce:
1. switch system to FIPS mode
2. openssl req -x509 -newkey rsa -keyout root.key -out root.crt -subj /CN=localhost -batch -nodes
3. echo "test" > text.txt
4. openssl dgst -propquery fips=no -sign root.key -sha256 -out file.sig file.txt

Actual results:
Could not open file or uri for loading private key from root.key
00FC1B22947F0000:error:16000069:STORE routines:ossl_store_get0_loader_int:unregistered scheme:crypto/store/store_register.c:237:scheme=file
00FC1B22947F0000:error:1608010C:STORE routines:inner_loader_fetch:unsupported:crypto/store/store_meth.c:357:No store loader found. For standard store loaders you need at least one of the default or base providers available. Did you forget to load them? Info: Global default library context, Scheme (file : 0), Properties (fips=no)

Expected results:
signature created

Additional info:
Overriding disablement of DSA is similarly broken.

Comment 1 Hubert Kario 2022-06-08 17:30:40 UTC
Running

openssl dgst -provider default -propquery fips=no -sign root.key -sha256 -out file.sig file.txt

fails with the exact same error message:

Could not open file or uri for loading private key from root.key
00DC3E2F857F0000:error:16000069:STORE routines:ossl_store_get0_loader_int:unregistered scheme:crypto/store/store_register.c:237:scheme=file
00DC3E2F857F0000:error:1608010C:STORE routines:inner_loader_fetch:unsupported:crypto/store/store_meth.c:357:No store loader found. For standard store loaders you need at least one of the default or base providers available. Did you forget to load them? Info: Global default library context, Scheme (file : 0), Properties (fips=no)

Comment 2 Clemens Lang 2022-06-09 08:11:32 UTC
I believe this may be expected. If you pass "fips=no", you're explicitly asking for the non-fips implementation of an algorithm, not just any implementation regardless of whether it's fips-certified or not.

The issue here is fetching the store loader (basically the part that implements reading from a file), which also uses the algorithm fetching code and thus also respects the property queries provided. Both the base provider and the default provider implement the file store loader, but both of them define the file store loader with the "fips=yes" property:

- https://github.com/openssl/openssl/blob/openssl-3.0/providers/baseprov.c#L85-L92
- https://github.com/openssl/openssl/blob/openssl-3.0/providers/defltprov.c#L474-L481
- https://github.com/openssl/openssl/blob/openssl-3.0/providers/stores.inc

We could modify defltprov.c to not set fips=yes on the store implementation, but I think the issue here really is just that what you're trying to do cannot be done from the command line. You need the standard property query to load the store loaders, and the specifically pass "fips=no" as props argument of EVP_DigestSignInit_ex, which will then internally fetch an EVP_SIGNATURE algorithm as documented in the manpage:

> The pkey algorithm is used to fetch a EVP_SIGNATURE method implicitly, to be used for the actual signing. See "Implicit fetch" in provider(7) for more information about implicit fetches.

Comment 3 Clemens Lang 2022-06-09 08:25:37 UTC
Btw, you can make this pass by changing the property query string to "-fips" (which I guess is not what you wanted because that doesn't tell you whether you're getting the FIPS or the non-FIPS implementation), or "?fips!=yes", which makes the query optional, but preferred, and the preference is to use anything that doesn't have "fips=yes".

Comment 4 Hubert Kario 2022-06-09 12:25:42 UTC
The goal is to do operations that are not allowed by the fips provider, like signing with SHA-1 or DSA param generation, that doesn't work with `?fips!=yes` either:

$ openssl dsaparam -propquery '?fips!=yes' -out param.pem 2048
Error, DSA parameter generation context allocation failed
C0419DB3077F0000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:crypto/evp/evp_fetch.c:349:Global default library context, Algorithm (DSA : 103), Properties (<null>)

Comment 5 Hubert Kario 2022-06-09 12:32:49 UTC
and `-fips` doesn't work for signing with sha-1 even if I switch the system to LEGACY policy (to allow SHA-1 signatures):

# openssl dgst -propquery '-fips' -sign root.key -sha1 -out file.sig file.txt
Error setting context
C0411E29967F0000:error:1C8000AE:Provider routines:rsa_setup_md:digest not allowed:providers/implementations/signature/rsa_sig.c:307:digest=SHA1

# openssl dgst -propquery '?fips!=yes' -sign root.key -sha1 -out file.sig file.txt
Error setting context
C0F10273467F0000:error:1C8000AE:Provider routines:rsa_setup_md:digest not allowed:providers/implementations/signature/rsa_sig.c:307:digest=SHA1

Comment 6 Clemens Lang 2022-06-14 12:27:47 UTC
openssl's dgst module does not actually respect the passed property queries when signing and verifying, because it calls EVP_DigestVerifyInit/EVP_DigestSignInit, which do not accept property queries. This could would have to be re-written to use EVP_DigestVerifyInit_ex and EVP_DigestSignInit_ex, but those do not support engines, and I haven't yet figured out in which cases I can ignore the engines without breaking existing functionality.

Comment 7 Hubert Kario 2022-06-14 12:41:41 UTC
That sounds like a question for upstream, but AFAIK, engines are deprecated so them getting broken by fixing a behaviour with providers is acceptable for upstream...

Comment 8 Clemens Lang 2022-06-14 12:51:54 UTC
Same for dsaparam, it doesn't pass the required flags to EVP_PKEY_CTX_new_from_name():

diff --git a/apps/dsaparam.c b/apps/dsaparam.c
index 8025b8be67..b65de6e91c 100644
--- a/apps/dsaparam.c
+++ b/apps/dsaparam.c
@@ -147,7 +147,7 @@ int dsaparam_main(int argc, char **argv)
     if (out == NULL)
         goto end;

-    ctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL);
+    ctx = EVP_PKEY_CTX_new_from_name(app_get0_libctx(), "DSA", app_get0_propq());
     if (ctx == NULL) {
         BIO_printf(bio_err,
                    "Error, DSA parameter generation context allocation failed\n");

I'll see what I can do to get those fixed upstream.

Comment 9 Hubert Kario 2022-06-14 12:57:12 UTC
Note that it's not just those two that we care about, there's RSA key sizes, EC curves... most of tools in apps/ should be audited for property use...

Comment 10 Clemens Lang 2022-06-15 11:03:51 UTC
Starting with DSA, more fixes to follow: https://github.com/openssl/openssl/pull/18576

Comment 31 errata-xmlrpc 2023-05-09 08:20:36 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 (Low: openssl security and bug fix 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/RHSA-2023:2523


Note You need to log in before you can comment on or make changes to this bug.