-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fix][broker] Use MessageDigest.isEqual when comparing digests #21061
Conversation
…lacing String.equals
@Crispy-fried-chicken Please add the following content to your PR description and select a checkbox:
|
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.
Thanks for your PR. Looks good to me.
I saw the Pulsar CI / Build and License check (pull_request) has been failed. Is there anything shall I change? |
@Crispy-fried-chicken Yes, you need to fix the code style issue:
|
OK, I've already fix it. Please review it again? Thank you! |
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.
LGTM. Note: I updated the PR name to remove certain words.
(cherry picked from commit c05954e)
(cherry picked from commit c05954e)
(cherry picked from commit c05954e)
(cherry picked from commit c05954e)
Fixes #21053
Main issue #21053
Motivation
I may have discovered a method in the newest version of pulsar, which has "Observable Timing Discrepancy" vulnerability. The vulnerability is located in the method org.apache.pulsar.broker.authentication.SaslRoleTokenSigner.verifyAndExtract(String signedStr) . The vulnerability bears similarities to a recent CVE disclosure GHSA-54g4-5cf6-hjp3 in the "apache/hive" project.
The source vulnerability information is as follows:
Vulnerability Description: The vulnerability exists within the String verifyAndExtract(String signedStr) method of the org.apache.pulsar.broker.authentication.SaslRoleTokenSigner class. It is responsible for authenticating and extracting SaslRoleToken. SaslRoleToken is a token used for authentication and authorization, which contains a signed string of information about roles and permissions.But the authentication snippet is similar to the vulnerable snippet for CVE-2020-1926 and may have the same consequence as CVE-2020-1926, where isvulnerable to timing attacks. Therefore, maybe you need to fix the vulnerability with much the same fix code as the CVE-2020-1926 patch.
Modifications
Verifying this change
I fix it by replacing
String.equals
withMessageDigest.isEqual
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete