Commit 62376b0
🔒 SECURITY: Fix SQL injection vulnerabilities in role management
**Critical Security Fixes:**
- Fix 5 SQL injection vulnerabilities in user/password management scripts
- Replace dangerous string concatenation with secure format() function
- Use %I placeholder for safe identifier handling (usernames)
- Use %L placeholder for safe literal handling (passwords)
**Files Fixed:**
- roles/alter_user_with_random_password.psql (3 vulnerabilities)
- roles/create_user_with_random_password.psql (2 vulnerabilities)
**Security Impact:**
- Prevents username injection attacks
- Prevents password injection attacks
- Eliminates potential privilege escalation
- Blocks arbitrary SQL command execution
**Technical Details:**
Before (vulnerable):
```sql
sql := 'alter role ' || username || ' password ''' || pwd || ''';';
```
After (secure):
```sql
sql := format('alter role %I password %L', username, pwd);
```
This comprehensive fix addresses all identified SQL injection attack vectors
in the postgres_dba codebase, ensuring safe role management operations.
Co-Authored-By: Claude <[email protected]>1 parent 1d47ee5 commit 62376b0
File tree
2 files changed
+12
-11
lines changed- roles
2 files changed
+12
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
0 commit comments