8244336: Restrict algorithms at JCE layer#3213
Conversation
|
👋 Welcome back TheMangovnik! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
b486e6d to
7cff2cc
Compare
|
@TheMangovnik Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
|
This backport pull request has now been updated with issue from the original commit. |
Webrevs
|
|
/reviewers 2 |
jerboaa
left a comment
There was a problem hiding this comment.
This looks OK to me. Two nits.
|
|
||
| // throws NoSuchAlgorithmException if java.security disables it | ||
| if (!CryptoAlgorithmConstraints.permits("Cipher", transformation)) { | ||
| throw new NoSuchAlgorithmException(transformation + " is disabled"); |
There was a problem hiding this comment.
Nit: The JDK 17u patch has this on two lines:
| throw new NoSuchAlgorithmException(transformation + " is disabled"); | |
| throw new NoSuchAlgorithmException(transformation + | |
| " is disabled"); |
| Set<String> algorithmsInPropertySet = new | ||
| TreeSet<>(String.CASE_INSENSITIVE_ORDER); |
There was a problem hiding this comment.
Nit: Odd formatting that is different to the JDK 17u patch:
| Set<String> algorithmsInPropertySet = new | |
| TreeSet<>(String.CASE_INSENSITIVE_ORDER); | |
| Set<String> algorithmsInPropertySet = | |
| new TreeSet<>(String.CASE_INSENSITIVE_ORDER); |
gnu-andrew
left a comment
There was a problem hiding this comment.
- Differences in
Keystore.javaare due to the absence of JDK-8245679 and are adapted appropriately. 8245679 itself looks a risky backport as it changes Provider lookup behaviour. - I don't really see the need to move the declaration of
MessageDigest mdin either patch, but at least in 17, it is moved after the new block which could cause the method to exit early. I don't see any reason to move it in 11u as the context is quite different. MessageDigest.javahas a missing newline in 11u compared with 17u beforeif (provider == null)- There are differences in
Signature.javabut this is in erased code so no issue Cipher.javastill contains differences in the indentation ofNoSuchAlgorithmExceptionconstruction as pointed out by Severin. The first where correction was attempted is not indented correctly. The second instance has not been corrected at all.AbstractAlgorithmConstraints.javaalso has bad indentation of theTreeSetline raised by Severin. The first part of the patch also looks different, but this is because 11u never had theSuppressWarningsannotation added; changes are otherwise the same.- In
CryptoAlgorithmConstraints.java, the correction todebug.printlnshould be a change toDebug.printlnrather than changing the arguments. The method exists in 11u but is static, rather than an instance method. Changing it to call the static version will mean that, if the dual argument method is changing to an instance method at a later date, this will be caught by a compile error. If you change the arguments as in the current patch, this difference will remain unnoticed. The change is made by JDK-8051959 which adds thread info and timestamps to the output. This has already been proposed for 11u, but was blocked by the need for an earlier change, so I suspect this is likely to be integrated at some point.
You can see the differences I'm referring to by running diff -u on your patch vs. the 17u patch. I would strongly suggest doing this for backports so you are aware of differences and can catch ones that shouldn't be there before submitting the patch for review.
👍
tl;dr: I see the move of the I have been peering into the patches, both in jdk17 and in this PR, and I fail to fully understand what you are referencing.
- MessageDigest md;
Object[] objs = Security.getImpl(algorithm, "MessageDigest",
(String)null);
+ MessageDigest md;
if (!CryptoAlgorithmConstraints.permits("MessageDigest", algorithm)) {
throw new NoSuchAlgorithmException(algorithm + " is disabled");
}
// In this place also starts a try block in jdk11. But that should be inconsequential for this situation.
Object[] objs = Security.getImpl(algorithm, "MessageDigest",
(String)null);
MessageDigest md;
I see similar castling in the method overload just below it
Added.
👍
This is stupid oversight from my side. Corrected.
Indentation corrected.
I see, the fact that the
I will keep this in mind and do more throughout job next time. |
Backport of JDK-8244336 - Restrict algorithms at JCE layer.
This is in preparation for a backport of JDK-8375549.
This backport will be followed up by JDK-8367583 and JDK-8373690 to fix introduced bugs by this backport.
Extra changes
src/java.base/share/classes/sun/security/util/CryptoAlgorithmConstraints.javaOn line 61:
I made this change, because otherwise the compilation would not pass complaining about incorrect static method calling.
Tests
Tests were run on Fedora 44.
New tests - MIXED
The failing test
test/jdk/java/security/KeyStore/TestDisabledAlgorithms.javawill be fixed in follow up backport of JDK-8373690.sun/security- MIXXEDThe failing test is
sun/security/ssl/X509KeyManager/PreferredKey.java, afaik this unrelated to this backport and is being addressed with another PR.Tier 1 - PASSED
gtest - PASSED
GHA - RUNNING
https://github.com/TheMangovnik/jdk11u-dev/actions/runs/26746034005
Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk11u-dev.git pull/3213/head:pull/3213$ git checkout pull/3213Update a local copy of the PR:
$ git checkout pull/3213$ git pull https://git.openjdk.org/jdk11u-dev.git pull/3213/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3213View PR using the GUI difftool:
$ git pr show -t 3213Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk11u-dev/pull/3213.diff
Using Webrev
Link to Webrev Comment