Repository navigation
Cherry pick #120313 to 26.9: Hide secret arguments in EXPLAIN AST output - #122803
Merged
Merged
Conversation
`EXPLAIN AST optimize = 1` inlines the definition of a view the user may `SELECT` from and dumps the result through `DumpASTNode`, which prints every literal verbatim. A user holding only `SELECT` on a `SQL SECURITY DEFINER` view could therefore read the definer's `encrypt` key that `SHOW CREATE VIEW` masks for the same user. The secret arguments found by `FunctionSecretArgumentsFinderAST` are now replaced with `'[HIDDEN]'` literals before the dump, under the same gate as `SHOW CREATE`, for the tree and the `graph = 1` output alike and for `optimize = 0` as well. Closes: ClickHouse/clickhouse-private#72669 Related: #118129
The visitor and call-site comments now say in short sentences what the dump cannot do and why the tree is edited instead. The test header reads the same way. No behaviour change.
The dump looked for a `key = value` pair inside every secret argument and kept the key visible.
`SHOW CREATE` does that only for a named argument and hides a positional one whole. A positional
secret written as a comparison, such as `encrypt('aes-128-ecb', 'plain', 'k1' = 'k2')`, therefore
showed its left operand. The dump now peels the value only when the finder reports the argument
as named, or when it is an entry of a nested map such as `headers(...)`.
`HideSecretArgumentsMatcher` ran `hideLiteralsInSubtree` on every secret slot, so a slot that `markSecretArgument` marks because the finder cannot read it (a url built by `concat(...)`, an identifier in a password slot, a positional secret written as a comparison) still dumped its expression node by node: `Function concat`, `Function equals`, `Identifier ...`. That is part of a `SQL SECURITY DEFINER` view body. Such a slot is now one `'[HIDDEN]'` literal, as `ASTFunction::formatImpl` prints it. A partially masked argument (a URL with its credentials removed, the reconstructed `S3(...)` of a `Backup` database) is re-parsed from the formatter text instead of walked. `hideLiteralsInSubtree` is kept only for the `encrypt` / `HMAC` key, where the expression shape is not a secret. The test prints the full AST for the fail-closed shapes so the collapse to a single node is visible. Review: #120313 (comment)
Keep `EXPLAIN AST` secret masking and the upstream removal of obsolete plan-secret checks. Co-authored-by: Copilot App <[email protected]>
The upgrade check failed on the old base because master has since disabled the AI function quotas by default, so the previous release and this branch disagreed on the defaults of `ai_function_max_*_per_query`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t` / `HMAC`
The visitor treated every unnamed secret span without a replacement as the
`encrypt` / `HMAC` span and hid only the literals inside it. `mongodb` with
two arguments produces the same shape when the finder cannot read the url,
so `EXPLAIN AST` of `mongodb(concat('mongodb://user:', password_column, '@host/db'), 'c')`
still dumped `Function concat` and `Identifier password_column`.
`SHOW CREATE` prints `'[HIDDEN]'` for the whole argument there.
Keep the structure only for the functions the finder masks as
`encrypt` / `HMAC`, and hide any other such slot whole.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Hide secret arguments in `EXPLAIN AST` output
Contributor
|
Dear @harikrishnan94, @Fgrtue, this cherry-pick PR has not been updated for 3d0h6m7s. Please resolve the conflicts to backport #120313, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity. |
The only conflict is in `InterpreterExplainQuery.cpp`: the new `EXPLAIN AST` secret-hiding helpers are inserted where `release/26.9` has the plan-dump secret checks. Keep both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Original pull-request #120313
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job