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
8277474: jarsigner does not check if algorithm parameters are disabled #7582
Conversation
/label remove core-libs |
/label remove compiler |
👋 Welcome back hchao! A progress list of the required criteria for merging this PR into |
@haimaychao The |
@haimaychao The |
@haimaychao The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
/label remove core-libs |
/label remove compiler |
@haimaychao |
@haimaychao |
Webrevs
|
@@ -30,6 +30,7 @@ | |||
import java.net.URLClassLoader; | |||
import java.security.cert.CertPathValidatorException; | |||
import java.security.cert.PKIXBuilderParameters; | |||
import java.security.spec.PSSParameterSpec; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need this import, as this class does not seem to be referenced anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. Thanks for the review.
@haimaychao 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:
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 265 new commits pushed to the
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 |
JAR_DISABLED_CHECK.permits(algParams, jcp); | ||
} catch (CertPathValidatorException e) { | ||
disabledAlgFound = true; | ||
return String.format(rb.getString("with.disabled"), algParams); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value of this method will be shown as the "Signature algorithm" in the output. It's OK to include an optional "weak" (or "disabled") tag, but the core part still must be an algorithm name. Here, the updated code returns the string format of algParams
, which is not an algorithm name.
I'm not sure how to fix this nicely. Certainly you want to show the user why it is weak so the weak part should be displayed. A verbose solution could be "RSASSA-PSS using PSSParameterSpec(...SHA-1...) (weak)", but the toString()
output of PSSParameterSpec
is quite long.
Same comment to the code change below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add "RSSSSA-PSS using “ to the -verbose
output as suggested, and keep the remaining output as the parameters for the RSASSA-PSS contain hashAlgorithm and maskGenAlgorithm that could be disabled or weak. At the same time, strip off the saltLength and trailerField display.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does it look like now? Also, you might need to create a mapping in Resources.java
because "using" should only be shown when system language is English.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what if it's another algorithm using another type of parameters? You cannot hardcode "RSASSA-PSS" and take it for granted that there is a "]" inside the string format of the parameter and it's the end of the weak part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made change to add "RSASSA-PSS using” before its parameter output when the signature algorithm is RSASSA-PSS. Also, keep the parameter string without doing further parsing and stripping off based on the "]".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return values of the 2 updated verifyWithWeak
methods need to be fixed.
if (algParams != null) { | ||
try { | ||
LEGACY_CHECK.permits(algParams, jcp); | ||
return alg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to return here since it will be returned on line 1445 anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
* @summary jarsigner -verify should check if the algorithm parameters of | ||
* its signature algorithm use disabled or legacy algorithms | ||
* @library /test/lib | ||
* @modules java.base/sun.security.x509 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this @modules
line useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, removed it. Thanks for the review!
return String.format(rb.getString("with.algparams.disabled"), | ||
"RSASSA-PSS", algParams); | ||
default: | ||
return String.format(rb.getString("with.disabled"), algParams); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to differentiate RSASSA-PSS and other algorithms. Just use the exact same format as you defined in Resources.java
. This makes sure if one day another type of algorithm parameters fail the check, we will see the algorithm name and full description of the parameters as well. If the description is not clear, it's the problem of its toString()
implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed code that differentiates.
"RSASSA-PSS", algParams); | ||
default: | ||
return String.format(rb.getString("with.weak"), algParams); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
/integrate |
Going to push as commit fb6b929.
Your commit was automatically rebased without conflicts. |
@haimaychao Pushed as commit fb6b929. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This fixes jarsigner to enforce checking against algorithm constraint properties so when the signature algorithms parameters use disabled or legacy algorithms, it will emit warnings accordingly. If the algorithm used in parameters is disabled, jarsigner treats the jar as unsigned.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7582/head:pull/7582
$ git checkout pull/7582
Update a local copy of the PR:
$ git checkout pull/7582
$ git pull https://git.openjdk.java.net/jdk pull/7582/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 7582
View PR using the GUI difftool:
$ git pr show -t 7582
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7582.diff