Bug 2112615

Summary: Additional configuration not correctly appended / results in misconfiguration of openssl
Product: [Fedora] Fedora Reporter: Leon Fauster <leonfauster>
Component: crypto-policiesAssignee: Alexander Sosedkin <asosedki>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 36CC: asosedki, crypto-team, luk.claes, rrelyea, tm
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-25 15:39:22 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:

Description Leon Fauster 2022-07-31 01:16:27 UTC
////////////////////////////////////////////////////////////////////////////////////

Description of problem:

"The contents of the <back-end>-file.config is appended to the configuration from the policy back end as shipped in the crypto-policies package".

For an openssl configuration like 

/etc/crypto-policies/local.d/opensslcnf-file.config

such appending results in a corrupted openssl configuration because the section (ini file format) is not respected.

////////////////////////////////////////////////////////////////////////////////////
Version-Release number of selected component (if applicable):

crypto-policies-scripts-20220428-1.gitdfb10ea.fc36.noarch
crypto-policies-20220428-1.gitdfb10ea.fc36.noarch


////////////////////////////////////////////////////////////////////////////////////
How reproducible:

# cat  local.d/opensslcnf-file.config 

Ciphersuites = TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_SHA256


# update-crypto-policies 
Setting system policy to DEFAULT:NO-CAMELLIA
Note: System-wide crypto policies are applied on application start-up.
It is recommended to restart the system for the change of policies
to fully take place.


# cat back-ends/opensslcnf.config 
CipherString = @SECLEVEL=2:kEECDH:kRSA:kEDH:kPSK:kDHEPSK:kECDHEPSK:kRSAPSK:-aDSS:-3DES:!DES:!RC4:!RC2:!IDEA:-SEED:!eNULL:!aNULL:!MD5:-SHA384:-CAMELLIA:-ARIA:-AESCCM8
Ciphersuites = TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_SHA256
TLS.MinProtocol = TLSv1.2
TLS.MaxProtocol = TLSv1.3
DTLS.MinProtocol = DTLSv1.2
DTLS.MaxProtocol = DTLSv1.2
SignatureAlgorithms = ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:ed25519:ed448:rsa_pss_pss_sha256:rsa_pss_pss_sha384:rsa_pss_pss_sha512:rsa_pss_rsae_sha256:rsa_pss_rsae_sha384:rsa_pss_rsae_sha512:RSA+SHA256:RSA+SHA384:RSA+SHA512:ECDSA+SHA224:RSA+SHA224

[openssl_init]
alg_section = evp_properties

[evp_properties]
rh-allow-sha1-signatures = yes

Ciphersuites = TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_SHA256



# echo test|openssl dgst -sha256
FATAL: Startup failure (dev note: apps_startup()) for openssl
809BC94A6A7F0000:error:030000A9:digital envelope routines:alg_module_init:unknown option:crypto/evp/evp_cnf.c:74:name=Ciphersuites, value=TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_SHA256
809BC94A6A7F0000:error:0700006D:configuration file routines:module_run:module initialization error:crypto/conf/conf_mod.c:270:module=alg_section, value=evp_properties retcode=-1      





Steps to Reproduce:
1. add Ciphersuites line into /etc/crypto-policies/local.d/opensslcnf-file.config
2. exec update-crypto-policies 
3. check /etc/crypto-policies/back-ends/opensslcnf.config 
4. test with "echo test|openssl dgst -sha256"

Actual results:
FATAL: Startup failure (dev note: apps_startup()) for openssl


Expected results:
echo test|openssl dgst -sha256
(stdin)= f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2




Additional info:

Change in /etc/crypto-policies/back-ends/opensslcnf.config the appended line before the two sections solves the misconfiguration.

Comment 1 Alexander Sosedkin 2022-08-01 11:02:35 UTC
Include the section name as well in your local.d file?
```
[crypto_policy]
Ciphersuites = TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_SHA256
```

Comment 2 Leon Fauster 2022-08-01 13:40:34 UTC
Are multiple sections in openssl.cnf supported? Are they internally appended then?

A first test shows that your suggestion works on F36 (openssl-3.0.5-1.fc36.x86_64).

Is this backward compatible to RHEL8 (openssl-1.1.1k) and 9 (openssl-3.0.1)? Thanks.

Comment 3 Alexander Sosedkin 2022-08-01 15:10:03 UTC
I don't see the behaviour of multiple sections spelled out explicitly in the openssl docs,
guess that'd be a question for openssl upstream.

RHEL-9 should not deviate from Fedora in this regard. RHEL-8 might be different.

Comment 4 Alexander Sosedkin 2022-08-02 15:14:11 UTC
I don't really see what to change here on the crypto-policies, the advertized feature to concatenate something onto the config is a pretty low-level one.
Could it be closed in favor of clarifying multi-section behaviour of the openssl parser or do you have any specific proposals for crypto-policies specifically?

Comment 5 Leon Fauster 2022-08-04 13:21:37 UTC
Initially not in particular but taking a look at how the composition of the configuration is done; shows that it could be more clearly of what to expect. 
What I mean is the include stanza in /etc/pki/tls/openssl.cnf that implies a certain section context (in this case [crypto_policy]). Reading this file I would assume that the included content belongs to section crypto_policy. But what happens is that (the package) crypto-policies injects additional sections.


The first idea that came up here was; why not add a include stanza for every  section that comes from  (the package) crypto-policies.

[ crypto_policy ]

.include = /etc/crypto-policies/back-ends/opensslcnf.config

[openssl_init]

.include = /etc/crypto-policies/back-ends/opensslcnf.openssl_init.config

[evp_properties]

.include = /etc/crypto-policies/back-ends/opensslcnf.evp_properties.config


This would elevate the transparency of what to expect, though.

Comment 6 Alexander Sosedkin 2022-08-04 13:32:03 UTC
Not a fan, honestly, that'd introduce more synchronization with openssl.
Maybe we could go the other way around and move `[ crypto_policy ]` into opensslcnf.config,
would that improve clarity?

Comment 7 Leon Fauster 2022-08-04 23:09:05 UTC
Sure, not that smart. Well, to isolate it locally I just see following. 
Each section has a set of items that belongs to that corresponding section.
Instead concatenating just the contents of local.d/opensslcnf-file.config,
take the content and "filter" it by "items of section" and then concatenate
it section wise ...

Comment 8 Alexander Sosedkin 2022-08-05 06:11:59 UTC
That'd overcomplicate what local.d does by an order of magnitude, while possibly losing some of what it offers currently in the process. Plus I don't see what it offers over putting section headers right into it.

Comment 9 Ben Cotton 2023-04-25 17:41:09 UTC
This message is a reminder that Fedora Linux 36 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 36 on 2023-05-16.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '36'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version. Note that the version field may be hidden.
Click the "Show advanced fields" button if you do not see it.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 36 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 10 Ludek Smid 2023-05-25 15:39:22 UTC
Fedora Linux 36 entered end-of-life (EOL) status on 2023-05-16.

Fedora Linux 36 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of Fedora Linux
please feel free to reopen this bug against that version. Note that the version
field may be hidden. Click the "Show advanced fields" button if you do not see
the version field.

If you are unable to reopen this bug, please file a new report against an
active release.

Thank you for reporting this bug and we are sorry it could not be fixed.