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 1868754 - java-11-openjdk / rhel-8 / FIPS: Ciphers remain in broken state (unusable), after supplied with wrongly sized buffer
Summary: java-11-openjdk / rhel-8 / FIPS: Ciphers remain in broken state (unusable), a...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: java-11-openjdk
Version: 8.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Martin Balao
QA Contact: OpenJDK QA
URL:
Whiteboard:
Depends On:
Blocks: 1868759
TreeView+ depends on / blocked
 
Reported: 2020-08-13 17:57 UTC by zzambers
Modified: 2021-09-03 15:14 UTC (History)
5 users (show)

Fixed In Version: java-11-openjdk-11.0.8.10-6.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1868759 (view as bug list)
Environment:
Last Closed: 2020-11-04 02:43:55 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
CipherBreak.java (1.36 KB, text/plain)
2020-08-13 17:58 UTC, zzambers
no flags Details


Links
System ID Private Priority Status Summary Last Updated
openjdk bug system JDK-8258833 0 None None None 2021-03-27 20:29:30 UTC

Description zzambers 2020-08-13 17:57:39 UTC
Ciphers remain in broken state (unusable), after supplied with wrongly sized buffer
- problem happens when wrongly sized data buffer is supplied to be encrypted, exception is thrown (CKR_DATA_LEN_RANGE), which is expected, but what is not expected is that ciphers became unusable afterwards, subsequent attempts to use ciphers end up with exception (CKR_OPERATION_ACTIVE), even on different instance/ different cipher with correct params. It seems that pkcs11 provider stays in some invalid state...
- affects all jdks (8, 11, latest-upstream)


Stack traces:

Alg 1: AES/CBC/NoPadding
Provider 1: SunPKCS11-NSS-FIPS version 1.8
Key 1: SunPKCS11-NSS-FIPS AES secret key, 128 bitssession object, sensitive, extractable)
java.security.ProviderException: update() failed
	at sun.security.pkcs11.P11Cipher.implUpdate(P11Cipher.java:629)
	at sun.security.pkcs11.P11Cipher.engineUpdate(P11Cipher.java:526)
	at sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:555)
	at sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:541)
	at javax.crypto.Cipher.doFinal(Cipher.java:2168)
	at CipherBreak.main(CipherBreak.java:24)
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DATA_LEN_RANGE
	at sun.security.pkcs11.wrapper.PKCS11.C_EncryptUpdate(Native Method)
	at sun.security.pkcs11.P11Cipher.implUpdate(P11Cipher.java:581)
	... 5 more
Alg 2: DES/CBC/NoPadding
Provider 2: SunPKCS11-NSS-FIPS version 1.8
Key 2: SunPKCS11-NSS-FIPS DES secret key, 56 bitssession object, sensitive, extractable)
Exception in thread "main" java.security.InvalidKeyException: Could not initialize cipher
	at sun.security.pkcs11.P11Cipher.implInit(P11Cipher.java:399)
	at sun.security.pkcs11.P11Cipher.engineInit(P11Cipher.java:299)
	at javax.crypto.Cipher.init(Cipher.java:1249)
	at javax.crypto.Cipher.init(Cipher.java:1189)
	at CipherBreak.main(CipherBreak.java:37)
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_OPERATION_ACTIVE
	at sun.security.pkcs11.wrapper.PKCS11.C_EncryptInit(Native Method)
	at sun.security.pkcs11.P11Cipher.initialize(P11Cipher.java:468)
	at sun.security.pkcs11.P11Cipher.implInit(P11Cipher.java:397)

Comment 1 zzambers 2020-08-13 17:58:50 UTC
Created attachment 1711353 [details]
CipherBreak.java

Reproducer

Comment 2 zzambers 2020-08-19 15:41:46 UTC
I looked a bit at this issue, and I think the problem could actually be in NSS library iteself.

Exception (CKR_DATA_LEN_RANGE) is thrown by C_EncryptUpdate [1]. Documentation I have found on the internet says [2]:
"A call to C_EncryptUpdate which results in an error other than CKR_BUFFER_TOO_SMALL terminates the current encryption operation."

I may be reading it wrong, but it seems to me, that if CKR_DATA_LEN_RANGE should have terminated the current operation, subsequent operations should not be showing CKR_OPERATION_ACTIVE.

I was just wondering if calling reset with true would make any difference... [3]

[1] https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/4687075d8ccf/src/share/classes/sun/security/pkcs11/P11Cipher.java#l581
[2] https://www.cryptsoft.com/pkcs11doc/v220/pkcs11__all_8h.html#aC_EncryptUpdate
[3] https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/4687075d8ccf/src/share/classes/sun/security/pkcs11/P11Cipher.java#l628

Comment 30 errata-xmlrpc 2020-11-04 02:43:55 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 (java-11-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:4657


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