Skip to content

8293345: SunPKCS11 provider checks on PKCS11 Mechanism are problematic #18387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

valeriepeng
Copy link
Contributor

@valeriepeng valeriepeng commented Mar 20, 2024

Existing legacy mechanism check disables mechanism(s) when the support is partial, e.g. supports decryption but not encryption, or supports verification but not signing. Some mechanisms can be used for both encryption/decryption and sign/verify such as RSA related ones. If the particular mechanism supports sign/verify/decryption but not encryption, it'd be disabled as a result. Fine tune the legacy mechanism check with the service type, i.e. supports encryption for Cipher, sign for Signature, so the mechanism is disabled based on the service type.
For completeness sake, I also added a PKCS11 provider configuration option to control this. If not set, SunPKCS11 provider will disable legacy mechanisms by default.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8329300 to be approved

Issues

  • JDK-8293345: SunPKCS11 provider checks on PKCS11 Mechanism are problematic (Enhancement - P3)
  • JDK-8329300: SunPKCS11 provider checks on PKCS11 Mechanism are problematic (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18387/head:pull/18387
$ git checkout pull/18387

Update a local copy of the PR:
$ git checkout pull/18387
$ git pull https://git.openjdk.org/jdk.git pull/18387/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18387

View PR using the GUI difftool:
$ git pr show -t 18387

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18387.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 20, 2024

👋 Welcome back valeriep! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Mar 20, 2024

@valeriepeng This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8293345: SunPKCS11 provider checks on PKCS11 Mechanism are problematic

Reviewed-by: djelinski, weijun

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 734 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 20, 2024
@openjdk
Copy link

openjdk bot commented Mar 20, 2024

@valeriepeng The following label will be automatically applied to this pull request:

  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the security security-dev@openjdk.org label Mar 20, 2024
@mlbridge
Copy link

mlbridge bot commented Mar 20, 2024

Webrevs

Copy link
Member

@djelinski djelinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 26, 2024
@seanjmullan
Copy link
Member

Is "disableLegacy" a standard PKCS11 attribute we are introducing support for? If so, I think a CSR is probably needed as it is kind of like a system property.

@valeriepeng
Copy link
Contributor Author

Is "disableLegacy" a standard PKCS11 attribute we are introducing support for? If so, I think a CSR is probably needed as it is kind of like a system property.

It's a configuration file option. Just for the uncommon case if users would like to disable the check entirely. I can file a CSR on this. Thanks for the comment.

@valeriepeng
Copy link
Contributor Author

LGTM

Thanks for the review~

@openjdk openjdk bot added csr Pull request needs approved CSR before integration and removed ready Pull request is ready to be integrated labels Mar 29, 2024
@valeriepeng
Copy link
Contributor Author

/csr

@openjdk
Copy link

openjdk bot commented Apr 3, 2024

@valeriepeng an approved CSR request is already required for this pull request.

Copy link
Contributor

@mcpowers mcpowers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about testing?

Comment on lines +1332 to +1344
if (!allowLegacy && mechInfo != null) {
if ((d.type == CIP &&
(mechInfo.flags & CKF_ENCRYPT) == 0) ||
(d.type == SIG &&
(mechInfo.flags & CKF_SIGN) == 0)) {
if (showInfo) {
System.out.println("DISABLED " + d.type +
" " + d.algorithm +
" due to partial support");
}
continue;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why this check was moved down in the file. The only advantage I see is that you have access to d.type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the purpose, e.g. perform the check based on the type of registered service. The earlier check does not take into account of the registered service and disables a mechanism completely even when it can still be used for some.
For example, a mechanism supports decryption, signing, and verification will be disabled completely with the earlier check, but will still be enabled for Signature with this proposed change.

@valeriepeng
Copy link
Contributor Author

What about testing?

I tested the change manually by changing some behavior to simulate the case. However, this cannot be done by regression test since NSS does not have legacy mechanisms.

@dems54
Copy link

dems54 commented Apr 15, 2024

@valeriepeng can this feature be backported to Java 17 ?

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Apr 16, 2024
@valeriepeng
Copy link
Contributor Author

@valeriepeng can this feature be backported to Java 17 ?

I suppose so, the PKCS11 configuration attribute part which requires CSR can be separated out if needed.

@valeriepeng
Copy link
Contributor Author

@mcpowers I am about to leave for vacation. Will wait for your review and resume on this PR after I return. Thanks!

@mcpowers
Copy link
Contributor

mcpowers commented May 9, 2024

Your changes look fine to me.

@valeriepeng
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented May 10, 2024

Going to push as commit 1b476f5.
Since your change was applied there have been 754 commits pushed to the master branch:

  • 1c5f150: 8331734: Atomic MemorySegment VarHandle operations fails for element layouts
  • 65abf24: 8331866: Add warnings for locale data dependence
  • d215bc4: 8332066: AArch64: Math test failures since JDK-8331558
  • d11e70a: 8331646: Add specific regression leap year tests
  • f95c937: 8331577: RISC-V: C2 CountLeadingZerosV
  • 675fbe6: 8331993: Add counting leading/trailing zero tests for Integer
  • 242446b: 8331931: JFR: Avoid loading regex classes during startup
  • 45792c5: 8331352: error: template-id not allowed for constructor/destructor in C++20
  • 1547a69: 8327696: [TESTBUG] "javax/swing/JTable/KeyBoardNavigation/KeyBoardNavigation.java" test instruction needs to be corrected
  • 784b8fc: 8331744: java.lang.classfile.TypeKind improvements
  • ... and 744 more: https://git.openjdk.org/jdk/compare/9bc1b065db238b7c9d0562f9bd55d2f338c6ff3d...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 10, 2024
@openjdk openjdk bot closed this May 10, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 10, 2024
@openjdk
Copy link

openjdk bot commented May 10, 2024

@valeriepeng Pushed as commit 1b476f5.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@valeriepeng valeriepeng deleted the JDK-8293345 branch May 10, 2024 16:53
@dems54
Copy link

dems54 commented May 10, 2024

Many thanks @valeriepeng for this feature.
Possible to backport on JDK 17 or 21 ?

@dems54
Copy link

dems54 commented May 29, 2024

UP @valeriepeng possible to backport PKCS11 configuration attribute part on JDK 17 or 21 ?

@valeriepeng
Copy link
Contributor Author

UP @valeriepeng possible to backport PKCS11 configuration attribute part on JDK 17 or 21 ?

I am not sure, let me check and get back to you.

@valeriepeng
Copy link
Contributor Author

UP @valeriepeng possible to backport PKCS11 configuration attribute part on JDK 17 or 21 ?

Based on the feedback that I got, it should be ok to backport the PKCS11 configuration attribute, separate CSRs would be needed for that though.

@dems54
Copy link

dems54 commented Jul 24, 2024

Many thanks @valeriepeng !
When could the backport to JDK17 and 21 be done ?
We are very excited to be able to update our clients with a maintained java version

@valeriepeng
Copy link
Contributor Author

Many thanks @valeriepeng ! When could the backport to JDK17 and 21 be done ? We are very excited to be able to update our clients with a maintained java version

This would be subject to the 21u and 17u Maintainer. I've opened the backport request against 17-pool and 21-pool but someone needs to file the CSR and do the actual backport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated security security-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

6 participants