Repository navigation
[SPARK-59306][SS] Redact all JAAS credential styles in Kafka parameter logging - #58594
HyukjinKwon wants to merge 2 commits into
Conversation
|
Thanks for tightening this up. The direction looks right to me, and I verified two of the premises rather than assuming them:
That said, I have two correctness concerns and a test concern. 1. Escaped double quotes leak the tail of the credential (regression vs. the old pattern)
So with this patch: The trailing 2. The change also narrows redaction, which the PR description doesn't mentionThe description says "No behavior change other than that more JAAS credential fields are masked", but the greedy-to-precise switch cuts the other way too.
One option worth considering instead of hard-coding key names: split on 3. The new test would pass against a whole-string redactionIt only asserts Nit:
|
543116a to
722f13f
Compare
|
Thanks for the quick turnaround -- I re-ran my checks against One new issue, and it comes from my own suggestion, so let me be the one to point it out.
|
a4d19d1 to
6507fb0
Compare
…r logging ### What changes were proposed in this pull request? `KafkaRedactionUtil.redactJaasParam` redacts credential values in a `sasl.jaas.config` string before it is logged (at DEBUG). The previous regex `password="..."` only masked a double-quoted value of an option named `password`, so a `password` value in single-quoted or unquoted form, and the OAUTHBEARER `clientSecret` value, were not masked. This parses each `key=value` option in the JAAS entry (escape-aware for quoted values, so an escaped quote does not cut the value short) and redacts the value of an option in any quoting style when its name matches either: - the always-redacted credential options `password` and `clientSecret` (matched case-insensitively as a substring), which are masked unconditionally so redaction never depends on configuration; or - the configured `spark.redaction.regex`, which widens coverage on top of the built-in options. Because `spark.redaction.regex` replaces the default rather than extending it, consulting it alone would be fail-open (a user pattern that omits `password` would silently stop masking it); the union with the built-in options keeps the unconditional guarantee the old code had. Non-secret options (the login-module class, control flag, `username`, `serviceName`, `clientId`, ...) are left intact so the entry stays readable in logs. ### Why are the changes needed? So Kafka JAAS credentials are not exposed in DEBUG logs regardless of how they are quoted, and so the OAUTHBEARER `clientSecret` is masked as well as `password`. ### Does this PR introduce _any_ user-facing change? No functional change. This only affects DEBUG log output: `password` values in single-quoted and unquoted forms (in addition to the double-quoted form already masked), `clientSecret` values, and values of any option whose name matches `spark.redaction.regex` are now shown as `<option>="[redacted]"`. Since the default `spark.redaction.regex` includes `token`, a non-secret `tokenauth` option is also masked -- a minor debuggability cost. Nothing used to connect is affected. ### How was this patch tested? `KafkaRedactionUtilSuite`: `password` (double-quoted, single-quoted, unquoted) and `clientSecret` values are redacted while non-secret context (`username`, `clientId`) is preserved; an escaped quote inside a credential value does not leak the tail; `password` is still redacted when `spark.redaction.regex` is set to a pattern that omits it; and an option matching a configured `spark.redaction.regex` is additionally redacted. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 4.8
6507fb0 to
76e3c3d
Compare
dongjoon-hyun
left a comment
There was a problem hiding this comment.
LGTM. All three points from my last round are addressed, and I verified the result rather than taking it on faith:
- The union (
alwaysRedactedOptions || redactionPattern) closes the fail-open hole -- a narrowedspark.redaction.regexcan no longer disable credential masking, and the new test pins that down.(?i)does carry across the|in"(?i)password|clientSecret", soCLIENTSECRETmatches too. - The
tokenauthtradeoff is now documented at the call site, which is what I was after. TAIL_SECRETmakes the escaped-quote test assert what it means.
Test isolation on the two new setSparkEnv cases is fine -- afterEach restores the saved SparkEnv.
CI backs this up: every test job passed, including the one that runs token-provider-kafka-0-10/test.
One trivial thing left, which is the sole reason Linters, licenses, and dependencies is red:
[error] .../KafkaRedactionUtilSuite.scala:163: File line length exceeds 100 characters
Suggestion inline. Approving -- please merge once the linter is green.
…spark/kafka010/KafkaRedactionUtilSuite.scala
…r logging ### What changes were proposed in this pull request? `KafkaRedactionUtil.redactJaasParam` redacts credential values in a `sasl.jaas.config` string before it is logged (at DEBUG). The previous regex `password="..."` only masked a double-quoted value of an option named `password`, so a `password` value in single-quoted or unquoted form, and the OAUTHBEARER `clientSecret` value, were not masked. This parses each `key=value` option in the JAAS entry (escape-aware for quoted values, so an escaped quote does not cut the value short) and redacts the value of the credential options `password` and `clientSecret` (matched case-insensitively against the full option name), in any quoting style. Non-secret options (the login-module class, control flag, `username`, `serviceName`, `clientId`, ...) are left intact so the entry stays readable in logs. ### Why are the changes needed? So Kafka JAAS credentials are not exposed in DEBUG logs regardless of how they are quoted, and so the OAUTHBEARER `clientSecret` is masked as well as `password`. ### Does this PR introduce _any_ user-facing change? No functional change. This only affects DEBUG log output: `password` values in single-quoted and unquoted forms (in addition to the double-quoted form already masked) and `clientSecret` values are now shown as `<option>="[redacted]"`. Nothing used to connect is affected. ### How was this patch tested? `KafkaRedactionUtilSuite`: `password` (double-quoted, single-quoted, unquoted) and `clientSecret` values are redacted while non-secret context (`username`, `clientId`) is preserved, and an escaped quote inside a credential value does not leak the tail. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 4.8 Closes #58594 from HyukjinKwon/SPARK-59306-kafka-jaas-redaction. Lead-authored-by: Hyukjin Kwon <gurwls223@apache.org> Co-authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com> (cherry picked from commit 2d7b7af) Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
…r logging ### What changes were proposed in this pull request? `KafkaRedactionUtil.redactJaasParam` redacts credential values in a `sasl.jaas.config` string before it is logged (at DEBUG). The previous regex `password="..."` only masked a double-quoted value of an option named `password`, so a `password` value in single-quoted or unquoted form, and the OAUTHBEARER `clientSecret` value, were not masked. This parses each `key=value` option in the JAAS entry (escape-aware for quoted values, so an escaped quote does not cut the value short) and redacts the value of the credential options `password` and `clientSecret` (matched case-insensitively against the full option name), in any quoting style. Non-secret options (the login-module class, control flag, `username`, `serviceName`, `clientId`, ...) are left intact so the entry stays readable in logs. ### Why are the changes needed? So Kafka JAAS credentials are not exposed in DEBUG logs regardless of how they are quoted, and so the OAUTHBEARER `clientSecret` is masked as well as `password`. ### Does this PR introduce _any_ user-facing change? No functional change. This only affects DEBUG log output: `password` values in single-quoted and unquoted forms (in addition to the double-quoted form already masked) and `clientSecret` values are now shown as `<option>="[redacted]"`. Nothing used to connect is affected. ### How was this patch tested? `KafkaRedactionUtilSuite`: `password` (double-quoted, single-quoted, unquoted) and `clientSecret` values are redacted while non-secret context (`username`, `clientId`) is preserved, and an escaped quote inside a credential value does not leak the tail. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 4.8 Closes #58594 from HyukjinKwon/SPARK-59306-kafka-jaas-redaction. Lead-authored-by: Hyukjin Kwon <gurwls223@apache.org> Co-authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com> (cherry picked from commit 2d7b7af) Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
What changes were proposed in this pull request?
KafkaRedactionUtil.redactJaasParamredacts credential values in asasl.jaas.configstringbefore it is logged (at DEBUG). The previous regex
password="..."only masked a double-quotedvalue of an option named
password, so apasswordvalue in single-quoted or unquoted form, andthe OAUTHBEARER
clientSecretvalue, were not masked.This parses each
key=valueoption in the JAAS entry (escape-aware for quoted values, so anescaped quote does not cut the value short) and redacts the value of the credential options
passwordandclientSecret(matched case-insensitively against the full option name), in anyquoting style. Non-secret options (the login-module class, control flag,
username,serviceName,clientId, ...) are left intact so the entry stays readable in logs.Why are the changes needed?
So Kafka JAAS credentials are not exposed in DEBUG logs regardless of how they are quoted, and so
the OAUTHBEARER
clientSecretis masked as well aspassword.Does this PR introduce any user-facing change?
No functional change. This only affects DEBUG log output:
passwordvalues in single-quoted andunquoted forms (in addition to the double-quoted form already masked) and
clientSecretvalues arenow shown as
<option>="[redacted]". Nothing used to connect is affected.How was this patch tested?
KafkaRedactionUtilSuite:password(double-quoted, single-quoted, unquoted) andclientSecretvalues are redacted while non-secret context (
username,clientId) is preserved, and an escapedquote inside a credential value does not leak the tail.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.8