Headline
CVE-2023-30625: fix: always use a sql safe table name in failed events manager (#2664) · rudderlabs/rudder-server@0d061ff
rudder-server is part of RudderStack, an open source Customer Data Platform (CDP). Versions of rudder-server prior to 1.3.0-rc.1 are vulnerable to SQL injection. This issue may lead to Remote Code Execution (RCE) due to the rudder
role in PostgresSQL having superuser permissions by default. Version 1.3.0-rc.1 contains patches for this issue.
Expand Up
@@ -56,7 +56,7 @@ func (*FailedEventsManagerT) SaveFailedRecordIDs(taskRunIDFailedEventsMap map[st
}
for taskRunID, failedEvents := range taskRunIDFailedEventsMap {
table := `"` + strings.ReplaceAll(fmt.Sprintf(`%s_%s`, failedKeysTablePrefix, taskRunID), `"`, `""`) + `"`
table := getSqlSafeTablename(taskRunID)
sqlStatement := fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s (
destination_id TEXT NOT NULL,
record_id JSONB NOT NULL,
Expand Down Expand Up
@@ -94,7 +94,7 @@ func (fem *FailedEventsManagerT) DropFailedRecordIDs(taskRunID string) {
}
// Drop table
table := fmt.Sprintf(`%s_%s`, failedKeysTablePrefix, taskRunID)
table := getSqlSafeTablename(taskRunID)
sqlStatement := fmt.Sprintf(`DROP TABLE IF EXISTS %s`, table)
_, err := fem.dbHandle.Exec(sqlStatement)
if err != nil {
Expand All
@@ -111,7 +111,7 @@ func (fem *FailedEventsManagerT) FetchFailedRecordIDs(taskRunID string) []*Faile
var rows *sql.Rows
var err error
table := `"` + strings.ReplaceAll(fmt.Sprintf(`%s_%s`, failedKeysTablePrefix, taskRunID), `"`, `""`) + `"`
table := getSqlSafeTablename(taskRunID)
sqlStatement := fmt.Sprintf(`SELECT %[1]s.destination_id, %[1]s.record_id
FROM %[1]s `, table)
rows, err = fem.dbHandle.Query(sqlStatement)
Expand Down Expand Up
@@ -188,3 +188,7 @@ func CleanFailedRecordsTableProcess(ctx context.Context) {
func (fem *FailedEventsManagerT) GetDBHandle() *sql.DB {
return fem.dbHandle
}
func getSqlSafeTablename(taskRunID string) string {
return `"` + strings.ReplaceAll(fmt.Sprintf(`%s_%s`, failedKeysTablePrefix, taskRunID), `"`, `""`) + `"`
}
Related news
rudder-server is part of RudderStack, an open source Customer Data Platform (CDP). Versions of rudder-server prior to 1.3.0-rc.1 are vulnerable to SQL injection. This issue may lead to Remote Code Execution (RCE) due to the `rudder` role in PostgresSQL having superuser permissions by default. Version 1.3.0-rc.1 contains patches for this issue.
This Metasploit module exploits a SQL injection vulnerability in RudderStack's rudder-server, an open source Customer Data Platform (CDP). The vulnerability exists in versions of rudder-server prior to 1.3.0-rc.1. By exploiting this flaw, an attacker can execute arbitrary SQL commands, which may lead to remote code execution due to the rudder role in PostgreSQL having superuser permissions by default.