Repository navigation
Do not let server-side AST fuzzer queries read stream-like tables directly - #122461
PedroTadim merged 6 commits into
Conversation
…ectly A direct SELECT from a stream-like table (FileLog, Kafka, RabbitMQ, NATS, S3Queue/AzureQueue) consumes its messages. The fuzz context inherited stream_like_engine_allow_direct_select from the seed query, which is 1 in the CI default profile (tests/config/users.d/filelog.xml) and in any seed that sets it, while the fuzzer rewrites table references into cross-database merge(REGEXP(...)), remote() or corpus names. A fuzzed copy of an unrelated seed could therefore read and commit another test's FileLog rows: in the Fast test of ClickHouse#118581 a fuzzed `SELECT n FROM merge(REGEXP('.*[0-9].*'), '^')` of 04104_ast_fuzzer_preserves_caller_transaction polled the 103 pending records of 02023_storage_filelog 0.4 s before that test's SELECT. Pin the setting to 0 on the fuzz context, and strip it from every query-level SETTINGS carrier of the fuzzed AST like the resource caps. Strip `profile` as well: a query-level profile switch installs every setting of that profile over the pins, so `SETTINGS profile = 'default'` alone would restore the CI profile's 1 (and could equally re-open a resource cap). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e tables directly The HTTP query allows direct reads through a settings profile and through the setting itself; every fuzzed copy of it must run with stream_like_engine_allow_direct_select = 0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The style check requires a retry loop around `SYSTEM FLUSH LOGS` in a test that sends a query with curl and then reads `system.query_log` (ClickHouse#84364): the query's own entry can be written after the HTTP response. Wait for the entry of the HTTP query; its fuzzed copies, which the test checks, are logged before it. Also restrict the `system.query_log` reads to the last 10 minutes, like the other tests that read system logs. CI report of the original failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118581&sha=ab4ec36ccd27eed40f615efaa31bc4116a7088c9&name_0=PR&name_1=Fast%20test (ClickHouse#118581) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Name exactly what stripFuzzerSafetyLimitSettings removes and keep the rest of its doc comment as on master. 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; 2 findings; 1 full pass).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20260926-184400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20260926-180600 |
|
Workflow [PR], commit [e0265a7] Summary: ✅
AI ReviewSummaryThis PR hardens server-side Findings❌ Blockers
Final Verdict❌ Changes requested — the stream-like direct-select ban remains bypassable via stored views. LLVM Coverage ReportMeasured on commit e0265a7.
Changed lines: Changed C/C++ lines covered: 6/8 (75.00%) · Uncovered code |
| fuzz_context->setSetting("ast_fuzzer_runs", Field(Float64(0))); | ||
| fuzz_context->setSetting("allow_experimental_parallel_reading_from_replicas", Field(UInt64(0))); | ||
| /// A direct read of a stream-like table (Kafka, FileLog, ...) consumes its messages, which may belong to another session. | ||
| fuzz_context->setSetting("stream_like_engine_allow_direct_select", Field(false)); |
There was a problem hiding this comment.
This still has an override path through stored views. StorageView::readImpl starts from a context copied from the outer fuzz context (src/Storages/StorageView.cpp:562-565, src/Storages/StorageInMemoryMetadata.cpp:212-238), but QueryTreeBuilder::buildSelectExpression then reapplies the view body's own SETTINGS clause onto that derived context (src/Analyzer/QueryTreeBuilder.cpp:279-318). Because stream_like_engine_allow_direct_select and profile are not pinned there, a view such as CREATE VIEW v AS SELECT * FROM file_log SETTINGS stream_like_engine_allow_direct_select = 1 still reaches ReadFromStreamLikeEngine::initializePipeline with direct reads enabled (src/Processors/QueryPlan/ReadFromStreamLikeEngine.cpp:34-36).
So the new fuzz-context pin is not yet authoritative: a fuzzed SELECT ... FROM v can still consume another test's queue rows through the view. This needs either a non-overridable constraint on the fuzz context, or equivalent stripping when planning stored view bodies, not just when formatting the outer fuzzed AST.
CI finish ledger - 975c209Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All 169 check runs completed (127 pass, 41 not selected, 1 red), Session id: cron:our-pr-ci-monitor:20260927-003314 |
|
cc @qoega |
| @@ -0,0 +1,48 @@ | |||
| #!/usr/bin/env bash | |||
| # Queries run by the server-side AST fuzzer (`ast_fuzzer_runs`) must not read a stream-like table directly, even when | |||
There was a problem hiding this comment.
Removed in e0265a7, and the description no longer mentions the test.
Requested in review: ClickHouse#122461 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #119625
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not required: CI-only change.
Description
02023_storage_filelogfailed in theFast testof #118581 (job, report): its thirdSELECTreturned 0 rows instead of 103. Per the server log, 0.4 s earlier a server-side AST fuzzer copy of a query of the concurrent04104_ast_fuzzer_preserves_caller_transaction,SELECT n FROM merge(REGEXP('.*[0-9].*'), '^') ORDER BY n ASC SETTINGS ast_fuzzer_runs = 3, readtest_j5u0x8q6q7b3.file_logand polled its 103 pending records.A direct read of a stream-like table consumes its messages. The fuzz context inherited
stream_like_engine_allow_direct_selectfrom the original query, where it is 1 in the CI default profile (tests/config/users.d/filelog.xml) or when the query sets it, and the fuzzer rewrites table references into cross-databasemerge(),remote()or corpus names.The fuzz context now pins the setting to 0, and strips it and
profilefrom every query-levelSETTINGSclause of the fuzzed query, like the resource caps (#108212): a profile switch would re-install the CI profile's 1 over the pin, and can lift a resource cap. This single site covers FileLog, Kafka, RabbitMQ, NATS and S3Queue/AzureQueue on both the native and the HTTP fuzzer path, since all of them check a context derived from the fuzz context;merge()child reads andremote()loopback shards inherit it. Fuzzed variants of a direct stream-like read now fail withQUERY_NOT_ALLOWED; the original query still reads.In a cross-database replay of the #118581 shape, a fuzzed
merge()consumed all 100 rows of another database's FileLog before the change; after it, all 12 such reads were refused. No regression test is added: the test was removed in review.Workflow [PR]
Sync PR [sync-upstream/pr/122461]
Version info
26.10.1.1858-master(included in26.10and later)