[fix][broker] Use MessageDigest.isEqual when comparing digests#21061
[fix][broker] Use MessageDigest.isEqual when comparing digests#21061michaeljmarshall merged 2 commits intoapache:masterfrom Crispy-fried-chicken:master
Conversation
…lacing String.equals
|
@Crispy-fried-chicken Please add the following content to your PR description and select a checkbox: |
RobertIndie
left a comment
There was a problem hiding this comment.
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! |
michaeljmarshall
left a comment
There was a problem hiding this comment.
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.equalswithMessageDigest.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
docdoc-requireddoc-not-neededdoc-complete