Skip to content

Commit 5542fa1

Browse files
fix(postgres): prevent Windows path traversal attacks in database names
Add validation for Windows-specific path traversal patterns (`./` and `.\`) to prevent directory traversal attacks on Windows systems. This addresses the security vulnerability where database names could contain current directory references to access unauthorized paths. Co-authored-by: Anguel <modelorona@users.noreply.github.com>
1 parent 6a44779 commit 5542fa1

File tree

1 file changed

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

1 file changed

+3
-2
lines changed

core/src/plugins/postgres/db.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ func validateDatabase(database string) error {
4949
return fmt.Errorf("invalid database name: contains URL-encoded forward slash")
5050
}
5151

52-
// Check for literal path traversal patterns
53-
if strings.Contains(database, "../") || strings.Contains(database, "..\\") {
52+
// Check for literal path traversal patterns (both Unix and Windows)
53+
if strings.Contains(database, "../") || strings.Contains(database, "..\\") ||
54+
strings.Contains(database, "./") || strings.Contains(database, ".\\") {
5455
return fmt.Errorf("invalid database name: contains path traversal pattern")
5556
}
5657

0 commit comments

Comments
 (0)