Skip to content

Commit 8754167

Browse files
fix: Correct PostgreSQL connection parameter escaping order
- Fix escapeConnectionParam to escape single quotes before backslashes - Prevents security vulnerability identified by jazzberry-ai - Ensures proper PostgreSQL libpq connection string escaping Co-authored-by: Anguel <modelorona@users.noreply.github.com>
1 parent e9fbf64 commit 8754167

File tree

1 file changed

+2
-1
lines changed
  • core/src/plugins/postgres

1 file changed

+2
-1
lines changed

core/src/plugins/postgres/db.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ func escapeConnectionParam(x string) string {
2929
// PostgreSQL libpq connection string escaping rules:
3030
// 1. Single quotes must be doubled: ' -> ''
3131
// 2. Backslashes must be doubled: \ -> \\
32-
x = strings.ReplaceAll(x, "\\", "\\\\")
32+
// IMPORTANT: Escape single quotes first, then backslashes to avoid double-escaping
3333
x = strings.ReplaceAll(x, "'", "''")
34+
x = strings.ReplaceAll(x, "\\", "\\\\")
3435
return x
3536
}
3637

0 commit comments

Comments
 (0)