Fix ClickHouse KILL QUERY parameterization - #7138
Conversation
🦋 Changeset detectedLatest commit: 0fb7694 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Important
The PR title, body, and changeset all describe a security fix, but no source code was changed. The vulnerability remains in packages/sql/clickhouse/src/ClickhouseClient.ts at lines 256 and 378.
Reviewed changes
- Added
.changeset/blue-pianos-rest.mdclaiming the KILL QUERY SQL injection is fixed. - Added a placeholder test in
packages/sql/clickhouse/test/Client.test.tsthat documents the bug but does not assert or exercise it.
⚠️ Source-code fix is missing
The PR title, body, and changeset all describe a fix for the KILL QUERY SQL injection, but the diff does not modify packages/sql/clickhouse/src/ClickhouseClient.ts. The vulnerable string interpolation remains at lines 256 and 378. Either complete the implementation before merging or reframe this as an audit/reproduction PR and remove the changeset.
⚠️ Added test does not verify the behavior
The new test executes Effect.void and will pass regardless of whether the bug exists. It needs to actually assert that command is called with query_params (for example, by mocking the ClickHouse client) or be skipped with a clear message until the fix lands.
@v0 or keep the SHA fresh with Dependabot | Fix it ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
017c582 to
f0fe5ec
Compare
There was a problem hiding this comment.
Important
The new regression test is now a real assertion, but it fails because the source code still interpolates the query ID. Either complete the fix in ClickhouseClient.ts or skip the test if this PR is audit-only.
Reviewed changes
- Replaced the placeholder test with an executable regression test that mocks
command, interrupts a fiber scoped towithQueryId, and assertsKILL QUERY WHERE query_id = {queryId:String}plusquery_params: { queryId }. - Removed the misleading changeset that claimed the SQL injection was already fixed.
⚠️ The new regression test fails against current source code
packages/sql/clickhouse/src/ClickhouseClient.ts lines 256 and 378 still build the kill command via \KILL QUERY WHERE query_id = '${queryId}'``. Running the new test produces:
[ { query: "KILL QUERY WHERE query_id = 'id' OR 1 = 1 --'" } ]
instead of the expected parameterized form. The PR body now says this is only a regression test, but the title still says "Fix"; if it lands as-is, CI will fail on the new assertion.
⚠️ Title does not match the body
The PR title claims a fix, while the body states no implementation fix is included. Update the title to match the audit/reproduction framing if the source-code change will not be added here.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Implemented the KILL QUERY parameterization fix in
ClickhouseClient.ts— replaced string interpolation withquery_params: { queryId }at both the query/command cancel handler and the insert cancel handler. - Added a regression test for insert cancellation, mirroring the existing query-cancellation test.
- Re-added the
.changeset/calm-hounds-smile.mdpatch changeset.
This incremental change addresses all prior feedback: the source-code fix now lands in the same PR, the regression tests pass against it (verified locally: 4 tests pass, and they use exact deepStrictEqual assertions that would fail without the fix), and the title now matches the body. I verified via ClickHouse docs that {queryId:String} resolves to a properly escaped literal value and that query_params is the same mechanism the client already uses for normal commands, so the fix is both correct and safe.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Summary
KILL QUERYcommands.@effect/sql-clickhouse.Validation
Closes EFF-572