Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .server-changes/fix-realtime-tags-sql-escape.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
area: webapp
type: fix
---

Hardened realtime run filtering so special characters in tags cannot interfere with the query.
5 changes: 4 additions & 1 deletion apps/webapp/app/services/realtimeClient.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ export class RealtimeClient {
const whereClauses: string[] = [`"runtimeEnvironmentId"='${environment.id}'`];

if (params.tags) {
whereClauses.push(`"runTags" @> ARRAY[${params.tags.map((t) => `'${t}'`).join(",")}]`);
// Escape single quotes so user-provided tags cannot break out of the
// ARRAY literal (Electric WHERE clause is string-interpolated).
const escapedTags = params.tags.map((t) => `'${t.replace(/'/g, "''")}'`).join(",");
whereClauses.push(`"runTags" @> ARRAY[${escapedTags}]`);
}

const createdAtFilter = await this.#calculateCreatedAtFilter(url, params.createdAt);
Expand Down