Skip to content

Commit a0da7e3

Browse files
fix(postgres): prevent SQL injection via backticks in database names
Add validation to reject database names containing backtick characters which could be used for SQL injection attacks in PostgreSQL connections. Co-authored-by: Anguel <modelorona@users.noreply.github.com>
1 parent 5542fa1 commit a0da7e3

File tree

1 file changed

+5
-0
lines changed
  • core/src/plugins/postgres

1 file changed

+5
-0
lines changed

core/src/plugins/postgres/db.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ func validateDatabase(database string) error {
5555
return fmt.Errorf("invalid database name: contains path traversal pattern")
5656
}
5757

58+
// Check for backticks that could enable SQL injection
59+
if strings.Contains(database, "`") {
60+
return fmt.Errorf("invalid database name: contains backtick character")
61+
}
62+
5863
// Check for other URL-encoded characters that could be problematic
5964
problematicEncoded := []string{"%00", "%20", "%22", "%27", "%3B", "%3C", "%3E"}
6065
for _, encoded := range problematicEncoded {

0 commit comments

Comments
 (0)