Skip to content

Mask URL credentials in the index page listing errors of a URL wildcard - #126184

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:mask-index-page-url-credentials
Oct 19, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:mask-index-page-url-credentials

Conversation

@groeneai

@groeneai groeneai commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #120425
Related: #120407
Related: #123226

Changelog category (leave one):

  • Improvement

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

Credentials in the URL of a url wildcard expanded from HTTP index pages (allow_url_wildcard_from_index_pages), or of a web_index disk, are now masked in the errors about an index page redirected to a different origin and about an index page over max_http_index_page_size.

Description

With allow_url_wildcard_from_index_pages = 1, two errors raised while listing index pages printed the listing URL with its userinfo:

Index page 'http://leak_user:[email protected]:21001/redir/' was redirected to a different origin 'http://127.0.0.1:21002/redir/'. (BAD_ARGUMENTS)
Index page 'http://leak_user:[email protected]:21001/big/' exceeds max_http_index_page_size. (BAD_ARGUMENTS)

The query text is logged masked, so the password reached the client, the server log and system.query_log.exception only through these messages. The listing URLs keep the userinfo because the index page request authenticates from it; #120407 masked the URL renders of the HTTP buffer layer, and these two messages are built above it, in the index page lister.

The three format arguments now get a copy masked with maskURICredentials, the helper #120407 uses for the other renders (http://[HIDDEN]@host/...). The request and the origin comparison still use the raw URLs. A web_index disk runs the same code.

This is the follow-up I offered on #120425 for its three remaining sites:

  1. RemoteHostFilter::checkURL: fixed by Mask URL credentials in the Avro schema registry trace log and in URL rejection errors #123226.
  2. The StorageURLWithFailover "Adding URL option" debug log: unreachable, the class is no longer constructed anywhere.
  3. The two index page errors: this PR.

Tests: test_storage_url test_url_wildcard_rejects_cross_origin_index_redirect (the redirect target now carries its own userinfo) and test_url_wildcard_oversize_index_page (the URL now has userinfo) check that the server's message has no credentials and renders http://[HIDDEN]@.... Both fail without the src/ change, and masking only the requested URL fails the redirect test.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.182-master (included in 26.11 and later)
  • Backported to: 26.10.7.5, 26.9.33.8, 26.8.41.9

The listing URLs built for a `url()` wildcard expanded from HTTP index pages
(and for a `web_index` disk) keep the source URL's userinfo, because the
index page request authenticates from it. The two `BAD_ARGUMENTS` errors
raised while listing ("redirected to a different origin" and "exceeds
max_http_index_page_size") formatted those URLs as is, so the password
reached the client, the server log and `system.query_log.exception`, while
the query text itself is logged masked. ClickHouse#120407 masked the URL renders of
the HTTP buffer layer; these messages are built above it.

Format a copy masked with `maskURICredentials`; the request and the origin
comparison keep the raw URLs.

Tests: the cross-origin redirect now points at a target with its own
userinfo, and the oversize test URL has userinfo. The assertions read the
server's part of the error, because the client appends the query text it
sent, which carries the credentials the test typed.

Closes ClickHouse#120425

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

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

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (3 nits, none blocking).

# Sev Finding Verdict Evidence / action
1 💡 maskedURL is a second file-local copy-then-mask wrapper next to maskedURI in ReadWriteBufferFromHTTP.cpp AGREE, not changed a shared helper in maskURIPassword.h would move #120407's call sites; kept out of this PR
2 💡 MetadataStorageFromStaticFilesWebServer.cpp:151 traces the web disk base URL raw AGREE, not changed its .index fetch sends empty credentials, so no working web disk configuration carries a credential in that URL
3 💡 StorageURLWithFailover is never constructed AGREE, not changed deleting the dead class is a separate refactor

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

Session id: cron:clickhouse-review-slot-10:20261016-024700

@clickhouse-gh

clickhouse-gh Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [85ee3ab]

Summary: ✅


AI Review

Summary

PR #126184, reviewed at 85ee3abe2ba8cb0fb044fd3ea339c5bfa3f4e048, masks credentials in cross-origin redirect and oversized index-page errors shared by url wildcard expansion and web_index disks. No actionable findings.

Missing context / blind spots
  • ⚠️ Integration CI is still pending in the workflow report. Runtime evidence comes from the author's reported runs: both modified regressions fail without the fix and pass with it. I did not rerun the integration suite locally; completed test_storage_url CI results would independently confirm that evidence.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Oct 16, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. url('http://leak_user:PW@host/redir/*.csv', ...) against a 302 to another port, and .../big/*.csv with max_http_index_page_size=2000, print the password on every run on master.
b Root cause explained? The listing URLs keep the userinfo for authentication, and rejectOriginChangingRedirect and the oversize rewrite in tryListDirectory formatted them raw; #120407 masked only the HTTP buffer layer below.
c Fix matches root cause? Yes. A masked copy is formatted at the only place these strings are rendered; the request and the origin comparison keep the raw URLs.
d Test intent preserved / new tests added? Two existing integration tests extended: the redirect target now has its own userinfo, the oversize URL gains userinfo; [HIDDEN] positive controls prove the URL was rendered. Existing assertions kept.
e Both directions demonstrated? Yes. Without the src/ change both tests fail on the new assertions; masking only the requested URL fails the redirect test; with the fix 50/50 runs pass and the whole module passes (65/65).
f Fix is general across code paths? The other messages in the file format relative paths or indexes; buffer-layer renders are masked by #120407 and RemoteHostFilter by #123226; the StorageURLWithFailover log is unreachable.
g Fix generalizes across inputs (params/datatypes/wrappers)? Userinfo, presigned-URL parameters (measured X-Amz-Signature=[HIDDEN]), and URLs without credentials (unchanged); both arguments of the redirect message; url() and a web_index disk share the code.
h Backward compatible? (maintainer-approved exception only) Yes. Only the text of two error messages changes.
i Invariants and contracts preserved? The origin check still compares the raw URLs, the oversize error still maps to BAD_ARGUMENTS per shard, and the helper works on a copy.

Session id: cron:clickhouse-impl-slot-41:20261016-021100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov @Michicosun, could you review this and add can be tested (I cannot add labels right now)? The two errors raised while listing the index pages of a url wildcard (cross-origin redirect, page over max_http_index_page_size) formatted the listing URL with its userinfo; they are built above the HTTP buffer layer that #120407 masked, and now get a copy masked with maskURICredentials.

@clickhouse-gh clickhouse-gh Bot added the comp-object-storage-disks Object-storage disk layer: DiskObjectStorage, metadata storage adapters, transaction support for ... label Oct 16, 2026
@tiandiwonder tiandiwonder self-assigned this Oct 16, 2026
@tiandiwonder tiandiwonder added the can be tested Allows running workflows for external contributors label Oct 16, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 85ee3abe2 with master 6bb427c9a (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of e5791b213; compile times per translation unit against the most recent warmup build that recompiled it).

⚠️ Significant changes: object file sizes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 785.87 MiB 784.58 MiB -1.29 MiB (-0.16%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

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 ⚠️

917 object files changed (-2.86 MiB total), 3 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/DataTypes/TypeFunctions.cpp.o new 1.00 MiB +1.00 MiB
src/CMakeFiles/dbms.dir/Interpreters/Aggregator.cpp.o 25.56 MiB 26.43 MiB +895.89 KiB (+3.42%)
src/CMakeFiles/dbms.dir/DataTypes/TypeMatchers.cpp.o new 692.78 KiB +692.78 KiB
src/CMakeFiles/dbms.dir/DataTypes/FunctionSignature.cpp.o new 417.14 KiB +417.14 KiB
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayDotProduct.cpp.o 1.75 MiB 1.55 MiB -201.52 KiB (-11.24%)
src/CMakeFiles/dbms.dir/Functions/FunctionsConversion_impl2.cpp.o 1.31 MiB 1.14 MiB -174.78 KiB (-13.07%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsBitmap.cpp.o 2.58 MiB 2.41 MiB -167.40 KiB (-6.35%)
src/CMakeFiles/dbms.dir/Functions/FunctionsConversion_impl1.cpp.o 1.12 MiB 986.07 KiB -160.78 KiB (-14.02%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/vectorFunctions.cpp.o 3.29 MiB 3.43 MiB +148.59 KiB (+4.41%)
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayCumSumNonNegative.cpp.o 603.16 KiB 466.82 KiB -136.34 KiB (-22.60%)
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayCumSum.cpp.o 673.15 KiB 538.16 KiB -134.99 KiB (-20.05%)
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayAggregation.cpp.o 1.29 MiB 1.16 MiB -134.86 KiB (-10.22%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsCodingIP.cpp.o 1.27 MiB 1.13 MiB -133.67 KiB (-10.32%)
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayDifference.cpp.o 592.61 KiB 478.04 KiB -114.56 KiB (-19.33%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsJSON.cpp.o 4.26 MiB 4.37 MiB +111.80 KiB (+2.57%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsHashingMisc.cpp.o 5.53 MiB 5.61 MiB +83.25 KiB (+1.47%)
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayDistance.cpp.o 10.19 MiB 10.11 MiB -78.98 KiB (-0.76%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsConversion_reg.cpp.o 6.83 MiB 6.75 MiB -78.39 KiB (-1.12%)
src/CMakeFiles/dbms.dir/Functions/FunctionsConversion_impl3.cpp.o 1.87 MiB 1.80 MiB -76.37 KiB (-3.98%)
src/CMakeFiles/dbms.dir/Functions/IFunction.cpp.o 555.11 KiB 631.16 KiB +76.05 KiB (+13.70%)

719 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

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

Job report

}

/// Listing URLs keep the source URL's userinfo for authentication, so only a masked copy may be formatted.
std::string maskedURL(std::string url)

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 duplicates maskedURI in src/IO/ReadWriteBufferFromHTTP.cpp, which #120407 added for the same reason.

a copy-returning overload of maskURICredentials in src/Common/maskURIPassword.h could replace both;

@groeneai would you please create a pr to address it once the related prs have been merged.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Acknowledged. Once the related PRs have merged, I will send a PR that adds a copy-returning maskURICredentials overload to src/Common/maskURIPassword.h and replaces both maskedURI in src/IO/ReadWriteBufferFromHTTP.cpp and maskedURL here with it, and link it in this thread.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I opened #130533 for this: one copy-returning maskURICredentials(std::string_view) in src/Common/maskURIPassword.h replaces maskedURI, maskedURL and five more hand-written copy-then-mask sites. Could you review it and add can be tested so CI runs?

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 18, 2026
Merged via the queue into ClickHouse:master with commit 050ffac Oct 19, 2026
526 of 528 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 19, 2026
kolsha pushed a commit that referenced this pull request Nov 18, 2026
The new tests of #129850 call it to check the refusal, but it came to
master's test file with #126184, which is not on 26.10, so those cases
fail with `NameError`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kolsha added a commit that referenced this pull request Nov 18, 2026
…_url`

Without credentials in `Location`, `test_url_redirect_userinfo_is_not_sent_with_forbidden_authorization` passes vacuously. The fixture is ported from #126184 for that test. URL masking in the index page errors (#126184) is absent on 26.10 and is not part of this backport.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
kolsha added a commit that referenced this pull request Nov 18, 2026
Carry the conflict resolution of the cherry-pick as a tree onto the rebuilt `backport/26.9/129850` branch: the release branch was rewritten, so the earlier resolution cannot be pushed as is without bringing the old history back.

Deviations from the original change, all approved:
- `HTTPDictionarySource` keeps the `created_from_ddl` field of `Configuration` from #101768, which the original change relies on.
- The `Elasticsearch` hunk and the `test_storage_elasticsearch` changes are dropped, the engine does not exist on this branch.
- `checkAndNormalizeHeaders` is called instead of `checkHeaders`.
- `test_storage_url` gets the helper `server_part_of_error` for the error assertions.
- The redirect fixture of `index_pages_server.py` puts userinfo into `Location` as on master (from #126184), so that `test_url_redirect_userinfo_is_not_sent_with_forbidden_authorization` exercises the redirect with credentials. The masking of the URL in the error of `rejectOriginChangingRedirect` from #126184 is not ported: it is not part of this change, and the branch keeps its existing behavior.
kolsha added a commit that referenced this pull request Nov 18, 2026
Carry the conflict resolution of the cherry-pick as a tree onto the rebuilt `backport/26.8/129850` branch: the release branch was rewritten, so the earlier resolution cannot be pushed as is without bringing the old history back.

Deviations from the original change, all approved:
- `HTTPDictionarySource` keeps the `created_from_ddl` field of `Configuration` from #101768, which the original change relies on.
- The `Elasticsearch` hunk and the `test_storage_elasticsearch` changes are dropped, the engine does not exist on this branch.
- `checkAndNormalizeHeaders` is called instead of `checkHeaders`.
- `test_storage_url` gets the helper `server_part_of_error` for the error assertions.
- The tests use the setting name `allow_experimental_url_wildcard_from_index_pages`, as it is named on this branch.
- The redirect fixture of `index_pages_server.py` puts userinfo into `Location` as on master (from #126184), so that `test_url_redirect_userinfo_is_not_sent_with_forbidden_authorization` exercises the redirect with credentials. The masking of the URL in the error of `rejectOriginChangingRedirect` from #126184 is not ported: it is not part of this change, and the branch keeps its existing behavior.
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 18, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 18, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 18, 2026
Backport #126184 to 26.10: Mask URL credentials in the index page listing errors of a URL wildcard
clickhouse-gh Bot added a commit that referenced this pull request Nov 18, 2026
Backport #126184 to 26.9: Mask URL credentials in the index page listing errors of a URL wildcard
clickhouse-gh Bot added a commit that referenced this pull request Nov 18, 2026
Backport #126184 to 26.8: Mask URL credentials in the index page listing errors of a URL wildcard
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-object-storage-disks Object-storage disk layer: DiskObjectStorage, metadata storage adapters, transaction support for ... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-improvement Pull request with some product improvements 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.8-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

URL userinfo password echoed verbatim in HTTP error messages and debug logs

5 participants