Skip to content

Do not log kafka secrets - #119244

Merged
antaljanosbenjamin merged 5 commits into
masterfrom
fix-kafka-producer-password-log
Sep 29, 2026
Merged

antaljanosbenjamin merged 5 commits into
masterfrom
fix-kafka-producer-password-log

Conversation

@antaljanosbenjamin

@antaljanosbenjamin antaljanosbenjamin commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Kafka producer and consumer trace logs now show the value of secret librdkafka properties, such as sasl.password, as [HIDDEN] instead of the cleartext value.


Workflow [PR]
Sync PR [sync-upstream/pr/119244]

Version info

  • Merged into: 26.10.1.1030-master (included in 26.10 and later)
  • Backported to: 26.9.7.5, 26.8.15.12, 26.7.18.4, 26.3.38.2

@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [72d0f59]

Summary: ✅


AI Review

Summary

This PR stops KafkaConfigLoader from dumping librdkafka sensitive property values into producer and consumer trace logs by deriving the redaction set from rd_kafka_properties, and it adds regression coverage for that trace-log path. The remaining gap is that the new _RK_SENSITIVE contract is not propagated to SQL/query logging, so one of the values now treated as sensitive in trace logs can still be emitted in cleartext through CREATE TABLE / SHOW CREATE / system.query_log.

PR Metadata
  • Changelog category: Critical Bug Fix (crash, data loss, RBAC) does not match this change. This is a user-visible logging/privacy fix, not a crash/data-loss/RBAC bug. Exact replacement: - Bug Fix (user-visible misbehavior in an official stable release).
  • Changelog entry: required for Bug Fix; the current entry is specific enough and would be fine after the category is corrected.
Findings

⚠️ Majors

  • [src/Storages/Kafka/KafkaConfigLoader.cpp:563-565] librdkafka's _RK_SENSITIVE flag is now the source of truth for Kafka secret redaction, but the SQL-formatting masks are still hard-coded to kafka_sasl_password only (src/Storages/Kafka/Kafka_fwd.h, src/Parsers/FunctionSecretArgumentsFinder.cpp). As a result, sasl.username is hidden in the producer/consumer trace dump but the same value is still written in cleartext when users configure it through CREATE TABLE ... SETTINGS kafka_sasl_username = '...', because SHOW CREATE and system.query_log still format it unmasked. Keep the SQL masking lists in sync with the new sensitive-property contract, or stop relying on sasl.username as the proof that the broader sensitive set is covered.
Tests
  • ⚠️ Add a focused parser/logging regression next to MaskKafkaTableEngineCredentials proving kafka_sasl_username is hidden by formatForLogging() once the SQL masking is updated, so the trace-log and query-log redaction rules cannot drift again.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    1. Extend Kafka SQL/query-log masking to cover every SQL-visible setting that maps to a librdkafka sensitive property, at least kafka_sasl_username.
    2. Fix the changelog category.

LLVM Coverage Report

Measured on commit 72d0f59.

Metric Baseline Current Δ
Lines 87.90% 87.90% +0.00%
Functions 91.70% 91.70% +0.00%
Branches 79.30% 79.30% +0.00%

Changed lines: Changed C/C++ lines covered: 16/16 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Sep 10, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-message-queues Message queue integrations (Kafka, RabbitMQ, NATS table engines for stream ingestion/egress). label Sep 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 72d0f59c8 with master 2ce29bc30 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of bdc5f8669; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

3 object files changed (+188.01 KiB total), 1 added.

Object file Master PR Δ
contrib/librdkafka-cmake/CMakeFiles/_rdkafka.dir/rdkafka_conf_sensitive.c.o new 188.57 KiB +188.57 KiB

717 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

8 translation units recompiled, 11 s compile time in total, 7 of them have a recent master baseline.

Job report

@clickhouse-gh clickhouse-gh Bot added the submodule changed At least one submodule changed in this PR. label Sep 23, 2026
@Algunenano Algunenano self-assigned this Sep 24, 2026
Comment thread contrib/librdkafka-cmake/CMakeLists.txt Outdated
# Generate the list of configuration properties that librdkafka marks with the _RK_SENSITIVE
# flag. ClickHouse uses it to hide the values of these properties in logs, because the public
# rd_kafka_conf_dump does not redact them.
set(RDKAFKA_SENSITIVE_PROPERTIES_HEADER "${CMAKE_CURRENT_BINARY_DIR}/generated/librdkafka_sensitive_properties.h")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try including the .c instead (in a namespace to avoid conflicts) and see if we can use the array directly. It's a much simpler code and we don't need to regenerate or handle bash

@antaljanosbenjamin

Copy link
Copy Markdown
Member Author

Size impact:

  • Duplicate rd_kafka_properties table — 134,400 bytes, .data (on disk); the irreducible cost, not foldable because it contains relocated pointers
  • chrd_kafka_conf_sensitive_properties — 29 bytes, .text
  • chrd_fill_sensitive_names — 67 bytes, .text
  • chrd_sensitive_names pointer array — 1,680 bytes, .bss (zero on disk, runtime memory only)
  • chrd_sensitive_names_once — 4 bytes, .bss
  • 65 renamed function copies — 0 bytes (garbage-collected by --gc-sections)
  • Total on disk: ~134.5 KB, about 0.006% of the binary

{
/// The properties librdkafka marks with the _RK_SENSITIVE flag, plus a substring safety net
/// for properties unknown to the vendored librdkafka version.
static const std::unordered_set<std::string_view> sensitive_properties = []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now takes librdkafka's _RK_SENSITIVE set as the source of truth, but the SQL-formatting masks are still hard-coded to kafka_sasl_password only (src/Storages/Kafka/Kafka_fwd.h and src/Parsers/FunctionSecretArgumentsFinder.cpp). That means sasl.username is redacted in the producer/consumer trace dump here, yet CREATE TABLE ... SETTINGS kafka_sasl_username = '...' still exposes the same value through SHOW CREATE and system.query_log.

If sasl.username is sensitive enough to prove the broader _RK_SENSITIVE path works, the SQL/query-log masking needs to stay in sync as well.

@antaljanosbenjamin
antaljanosbenjamin added this pull request to the merge queue Sep 29, 2026
Merged via the queue into master with commit ccb067e Sep 29, 2026
149 checks passed
@antaljanosbenjamin
antaljanosbenjamin deleted the fix-kafka-producer-password-log branch September 29, 2026 20:35
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 29, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 29, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 29, 2026
Backport #119244 to 26.9: Do not log kafka secrets
clickhouse-gh Bot pushed a commit that referenced this pull request Sep 29, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 29, 2026
Backport #119244 to 26.8: Do not log kafka secrets
antaljanosbenjamin added a commit that referenced this pull request Sep 30, 2026
Cherry pick #119244 to 26.7: Do not log kafka secrets
antaljanosbenjamin added a commit that referenced this pull request Sep 30, 2026
Cherry pick #119244 to 26.3: Do not log kafka secrets
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 30, 2026
antaljanosbenjamin added a commit that referenced this pull request Sep 30, 2026
Backport #119244 to 26.3: Do not log kafka secrets
clickhouse-gh Bot added a commit that referenced this pull request Sep 30, 2026
Backport #119244 to 26.7: Do not log kafka secrets
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Oct 2, 2026
@clickhouse-gh clickhouse-gh Bot added comp-kafka Kafka table engine: consumers and producers on librdkafka, the Kafka2 engine that keeps offsets i... and removed comp-message-queues Message queue integrations (Kafka, RabbitMQ, NATS table engines for stream ingestion/egress). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-kafka Kafka table engine: consumers and producers on librdkafka, the Kafka2 engine that keeps offsets i... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants