fix: add column whitelist to queryTopN to prevent SQL injection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 10:08:28 +01:00
parent adfe372d13
commit 058da51f86

View File

@@ -292,6 +292,13 @@ func (s *SQLiteStore) GetTopIPs(ctx context.Context, limit int) ([]TopEntry, err
}
func (s *SQLiteStore) queryTopN(ctx context.Context, column string, limit int) ([]TopEntry, error) {
switch column {
case "username", "password", "ip":
// valid columns
default:
return nil, fmt.Errorf("invalid column: %s", column)
}
query := fmt.Sprintf(`
SELECT %s, SUM(count) AS total
FROM login_attempts