Repository navigation
Mask URL credentials in the index page listing errors of a URL wildcard - #126184
Conversation
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]>
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).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20261016-024700 |
|
Workflow [PR], commit [85ee3ab] Summary: ✅
AI ReviewSummaryPR #126184, reviewed at Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20261016-021100 |
|
cc @alexey-milovidov @Michicosun, could you review this and add |
Build profile diff (arm_release)Comparing Binary sizes
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 Object file sizes
|
| 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.
| } | ||
|
|
||
| /// Listing URLs keep the source URL's userinfo for authentication, so only a masked copy may be formatted. | ||
| std::string maskedURL(std::string url) |
There was a problem hiding this comment.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
050ffac
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]>
…_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]>
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.
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.
Backport #126184 to 26.10: Mask URL credentials in the index page listing errors of a URL wildcard
Backport #126184 to 26.9: Mask URL credentials in the index page listing errors of a URL wildcard
Backport #126184 to 26.8: Mask URL credentials in the index page listing errors of a URL wildcard
Closes: #120425
Related: #120407
Related: #123226
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Credentials in the URL of a
urlwildcard expanded from HTTP index pages (allow_url_wildcard_from_index_pages), or of aweb_indexdisk, are now masked in the errors about an index page redirected to a different origin and about an index page overmax_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:The query text is logged masked, so the password reached the client, the server log and
system.query_log.exceptiononly 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. Aweb_indexdisk runs the same code.This is the follow-up I offered on #120425 for its three remaining sites:
RemoteHostFilter::checkURL: fixed by Mask URL credentials in the Avro schema registry trace log and in URL rejection errors #123226.StorageURLWithFailover"Adding URL option" debug log: unreachable, the class is no longer constructed anywhere.Tests:
test_storage_urltest_url_wildcard_rejects_cross_origin_index_redirect(the redirect target now carries its own userinfo) andtest_url_wildcard_oversize_index_page(the URL now has userinfo) check that the server's message has no credentials and rendershttp://[HIDDEN]@.... Both fail without thesrc/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
26.11.1.182-master(included in26.11and later)26.10.7.5,26.9.33.8,26.8.41.9