Bug 1780335
Summary: | FIPS mode Provider refuses to load pk11-kit-trust | |||
---|---|---|---|---|
Product: | Red Hat Enterprise Linux 8 | Reporter: | Alex Scheel <ascheel> | |
Component: | java-1.8.0-openjdk | Assignee: | Martin Balao <mbalao> | |
Status: | CLOSED ERRATA | QA Contact: | OpenJDK QA <java-qa> | |
Severity: | unspecified | Docs Contact: | ||
Priority: | unspecified | |||
Version: | 8.2 | CC: | ahughes, dbhole, jandrlik, jvanek, mbalao | |
Target Milestone: | rc | |||
Target Release: | 8.0 | |||
Hardware: | Unspecified | |||
OS: | Unspecified | |||
Whiteboard: | ||||
Fixed In Version: | java-1.8.0-openjdk-1.8.0.262.b01-0.1.ea.el8 | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | ||
Clone Of: | ||||
: | 1818900 (view as bug list) | Environment: | ||
Last Closed: | 2020-11-04 02:43:27 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: | 1760850, 1818900 |
Description
Alex Scheel
2019-12-05 17:29:31 UTC
Note that p11-kit-trust can be removed from the NSS DB: [root@localhost ~]# modutil -dbdir /nssdb -delete p11-kit-trust After which, the test will succeed: Provider: MessageDigest.SHA-1 algorithm from: SunPKCS11-NSS-FIPS Killing session (sun.security.pkcs11.P11Digest.engineReset(P11Digest.java:145)) active: 3 Provider: MessageDigest.SHA-1 algorithm from: SunPKCS11-NSS-FIPS Killing session (sun.security.pkcs11.P11Digest.engineReset(P11Digest.java:145)) active: 3 Token Alias Map: localhost type=[private key] label=[localhost] id=0xd4b9ef47ebeb5414c277c068dc94459328422185 trusted=[false] matched=[true] cert=[ subject: CN=localhost, O=CIPHERBOY issuer: CN=CA Root Certificate, OU=pki-tomcat, O=CIPHERBOY serialNum: 20878] CA Root type=[private key] label=[CA Root] id=0x9af25882bf3ef65f07bc9034dd87081ed34b3216 trusted=[false] matched=[true] cert=[ subject: CN=CA Root Certificate, OU=pki-tomcat, O=CIPHERBOY issuer: CN=CA Root Certificate, OU=pki-tomcat, O=CIPHERBOY serialNum: 28335] All known SunJSSE.PKCS12 aliases: - localhost - CA Root Yes, OpenJDK explicitly checks that no module other than the software token is in NSSDB when configured in FIPS mode: http://hg.openjdk.java.net/jdk/jdk/file/b2aca65cc099/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Secmod.java#l417 This check has been there since the initial revision. I'm not sure of the rationale though. I wonder if we are able to initialize NSS in FIPS mode using an NSSDB with external modules. I can further investigate this. Hello Alex, I've been investigating a bit deeper into this issue and want to make some notes -which will hopefully clarify my initial comment in this ticket-. NSS represents modules internally with a "struct SECMODModuleStr" object. In particular, there is a isFIPS member [1] which is initialized with PR_FALSE by default [2]. The only code line that may change the value of isFIPS to PR_TRUE is here [3], and depends on the existence of a "FIPS" flag in the spec. This isFIPS value gets passed to OpenJDK as the "fips" variable and is used here [4] to check whether or not the module is allowed. What OpenJDK does not allow is the existence of a module that has isFIPS = true but is different than the internal software token. That means that if there is a module (say p11-kit-trust) which has isFIPS = false, there shouldn't be any problems. I could not reproduce this issue yet. My NSSDB has: [martin@vmhost test]$ modutil -dbdir /home/martin/redhat/java/openjdk/workspace/rhel_8_fips/fips/test/src/nssdb -list Listing of PKCS #11 Modules ----------------------------------------------------------- 1. NSS Internal FIPS PKCS #11 Module slots: 1 slot attached status: loaded slot: NSS FIPS 140-2 User Private Key Services token: NSS FIPS 140-2 Certificate DB 2. p11-kit-trust library name: /usr/lib64/p11-kit-trust.so slots: 2 slots attached status: loaded slot: /etc/pki/ca-trust/source token: System Trust slot: /usr/share/pki/ca-trust-source token: Default Trust ----------------------------------------------------------- It's FIPS enabled: [martin@vmhost test]$ modutil -dbdir /home/martin/redhat/java/openjdk/workspace/rhel_8_fips/fips/test/src/nssdb -chkfips true FIPS mode enabled. The spec for #1 module is: " name=\"NSS Internal FIPS PKCS #11 Module\" parameters=\"configdir='/home/martin/redhat/java/openjdk/workspace/rhel_8_fips/fips/test/src/nssdb' certPrefix='' keyPrefix='' secmod='secmod.db' flags=readOnly updatedir='' updateCertPrefix='' updateKeyPrefix='' updateid='' updateTokenDescription='' \" NSS=\" slotParams={0x00000003=[slotFlags=RSA,RC4,RC2,DES,DH,SHA1,MD5,MD2,SSL,TLS,AES,RANDOM ] } Flags=internal,FIPS,critical\"" And the SECMODModule module for #1 is: (gdb) print *((*((*(SECMODModuleList*)0x7f59c13b94e0).next)).module) $8 = {arena = 0x7f59b826d8d0, internal = 3, loaded = 1, isFIPS = 1, dllName = 0x0, commonName = 0x7f59b8271e78 "NSS Internal FIPS PKCS #11 Module", library = 0x0, functionList = 0x7f59c0815420, refLock = 0x7f59b8271fa0, refCount = 2, slots = 0x7f59b82720b0, slotCount = 1, slotInfo = 0x7f59b8272070, slotInfoCount = 0, moduleID = 1, isThreadSafe = 1, ssl = {0, 0}, libraryParams = 0x7f59b8271ea0 "configdir='/home/martin/redhat/java/openjdk/workspace/rhel_8_fips/fips/test/src/nssdb' certPrefix='' keyPrefix='' secmod='secmod.db' flags=readOnly updatedir='' updateCertPrefix='' updateKeyPrefix='' "..., moduleDBFunc = 0x0, parent = 0x7f59b826d630, isCritical = 1, isModuleDB = 0, moduleDBOnly = 0, trustOrder = 50, cipherOrder = 0, evControlMask = 0, cryptokiVersion = {major = 2 '\002', minor = 20 '\024'}} The spec for #2 module is: "library=/usr/lib64/p11-kit-trust.so name=p11-kit-trust NSS=\"trustOrder=100 \"" And the SECMODModule module for #2 is: (gdb) print *((*((*((*(SECMODModuleList*)0x7f59c13b94e0).next)).next)).module) $11 = {arena = 0x7f59b8293560, internal = 0, loaded = 1, isFIPS = 0, dllName = 0x7f59b8293758 "/usr/lib64/p11-kit-trust.so", commonName = 0x7f59b8293748 "p11-kit-trust", library = 0x7f59b8293530, functionList = 0x7f599a4f9020, refLock = 0x7f59b8293870, refCount = 1, slots = 0x7f59b8293778, slotCount = 2, slotInfo = 0x7f59b82937c8, slotInfoCount = 0, moduleID = 2, isThreadSafe = 1, ssl = {0, 0}, libraryParams = 0x0, moduleDBFunc = 0x0, parent = 0x7f59b826d630, isCritical = 0, isModuleDB = 0, moduleDBOnly = 0, trustOrder = 100, cipherOrder = 0, evControlMask = 0, cryptokiVersion = {major = 2 '\002', minor = 20 '\024'}} Looks to me that your spec for p11-kit-trust (#2 in my case) has the "FIPS" flag in it. Is this correct? Is it required for you? Beyond that, and assuming that you are able to initialize SunPKCS11-NSS-FIPS with the NSSDB you want, do you need access from OpenJDK to p11-kit-trust module? Thanks, Martin.- -- [1] - https://github.com/nss-dev/nss/blob/c1ff439ca931f53c318e7381636ed5889b3d66f1/lib/pk11wrap/secmodt.h#L49 [2] - https://github.com/nss-dev/nss/blob/a141cd68ece76118aebf8033c06d46a3692b55fe/lib/pk11wrap/pk11pars.c#L49 [3] - https://github.com/nss-dev/nss/blob/a141cd68ece76118aebf8033c06d46a3692b55fe/lib/pk11wrap/pk11pars.c#L819 [4] - http://hg.openjdk.java.net/jdk/jdk/file/b2aca65cc099/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Secmod.java#l417 [5] - http://hg.openjdk.java.net/jdk/jdk/file/f93bd058a4ce/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/SunPKCS11.java#l235 Update: I've just realized that newer NSS versions have a secmod_GetSystemFIPSEnabled function, introduced by 1531267 [1] [2]. As a result, all modules have isFIPS = PR_TRUE when global FIPS in enabled in the system; you don't need a "FIPS" flag in your p11-kit-trust spec (and you don't probably have it). I'll investigate what happens if we remove the check from OpenJDK. Keep you posted. -- [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1531267 [2] - https://hg.mozilla.org/projects/nss/rev/536fd7c9db5a (In reply to mbalao from comment #4) > > I'll investigate what happens if we remove the check from OpenJDK. Keep you > posted. > I've done a quick test removing the check but couldn't notice anything in my testing environment, so I raised the discussion in upstream [1]. -- [1] - https://mail.openjdk.java.net/pipermail/security-dev/2019-December/021077.html 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 (java-1.8.0-openjdk 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-2020:4656 |