Skip to content

fix(ai-conversations): Escape conversation IDs in query strings#112455

Merged
vgrozdanic merged 1 commit intomasterfrom
fix/escape-conversation-ids-in-query-strings
Apr 8, 2026
Merged

fix(ai-conversations): Escape conversation IDs in query strings#112455
vgrozdanic merged 1 commit intomasterfrom
fix/escape-conversation-ids-in-query-strings

Conversation

@vgrozdanic
Copy link
Copy Markdown
Member

Conversation IDs were interpolated directly into search query strings
without escaping in both the AI conversations list and details endpoints.
Values containing special characters like parentheses (e.g. UUID(xxx))
would be misinterpreted by the search parser, breaking queries entirely.

More critically, this was a stored injection vector: conversation IDs
returned from Snuba results were used unescaped in subsequent queries
(aggregations, enrichment, first/last IO). A malicious conversation ID
value like foo OR user.email:* stored in ClickHouse could modify the
query logic and potentially leak data across conversations.

Uses the existing build_escaped_term_filter utility from
sentry.search.eap.occurrences.query_utils which properly double-quotes
values and escapes backslashes and quotes within them.

Conversation IDs were interpolated directly into search query strings
without escaping. Values containing special characters like parentheses
(e.g. `UUID(xxx)`) would be misinterpreted by the search parser,
breaking queries. This also prevented stored injection where a
malicious conversation ID from Snuba results could modify subsequent
query logic.

Use `build_escaped_term_filter` to properly quote and escape values.

Co-Authored-By: Claude <[email protected]>
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 8, 2026
@vgrozdanic vgrozdanic marked this pull request as ready for review April 8, 2026 09:01
@vgrozdanic vgrozdanic requested a review from a team as a code owner April 8, 2026 09:01
@vgrozdanic vgrozdanic enabled auto-merge (squash) April 8, 2026 09:10
@vgrozdanic vgrozdanic merged commit 36e9db2 into master Apr 8, 2026
57 checks passed
@vgrozdanic vgrozdanic deleted the fix/escape-conversation-ids-in-query-strings branch April 8, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants