Bug 2045083

Summary: crypto-policies: java override not working as expected
Product: [Fedora] Fedora Reporter: Paul Wouters <paul.wouters>
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, lef, luk.claes, rrelyea, ssorce, tm
Target Milestone: ---Flags: asosedki: needinfo? (paul.wouters)
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:20 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 Paul Wouters 2022-01-25 15:10:13 UTC
We had an issue in Azure where they still use root CA with a SHA1 selfsig. They also send the root CA as part of the chain in TLS, so then java would try to validate it (despite it having the root CA in its local trust store), it would see the SHA1 and fail because SHA1 was added to jdk.certpath.disabledAlgorithms=

So we tried to modify the java startup command by adding:

-Djava.security.properties=/etc/sysconfig/jvm.java.security

and then creating this file in the container with the content:

jdk.certpath.disabledAlgorithms=MD2, MD5, DSA, RSA keySize < 2048, SHA1 jdkCA & usage TLSServer

This did not work. We looked at:

/etc/java/java-1.8.0-openjdk/java-1.8.0-openjdk-1.8.0.312.b07-2.fc34.x86_64/lib/security/java.security

and we noticed the correct:

security.overridePropertiesFile=true

So we were confused why this does not work.


Sadly, we then scrapped this and just overwrote /etc/crypto-policies/back-ends/java.config  to change the SHA1 entry in disabledAlgorithms to this value.

That worked.


I'd rather not edit the crypto-policies file as running update-crypto-policies will override this change again. Note we also did not want to go from DEFAULT to LEGACY because that would downgrade other things besides this constrained java property. (eg we did not want to downgrade TLS and ssh)


Not sure if crypto-policies can do anything about this, or whether it is a java bug. I just figured I file this bug as a documentation method for the issue we had to workaround.

Comment 1 Simo Sorce 2022-01-25 15:25:32 UTC
Hi Paul,
have you experimented with custom crypto polcies?
https://www.redhat.com/en/blog/how-customize-crypto-policies-rhel-82

Comment 2 Alexander Sosedkin 2022-01-25 15:55:22 UTC
Reminds me of https://bugzilla.redhat.com/show_bug.cgi?id=1883312
and 
https://gitlab.com/redhat-crypto/fedora-crypto-policies/-/merge_requests/104

IIRC, we had to split the file in two so that java could pick the properties right.
Could you please check the issue is still present in 35 or rawhide?

Comment 3 Paul Wouters 2022-01-25 17:54:58 UTC
I have not checked the custom policies yet.

In our case, we specifically only wanted to affect java, and not the entire system. I'm not entirely sure if this would be possible with custom modules, but i will have a look as it is always better to use the system than to fight the system :)

Comment 4 Alexander Sosedkin 2022-01-25 18:45:08 UTC
> In our case, we specifically only wanted to affect java, and not the entire system.

In general, there are one-two mechanisms for that:
* local.d drop-ins:
    * low-level directives get concatenated to the backend config file
    * been available for a while
* scoped policies:
    * hash@java-tls = -SHA1, a directive other backends will ignore
    * only available starting from Fedora 35+

Comment 5 Ben Cotton 2022-05-12 14:58:29 UTC
This message is a reminder that Fedora Linux 34 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 34 on 2022-06-07.
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 '34'.

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.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 34 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 6 Alexander Sosedkin 2023-02-07 19:12:30 UTC
Is there something I should do about this bug or are scoped subpolicies enough to satisfy the request?

---

# grep SHA /etc/crypto-policies/back-ends/java.config
jdk.certpath.disabledAlgorithms=MD2, SHA1, MD5, DSA, RSA keySize < 2048
# echo 'hash@java-tls = SHA1+' > /etc/crypto-policies/policies/modules/JAVA-SHA1.pmod
# update-crypto-policies --set DEFAULT:JAVA-SHA1
Setting system policy to DEFAULT:JAVA-SHA1
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.
# grep SHA /etc/crypto-policies/back-ends/java.config
# cat /etc/crypto-policies/back-ends/java.config
jdk.certpath.disabledAlgorithms=MD2, MD5, DSA, RSA keySize < 2048
jdk.tls.disabledAlgorithms=DH keySize < 2048, TLSv1.1, TLSv1, SSLv3, SSLv2, DHE_DSS, RSA_EXPORT, DHE_DSS_EXPORT, DHE_RSA_EXPORT, DH_DSS_EXPORT, DH_RSA_EXPORT, DH_anon, ECDH_anon, DH_RSA, DH_DSS, ECDH, 3DES_EDE_CBC, DES_CBC, RC4_40, RC4_128, DES40_CBC, RC2, HmacMD5
jdk.tls.legacyAlgorithms=

Comment 7 Ben Cotton 2023-04-25 16:48:21 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 8 Ludek Smid 2023-05-25 15:39:20 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.