You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Security: SQL injection risk in get_filter_string / list_condition_expr (alerts_utils.rs) #1688
The get_filter_string function in src/alerts/alerts_utils.rs does not properly escape user-provided values when building SQL filter strings. Specifically, in list_condition_expr, the inner_value parameter is directly interpolated into SQL expressions (e.g., ARRAY[{inner_value}]) without escaping or sanitization, allowing crafted input to break out of the ARRAY context and inject arbitrary SQL.
Steps to Reproduce / Exploit
A user-supplied condition value such as 1] OR 1=1; -- would be embedded verbatim, producing:
ARRAY[1] OR1=1; --]
which alters the query logic.
The resulting filter string is then directly concatenated into WHERE clauses (e.g., in the log context query builder added in PR #1687), rather than being passed as a parameterized binding.
#1304 - fix: sql query to fetch distinct values in datasets API [merged] #1355 - null checks [merged] #1357 - fix: filter with LIKE operators [merged] #1379 - fix: handle proper SQL variable type for operators [merged] #1532 - fix: counts api [merged]
📝 Issue Planner
Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.
Create Plan
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your .coderabbit.yaml:
issue_enrichment:
auto_enrich:
enabled: false
💬 Have feedback or questions? Drop into our discord!
Hi @nikhilsinhaparseable ! I had a look at this and the fix is pretty straightforward - the vulnerability is isolated to list_condition_expr in alerts_utils.rs. Interestingly, scalar_condition_expr right below it already handles escaping correctly (single-quote escaping, numeric validation, etc.), so list_condition_expr just needs the same treatment.
The plan would be to add a small sanitize_array_elements helper that splits the array value by comma, validates each element as either a numeric, boolean, or properly single-quoted string, and rejects anything that doesn't fit - like bracket characters that could break out of the ARRAY[...] context. Then just run inner_value through that before interpolating it into the format string.
It's a single-file change and I can have a PR up pretty quickly. Would it be okay if I took this one?
Activity
coderabbitai commentedon Jun 18, 2026
🔗 Related PRs
#1304 - fix: sql query to fetch distinct values in datasets API [merged]
#1355 - null checks [merged]
#1357 - fix: filter with LIKE operators [merged]
#1379 - fix: handle proper SQL variable type for operators [merged]
#1532 - fix: counts api [merged]
📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
prabhaks commentedon Jul 1, 2026
Hi @nikhilsinhaparseable ! I had a look at this and the fix is pretty straightforward - the vulnerability is isolated to list_condition_expr in alerts_utils.rs. Interestingly, scalar_condition_expr right below it already handles escaping correctly (single-quote escaping, numeric validation, etc.), so list_condition_expr just needs the same treatment.
The plan would be to add a small sanitize_array_elements helper that splits the array value by comma, validates each element as either a numeric, boolean, or properly single-quoted string, and rejects anything that doesn't fit - like bracket characters that could break out of the ARRAY[...] context. Then just run inner_value through that before interpolating it into the format string.
It's a single-file change and I can have a PR up pretty quickly. Would it be okay if I took this one?
nikhilsinhaparseable commentedon Jul 2, 2026
Hi @prabhaks thank you for explaining the issue and the plan to fix.
I would love to review the PR. Please give it a shot.
fix: sanitize array elements in list_condition_expr to prevent SQL in…
fix: sanitize array elements in list_condition_expr to prevent SQL in…