fix(sec): sql injection in validate jsonpath query (CVE-2026-8462)#4383
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR refactors how ClickHouse JSON path validation queries are generated. The implementation switches from manually constructed SQL with escaped strings to a parameterized query approach using ChangesJSON Path Query Parameterization
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
openmeter/streaming/clickhouse/utils_query_test.go (1)
9-17: ⚡ Quick winAdd an injection-payload regression test for this CVE fix.
Nice baseline test. I’d also add one malicious JSONPath case to ensure payload content is always kept in args and never interpolated into SQL text.
Suggested test
func Test_ValidateJsonPathQuery(t *testing.T) { query, args := validateJsonPathQuery{ jsonPath: "$.foo.bar", }.toSQL() assert.Equal(t, `SELECT JSON_VALUE('{}', ?)`, query) assert.Equal(t, []interface{}{ "$.foo.bar"}, args) } + +func Test_ValidateJsonPathQuery_InjectionPayloadIsParameterized(t *testing.T) { + payload := "$.foo.bar') OR 1=1 --" + + query, args := validateJsonPathQuery{ + jsonPath: payload, + }.toSQL() + + assert.Equal(t, `SELECT JSON_VALUE('{}', ?)`, query) + assert.Equal(t, []interface{}{payload}, args) +}As per coding guidelines: "
**/*_test.go: Make sure the tests are comprehensive and cover the changes. Keep a strong focus on unit tests and in-code integration tests."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@openmeter/streaming/clickhouse/utils_query_test.go` around lines 9 - 17, Extend Test_ValidateJsonPathQuery by adding a regression case that passes a malicious JSONPath (e.g. containing quotes, SQL keywords, semicolon or a payload like "$.foo'); DROP TABLE users; --") into validateJsonPathQuery{jsonPath: "..."} and assert the returned SQL string still uses a parameter placeholder (e.g. contains "JSON_VALUE('{}', ?)") and that the args slice contains the exact malicious JSONPath as a single element (no interpolation into the query); update the test around the existing Test_ValidateJsonPathQuery function and the toSQL invocation to verify query stays parameterized and args preserves the payload.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@openmeter/streaming/clickhouse/utils_query_test.go`:
- Around line 9-17: Extend Test_ValidateJsonPathQuery by adding a regression
case that passes a malicious JSONPath (e.g. containing quotes, SQL keywords,
semicolon or a payload like "$.foo'); DROP TABLE users; --") into
validateJsonPathQuery{jsonPath: "..."} and assert the returned SQL string still
uses a parameter placeholder (e.g. contains "JSON_VALUE('{}', ?)") and that the
args slice contains the exact malicious JSONPath as a single element (no
interpolation into the query); update the test around the existing
Test_ValidateJsonPathQuery function and the toSQL invocation to verify query
stays parameterized and args preserves the payload.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c55294b4-6ff1-4603-ae28-34e12870899b
📒 Files selected for processing (2)
openmeter/streaming/clickhouse/utils_query.goopenmeter/streaming/clickhouse/utils_query_test.go
be944a5
7e4e6e8 to
be944a5
Compare
SQL Injection in ClickHouse-backed Meter Definitions (CVE-2026-8462)
An attacker may be able to perform SQL injection through meter configuration fields in
POST /api/v1/meterswhen OpenMeter is configured to use ClickHouse as the event database.The issue affects user-controlled JSONPath values which may be incorporated into ClickHouse queries without sufficient parameterization. Under vulnerable configurations, an attacker with access to the meter creation endpoint could craft a meter definition that alters the intended SQL query.
In multi-tenant ClickHouse deployments where tenant event data is stored in shared tables without database-enforced row-level isolation, successful exploitation could allow an attacker to access metering event data belonging to other tenants. Depending on the ClickHouse user's database permissions, additional impact such as data modification or denial of service through expensive queries may also be possible.
Am I affected?
You are affected if all of the following hold:
POST /api/v1/metersto untrusted users or without authentication.Resolution
Please upgrade to version v1.0.0-beta.228 or newer.
CVSS
CVSS v4.0: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:P
Severity: High
Score: 8.9
Details
Please see the following security advisory: GHSA-wc3v-3457-c8cm
Summary by CodeRabbit
Tests
Refactor