Skip to content
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

8328556: Do not extract large CKO_SECRET_KEY keys from the NSS Software Token #18389

Closed
wants to merge 3 commits into from

Conversation

martinuy
Copy link
Contributor

@martinuy martinuy commented Mar 20, 2024

Hi,

I'd like to propose a fix for "8328556: Do not extract large CKO_SECRET_KEY keys from the NSS Software Token". See more details in the JBS ticket [1].

No regressions observed in jdk/sun/security/pkcs11.

Thanks,
Martin.-

--
[1] - https://bugs.openjdk.org/browse/JDK-8328556


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

Issue

  • JDK-8328556: Do not extract large CKO_SECRET_KEY keys from the NSS Software Token (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18389

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 20, 2024

👋 Welcome back mbalao! 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

@martinuy 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:

8328556: Do not extract large CKO_SECRET_KEY keys from the NSS Software Token

Reviewed-by: djelinski

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 76 new commits pushed to the master branch:

  • e669d14: 8328671: Mark allocate_new_tlab and unsafe_max_tlab_alloc of CollectedHeap as pure virtual
  • 940d196: 8328604: remove on_aix() function
  • d44aaa3: 8326643: JDK server does not send a dummy change_cipher_spec record after HelloRetryRequest message
  • 9bc741d: 8328339: Static import prevents source launcher from finding class with main method
  • 256d48b: 8327980: Convert javax/swing/JToggleButton/4128979/bug4128979.java applet test to main
  • 177b8a2: 8327840: Automate javax/swing/border/Test4129681.java
  • da00921: 8320404: Double whitespace in SubTypeCheckNode::dump_spec output
  • 4d36c4a: 8328285: GetOwnedMonitorInfo functions should use JvmtiHandshake
  • 0efd9dc: 8328398: Convert java/awt/im/4490692/bug4490692.html applet test to main
  • 46809b3: 8324736: Invalid end positions for EMPTY_STATEMENT
  • ... and 66 more: https://git.openjdk.org/jdk/compare/9059727df135dc90311bd476124f090b5766092b...master

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

@martinuy 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

@djelinski
Copy link
Member

Would it be possible to add a regression test for this? I think you should be able to trigger a failure by calculating a HMAC using the same key two times.

@martinuy
Copy link
Contributor Author

Would it be possible to add a regression test for this? I think you should be able to trigger a failure by calculating a HMAC using the same key two times.

May be possible. To create a large secret key we can use a DH derivation + TLS pre-master generation trick as shown in the TestLargeKeys.java reproducer that I attached to JDK-8328556. Other attempts to create a large secret key may fail due to NSS checks. Then we would need to configure the NSS Software Token in FIPS mode. This is currently not supported by the PKCS11Test library, so we would need to extend it. Notice that there is currently one FIPS standalone test (FipsModeTLS12.java) but the right approach would be to do refactoring in PKCS11Test. The reason why FIPS mode is necessary is because, otherwise, the mechanism for rebuilding keys in the token would be C_CreateObject instead of C_UnwrapKey. Actually, it's not FIPS mode strictly what we need but keys with CKA_SENSITIVE = CK_TRUE. Perhaps we can modify the NSS configuration to set this attribute, but that would be a shortcut and the use case is better represented by FIPS mode. If there is interest in supporting FIPS scenarios, I can do this work. I didn't go this far in my proposal because this bug, in my view, is not very likely to be hit —as far as I know, it haven't been for years since the introduction of JDK-6913047— and the fix is trivial.

@martinuy
Copy link
Contributor Author

Update: I found that an existing PKCS11Test configuration (p11-nss-sensitive.txt) sets CKA_SENSITIVE to CK_TRUE for secret keys. Combining this with the DH large secret key derivation trick led to a viable reproducer without having to introduce a FIPS configuration.

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.

Thanks for adding the test, the proposed changes look good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 22, 2024
@martinuy
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Mar 22, 2024

Going to push as commit 13cf070.
Since your change was applied there have been 86 commits pushed to the master branch:

  • 709410d: 8328679: Improve comment for UNSAFE_ENTRY_SCOPED in unsafe.cpp
  • f207aa9: 8326960: GHA: RISC-V sysroot cannot be debootstrapped due to ongoing Debian t64 transition
  • e80619a: 8328680: Introduce JDK_LIB, and clean up module native compilation
  • 638708c: 8328697: SubMenuShowTest and SwallowKeyEvents tests stabilization
  • e06b568: 8328602: Parallel: Incorrect assertion in fill_dense_prefix_end
  • 528efe2: 8328484: Convert and Opensource few JFileChooser applet test to main
  • d379afb: 8328312: runtime/stack/Stack0*.java fails intermittently on libgraal
  • cd534f8: 8328673: Convert closed text/html/CSS manual applet test to main
  • 38e3cda: 8328670: Automate and open source few closed manual applet test
  • b334a8e: 8328272: [AIX] Use flag kind "diagnostic" for platform specific flags
  • ... and 76 more: https://git.openjdk.org/jdk/compare/9059727df135dc90311bd476124f090b5766092b...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Mar 22, 2024

@martinuy Pushed as commit 13cf070.

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

@martinuy martinuy deleted the JDK-8328556 branch March 22, 2024 17:35
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.

2 participants