Hoch

PostgreSQL JDBC Driver SQL Injection in ResultSet.refreshRow() with malicious column names

  • Veröffentlicht: 06.08.2022
  • Aktualisiert: 11.10.2026 13:19

Impact

What kind of vulnerability is it? Who is impacted?

The PGJDBC implementation of the java.sql.ResultRow.refreshRow() method is not performing escaping of column names so a malicious column name that contains a statement terminator, e.g. ;, could lead to SQL injection. This could lead to executing additional SQL commands as the application's JDBC user.

User applications that do not invoke the ResultSet.refreshRow() method are not impacted.

User application that do invoke that method are impacted if the underlying database that they are querying via their JDBC application may be under the control of an attacker. The attack requires the attacker to trick the user into executing SQL against a table name who's column names would contain the malicious SQL and subsequently invoke the refreshRow() method on the ResultSet.

For example:

sql
CREATE TABLE refresh_row_example (
  id     int PRIMARY KEY,
  "1 FROM refresh_row_example; SELECT pg_sleep(10); SELECT * " int
);

This example has a table with two columns. The name of the second column is crafted to contain a statement terminator followed by additional SQL. Invoking the ResultSet.refreshRow() on a ResultSet that queried this table, e.g. SELECT * FROM refresh_row, would cause the additional SQL commands such as the SELECT pg_sleep(10) invocation to be executed.

As the multi statement command would contain multiple results, it would not be possible for the attacker to get data directly out of this approach as the ResultSet.refreshRow() method would throw an exception. However, the attacker could execute any arbitrary SQL including inserting the data into another table that could then be read or any other DML / DDL statement.

Note that the application's JDBC user and the schema owner need not be the same. A JDBC application that executes as a privileged user querying database schemas owned by potentially malicious less-privileged users would be vulnerable. In that situation it may be possible for the malicious user to craft a schema that causes the application to execute commands as the privileged user.

Patches

Has the problem been patched? What versions should users upgrade to?

Yes, versions 42.2.26, 42.3.7, and 42.4.1 have been released with a fix.

Workarounds

Is there a way for users to fix or remediate the vulnerability without upgrading?

Check that you are not using the ResultSet.refreshRow() method.

If you are, ensure that the code that executes that method does not connect to a database that is controlled by an unauthenticated or malicious user. If your application only connects to its own database with a fixed schema with no DDL permissions, then you will not be affected by this vulnerability as it requires a maliciously crafted schema.

Betroffene Software

Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.

PlattformPaketAnfällige VersionenBehoben in
Java / Kotlin (Maven) org.postgresql:postgresql < 42.2.26, >= 42.4.0, < 42.4.1, >= 42.3.0, < 42.3.7 42.2.26, 42.4.1, 42.3.7

Verweise

CVSS-Wert 7.1/10
CVSS-Vektor
CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H
Schwäche (CWE)
CWE-89
Plattform
Java / Kotlin (Maven)
Paket
org.postgresql:postgresql
Veröffentlicht
06.08.2022
Aktualisiert
11.10.2026 13:19

Quellen und Lizenzen

OSV / GitHub Advisory Database - GHSA-r38f-c4h4-hqq2 - CC BY 4.0

Schwachstellenhistorie: org.postgresql:postgresql

Alle veröffentlichten Schwachstellen dieses Pakets (Java / Kotlin (Maven)), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.

Alle (10) im Archiv
Einträge insgesamt
10
Erste → letzte
02.2022 07.2026
Ohne Fix
0
In Angriffen ausgenutzt
0

Verteilung nach Schweregrad

  • Kritisch 1
  • Hoch 7
  • Mittel 2

Veröffentlichungen pro Jahr

  1. 2022: 6
  2. 2023: 0
  3. 2024: 1
  4. 2025: 1
  5. 2026: 2
Schweregrad:
  1. Hoch · 7.5 CVE-2026-42198 >= 42.2.0, < 42.7.11 42.7.11
  2. Kritisch · 10.0 CVE-2024-1597 < 42.2.28, >= 42.3.0, < 42.3.9, >= 42.4.0, < 42.4.4, >= 42.5.0, < 42.5.5, >= 42.6.0, < 42.6.1, >= 42.7.0, < 42.7.2 42.2.28, 42.3.9, 42.4.4, 42.5.5, 42.6.1, 42.7.2
  3. PostgreSQL JDBC Driver SQL Injection in ResultSet.refreshRow() with malicious column names dieser Eintrag
    Hoch · 7.1 CVE-2022-31197 < 42.2.26, >= 42.4.0, < 42.4.1, >= 42.3.0, < 42.3.7 42.2.26, 42.4.1, 42.3.7
  4. Hoch · 7.7 CVE-2020-13692 >= 9.4.1212.jre6, < 42.2.13 42.2.13
  5. Hoch · 7.0 CVE-2022-21724 >= 9.4.1208, < 42.2.25, >= 42.3.0, < 42.3.2 42.2.25, 42.3.2

Erkennen Sie Schwachstellen in Ihrer Anwendung

Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.

Anwendung verbinden
DockRay Newsletter

Anwendungssicherheit in Ihrem Postfach

Wichtige Schwachstellen, konkrete Empfehlungen und praktische Tipps für Ihre Anwendungen. Wählen Sie Ihre Technologien und verfolgen Sie, was für Ihr Projekt relevant ist.

  • Eine tägliche Zusammenfassung neuer Schwachstellen, auch kritischer.
  • Benachrichtigungen über wichtige Updates.
  • Praktische Tipps zur Sicherheit und Überwachung von Anwendungen.

Leer lassen, um Meldungen zu allen Technologien zu erhalten.

Kostenlos anmelden. In jeder E-Mail mit einem Klick abmelden.