KAFKA-20964: Do not echo salt or saltedPassword in ScramParser errors - #23312
Open
shantanushukla wants to merge 1 commit into
Open
KAFKA-20964: Do not echo salt or saltedPassword in ScramParser errors#23312shantanushukla wants to merge 1 commit into
shantanushukla wants to merge 1 commit into
Conversation
On Base64 decode failure, FormatterException included the user-supplied value. kafka-storage format --add-scram prints that message to stderr. Keep a generic message and the IllegalArgumentException cause.
|
A label of 'needs-attention' was automatically added to this PR in order to raise the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JIRA: https://issues.apache.org/jira/browse/KAFKA-20964
kafka-storage format --add-scramparses SCRAM credentials inScramParser. On Base64 decode failure,PerMechanismDatabuilt aFormatterExceptionwhose message included the user-suppliedsaltedpassword(and the same forsalt).StorageToolprintsgetMessage()to stderr, so credential-adjacent input was echoed in the CLI error.Fix
Use a generic decode-failure message and keep the
IllegalArgumentExceptionas the cause. Do not concatenate the user-supplied value.This matches the existing request-side practice of not printing salt or salted password (
AlterUserScramCredentialsRequest). Decode details remain on the cause if it is logged.Why existing tests missed this
ScramParserTestcovered valid Base64saltedpassword/saltand missing-field errors (name,password,saltrequired withsaltedpassword, extra keys). None of those paths throw on Base64 failure, so the decode-error message was never asserted.Tests
These failed on trunk (message included the raw input) and pass after this change:
testParsePerMechanismDataFailsWithInvalidSaltedPasswordBase64— valid salt so construction reaches the salted-password decoder;saltedpassword="not-valid-base64!!!". Trunk:Failed to decode given saltedPassword: not-valid-base64!!!. After:Failed to decode given saltedPassword.testParsePerMechanismDataFailsWithInvalidSaltBase64—salt="%%%". Trunk:Failed to decode given salt: %%%. After:Failed to decode given salt.Related existing tests still pass: full
ScramParserTest(including validsaltedpasswordparse andtoRecord()).BUILD SUCCESSFUL.