Skip to content

Hide secret key in HMAC SQL function - #102997

Merged
Felixoid merged 2 commits into
masterfrom
hmac-secret-hidden
Apr 21, 2026
Merged

Felixoid merged 2 commits into
masterfrom
hmac-secret-hidden

Conversation

@Felixoid

@Felixoid Felixoid commented Apr 17, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Hide secret key in HMAC SQL function. Fix #102927.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.1114
  • Backported to: 26.3.10.30, 26.2.17.19, 26.1.12.14

@clickhouse-gh

clickhouse-gh Bot commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [209cae1]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) FAIL
04057_transaction_version_metadata_lifecycle FAIL cidb, issue
Stateless tests (amd_llvm_coverage, 3/3) FAIL
03150_trace_log_add_build_id FAIL cidb

AI Review

Summary

This PR updates FunctionSecretArgumentsFinder to treat HMAC keys as secrets and extends stateless query-cache tests to verify key redaction in system.query_cache. The change is focused and correct; I did not find blockers or major risks in correctness, safety, or performance.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Apr 17, 2026
@Felixoid
Felixoid force-pushed the hmac-secret-hidden branch from 85618c2 to c3d3536 Compare April 17, 2026 15:27
@scanhex12 scanhex12 self-assigned this Apr 20, 2026

@scanhex12 scanhex12 left a comment

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.

looks good

@Felixoid
Felixoid force-pushed the hmac-secret-hidden branch from 654a68a to 70e434c Compare April 21, 2026 10:05
@Felixoid
Felixoid force-pushed the hmac-secret-hidden branch 2 times, most recently from 3591057 to 74b359c Compare April 21, 2026 11:53
@Felixoid
Felixoid force-pushed the hmac-secret-hidden branch from 74b359c to 209cae1 Compare April 21, 2026 16:06
@Felixoid
Felixoid enabled auto-merge April 21, 2026 19:05
@Felixoid
Felixoid added this pull request to the merge queue Apr 21, 2026
Merged via the queue into master with commit fa20586 Apr 21, 2026
159 of 161 checks passed
@Felixoid
Felixoid deleted the hmac-secret-hidden branch April 21, 2026 21:16
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 21, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Hi — this PR may need backporting to 26.3 (LTS), 26.2, 26.1, but no backport label was found.

Affected code: FunctionSecretArgumentsFinder::findOrdinaryFunctionSecretArguments in FunctionSecretArgumentsFinder.h — introduced in 26.1.

Why: Security fix: HMAC function secret key leaks in system.query_log and system.query_cache. The HMAC function was introduced in commit e115854 (2025-11-25), after the 25.8 release (2025-08-29) but before 26.1 (2026-01-30). Therefore 25.8 does not contain HMAC and needs no backport; 26.1, 26.2, and 26.3 all contain HMAC and need this fix.

Other supported branches (25.8) predate 26.1 and do not contain this code.

If this should be backported, consider adding pr-must-backport or a version-specific label (e.g. v26.3-must-backport). Ignore this if backporting is not applicable.

@clickhouse-gh

clickhouse-gh Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 91.10% 91.10% +0.00%
Branches 76.60% 76.50% -0.10%

Changed lines: 100.00% (11/11) · Uncovered code

Full report · Diff report

robot-clickhouse-ci-2 added a commit that referenced this pull request Apr 22, 2026
Cherry pick #102997 to 26.3: Hide secret key in HMAC SQL function
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Apr 22, 2026
Felixoid added a commit that referenced this pull request Apr 22, 2026
Backport #102997 to 26.3: Hide secret key in HMAC SQL function
Felixoid added a commit that referenced this pull request Apr 22, 2026
Backport #102997 to 26.1: Hide secret key in HMAC SQL function
Felixoid added a commit that referenced this pull request Apr 22, 2026
Backport #102997 to 26.2: Hide secret key in HMAC SQL function
Algunenano added a commit that referenced this pull request Jun 26, 2026
… 25.8

The 25.8 release has no `HMAC` SQL function (`src/Functions/HMAC.cpp` was
added later), so the HMAC cases throw `UNKNOWN_FUNCTION`. Remove the HMAC
`EXPLAIN actions` case from `04409_explain_actions_secret_args` and revert the
`findHMACSecretArguments` fold-in (upstream #102997) together with its
`02494_query_cache_secrets` changes. The `encrypt`/`decrypt` masking that this
backport targets still applies and is verified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default 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 v26.2-must-backport v26.3-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HMAC() function does not redact the secret key in system.query_log

4 participants