Skip to content

Mask URL credentials in the Avro schema registry trace log and in URL rejection errors - #123226

Merged
CheSema merged 3 commits into
ClickHouse:masterfrom
groeneai:mask-avro-schema-registry-url-credentials
Oct 1, 2026
Merged

CheSema merged 3 commits into
ClickHouse:masterfrom
groeneai:mask-avro-schema-registry-url-credentials

Conversation

@groeneai

@groeneai groeneai commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #120407

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):

A password or presigned signature in a URL is no longer printed in clear by the ConfluentSchemaRegistry trace log, by the URL ... is not allowed in configuration file, see <remote_url_allow_hosts> error, or by the Unsupported scheme in URI error. These now show scheme://[HIDDEN]@host and X-Amz-Signature=[HIDDEN], as system.query_log already does for format_avro_schema_registry_url.

Description

Follow-up to review comment #120407 (comment) (the :178 item).

On 26.8 (26.8.10.6), format_avro_schema_registry_url = 'http://user:password@host/' is shown as http://[HIDDEN]@host/ by every setting sink, yet the password is printed in clear by:

  • the ConfluentSchemaRegistry: Fetching schema id = ... from url ... trace log;
  • Unsupported scheme in URI '...' from HTTPConnectionPool (for example an ftp:// registry URL);
  • URL "..." is not allowed in configuration file, see <remote_url_allow_hosts> from RemoteHostFilter::checkURL, which the registry URL reaches on a server, as do url(), URL and the other checkURL callers.

Each site printed Poco::URI::toString(), which includes the userinfo and the query. They now mask the rendered string with the existing maskURIUserinfo and maskPresignedURLParameters before printing it; checkURL first turns %3F back into ?, because compatibility_s3_presigned_url_query_in_path folds an S3 presigned query into the path (as S3::maskedURIString does). The request itself still uses the unmasked URL. The pair is not extracted into a helper because #120407 adds exactly that helper (maskURICredentials).

Tests: 05315_avro_schema_registry_url_credentials_masked covers the trace log and the unsupported-scheme error (the latter for userinfo and, through the AvroConfluent output, a presigned signature); test_allowed_url_from_config::test_rejected_url_credentials_masked covers the remote_url_allow_hosts rejection for userinfo, a presigned signature, the registry URL and an S3 presigned query folded into the path. Both fail on master and pass with the fix.

The HTTP 409 path of registerSchema and the HTTPCommon.cpp items from the same review build on code that only #120407 adds, so they follow its merge.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.1198-master (included in 26.10 and later)

groeneai and others added 3 commits October 1, 2026 08:29
… rejection errors

`format_avro_schema_registry_url` may carry Basic-auth credentials in its userinfo and is
listed in `SETTINGS_TO_HIDE`, so every setting sink shows `http://[HIDDEN]@host`. Three
places still printed the full URL, because they render a `Poco::URI` with `toString()`,
which includes the userinfo and the query (where a presigned URL keeps its signature):

- the `ConfluentSchemaRegistry` "Fetching schema id = ... from url ..." trace log;
- `useSecureConnection` in `HTTPConnectionPool.cpp`: "Unsupported scheme in URI";
- `RemoteHostFilter::checkURL`: "URL ... is not allowed in configuration file", reached
  by the registry URL on a server and by `url()`, `URL` and the other `checkURL` callers.

Mask the rendered string at each site with the existing `maskURIUserinfo` and
`maskPresignedURLParameters`. The two errors are fixed in the shared functions rather
than at the Avro caller. The request still uses the unmasked URL. The pair is not
extracted into a helper here because ClickHouse#120407 adds exactly that helper
(`maskURICredentials`) to `maskURIPassword.h`.

Measured on master and on 26.8.10.6: the trace line and the unsupported-scheme error print
`http://user:password@...`; `checkURL` prints it on master with `remote_url_allow_hosts`.

Tests: `05315_avro_schema_registry_url_credentials_masked` (trace log and unsupported
scheme, each with a positive control on the masked shape) and
`test_allowed_url_from_config::test_rejected_url_credentials_masked` (userinfo, presigned
signature, registry URL). Both fail on master and pass with the fix.

Review comment: ClickHouse#120407 (comment)
Related: ClickHouse#120407

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With `compatibility_s3_presigned_url_query_in_path = 1`, `S3::URI` folds a presigned query into the
path, so `toString()` renders its `?` as `%3F` and `maskPresignedURLParameters` did not see the
signature; `checkURL` now restores the `?` before the presigned scan, as `S3::maskedURIString` does.

Test: a fourth `test_rejected_url_credentials_masked` case, `s3()` with that setting.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…through the AvroConfluent output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 1, 2026
@groeneai

groeneai commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex, 3 rounds) plus my own review.

# Sev Finding Verdict Evidence / action
1 ❌ With compatibility_s3_presigned_url_query_in_path = 1 the S3 query is folded into the path (%3F), so checkURL misses its first parameter AGREE, fixed checkURL restores %3F before the presigned scan, as S3::maskedURIString does; new s3() arm, reddens when the line is deleted
2 ❌ A percent-encoded parameter name (%58-Amz-Signature) is not masked DISAGREE every existing masker matches names literally (FunctionSecretArgumentsFinder.cpp:20-27, SettingsSecrets.h:39, S3/URI.cpp:44-55), so the query text of the same query keeps it too
3 ❌ The fold also needs handling in useSecureConnection DISAGREE no caller passes the folded S3::URI to makeHTTPSession; the S3 client passes the SDK request URI, always http/https
4 ⚠️ No test proves presigned masking in the Unsupported scheme in URI error AGREE, fixed new 05315 arm through the AvroConfluent output (registerSchema passes the registry URL with its query); fails on master and when maskPresignedURLParameters is deleted in useSecureConnection
5 💡 The same mask at three sites noted #120407 adds maskURICredentials for exactly this pair
6 💡 A literal %3F in a non-S3 url() path is shown as ? in the rejection noted message only, same rendering as S3::maskedURIString
7 💡 The 05315 header comment describes only the userinfo shape, not the presigned one noted test comment only; the assertions check the exact masked string of each arm

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

@groeneai

groeneai commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. clickhouse local --send_logs_level=trace -q "SELECT * FROM format(AvroConfluent, 'a UInt8', '\x00\x00\x00\x00\x01') SETTINGS format_avro_schema_registry_url='http://u:[email protected]:1/', format_avro_schema_registry_max_retries=0" prints the password in the trace line every run; an ftp:// URL prints it in Unsupported scheme in URI; a server with remote_url_allow_hosts prints it in the rejection.
b Root cause explained? The three sites print Poco::URI::toString(), which includes the userinfo and the query. The setting is masked only at the setting sinks, so these renders bypass it.
c Fix matches root cause? Yes. The rendered string is masked at each sink with the existing maskURIUserinfo and maskPresignedURLParameters; the two errors are fixed in their shared functions, not at the Avro caller.
d Test intent preserved / new tests added? New stateless test 05315 (trace log; unsupported scheme for userinfo and, through the AvroConfluent output, a presigned signature) and integration test test_rejected_url_credentials_masked (userinfo, presigned, registry URL, S3 presigned query folded into the path). No existing test changed.
e Both directions demonstrated? Yes. Both tests fail on master (cleartext) and pass with the fix; deleting the maskURIUserinfo call at the trace log turns its arm red again, deleting the %3F restore in checkURL turns only the folded-S3 arm red, and deleting maskPresignedURLParameters in useSecureConnection turns only the presigned unsupported-scheme arm red. 50/50 randomized runs pass.
f Fix is general across code paths? The other renders on the registry path are path-only (getURI() of path-only requests, the :268 trace), host-only (DNS and connect errors, checkHostAndPort) or already masked (setting parse error). The 409 body path changes code only #120407 adds and follows its merge.
g Fix generalizes across inputs (params/datatypes/wrappers)? Userinfo with password, presigned X-Amz-Signature (also folded into the path by compatibility_s3_presigned_url_query_in_path, restored from %3F as S3::maskedURIString does), http and ftp schemes are tested; credential-free URLs are unchanged, and a password containing @ is masked whole (helpers covered by gtest_mask_uri_password).
h Backward compatible? (maintainer-approved exception only) Yes. Only the text of these messages changes, and only for URLs that carry a credential. No setting, format or protocol change.
i Invariants and contracts preserved? The same error codes are thrown on the same conditions, and the request still uses the unmasked URL for authentication. No locking change; one string copy on the throw paths and per uncached schema fetch.

Session id: cron:clickhouse-impl-slot-6:20261001-075500

@clickhouse-gh

clickhouse-gh Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6ec21f6]

Summary: ✅


AI Review

Summary

This PR masks URI userinfo and presigned-signature query values in the three paths that previously rendered Poco::URI::toString() verbatim: the ConfluentSchemaRegistry trace log, the Unsupported scheme in URI exception, and the RemoteHostFilter::checkURL rejection. The change is surgical, keeps request behavior unchanged, and adds focused stateless and integration coverage for the reported regressions; I did not find an unresolved correctness, compatibility, or safety issue in the current diff.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit 6ec21f6.

Metric Baseline Current Δ
Lines 88.30% 88.30% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 79.70% 79.70% +0.00%

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

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 1, 2026
@CheSema
CheSema enabled auto-merge October 1, 2026 10:21
@CheSema CheSema self-assigned this Oct 1, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). label Oct 1, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 6ec21f6bd with master d96270ddd (stripped binary size, per-symbol sizes and ThinLTO time; 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

5 object files changed (+53.96 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/clickhouse_common_io.dir/Common/RemoteHostFilter.cpp.o 71.79 KiB 115.61 KiB +43.81 KiB (+61.03%)

716 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

9 translation units recompiled, 17 s compile time in total, 9 of them have a recent master baseline.

Job report

@CheSema
CheSema added this pull request to the merge queue Oct 1, 2026
Merged via the queue into ClickHouse:master with commit 1f07c45 Oct 1, 2026
149 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 1, 2026
@clickhouse-gh clickhouse-gh Bot added comp-networking The connection layer under the protocols, on the server and on the client side: socket read / wri... and removed comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-networking The connection layer under the protocols, on the server and on the client side: socket read / wri... groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants