// For flags

CVE-2022-31197

SQL Injection in ResultSet.refreshRow() with malicious column names in pgjdbc

Severity Score

8.0
*CVSS v3.1

Exploit Likelihood

*EPSS

Affected Versions

*CPE

Public Exploits

1
*Multiple Sources

Exploited in Wild

-
*KEV

Decision

-
*SSVC
Descriptions

PostgreSQL JDBC Driver (PgJDBC for short) allows Java programs to connect to a PostgreSQL database using standard, database independent Java code. 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. 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. Patched versions will be released as `42.2.26` and `42.4.1`. Users are advised to upgrade. There are no known workarounds for this issue.

El controlador JDBC de PostgreSQL (PgJDBC para abreviar) permite a los programas Java conectarse a una base de datos PostgreSQL usando código Java estándar e independiente de la base de datos. La implementación de PGJDBC del método "java.sql.ResultRow.refreshRow()" no realiza el escape de los nombres de las columnas, por lo que un nombre de columna malicioso que contenga un terminador de sentencia, por ejemplo ";", podría conllevar una inyección SQL. Esto podría conllevar a una ejecución de comandos SQL adicionales como usuario JDBC de la aplicación. Las aplicaciones de usuario que no invocan el método "ResultSet.refreshRow()" no están afectadas. Las aplicaciones de usuario que sí invocan ese método están afectadas si la base de datos subyacente que están consultando por medio de su aplicación JDBC puede estar bajo el control de un atacante. El ataque requiere que el atacante engañe al usuario para que ejecute SQL contra un nombre de tabla cuyos nombres de columna contengan el SQL malicioso y posteriormente invoque el método "refreshRow()" en el ResultSet. Tenga en cuenta que el usuario JDBC de la aplicación y el propietario del esquema no tienen por qué ser el mismo. Una aplicación JDBC que es ejecutado como un usuario privilegiado consultando esquemas de base de datos que pertenecen a usuarios menos privilegiados potencialmente maliciosos sería vulnerable. En esta situación, el usuario malicioso podría diseñar un esquema que causara que la aplicación ejecutara comandos como el usuario privilegiado. Las versiones parcheadas serán publicadas como "42.2.26" y "42.4.1". Es recomendado a usuarios actualizar. No se presentan mitigaciones conocidas para este problema

A flaw was found in PostgresQL. This flaw allows an attacker to benefit from a miss escaping character and leads to a SQL injection attack due to Java.sql.ResultRow.refreshRow() implementation from PGSQL.

*Credits: N/A
CVSS Scores
Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High
Attack Vector
Network
Attack Complexity
High
Privileges Required
Low
User Interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High
* Common Vulnerability Scoring System
SSVC
  • Decision:-
Exploitation
-
Automatable
-
Tech. Impact
-
* Organization's Worst-case Scenario
Timeline
  • 2022-05-18 CVE Reserved
  • 2022-08-03 CVE Published
  • 2024-08-03 CVE Updated
  • 2024-08-03 First Exploit
  • 2024-10-25 EPSS Updated
  • ---------- Exploited in Wild
  • ---------- KEV Due Date
CWE
  • CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
CAPEC
Affected Vendors, Products, and Versions
Vendor Product Version Other Status
Vendor Product Version Other Status <-- --> Vendor Product Version Other Status
Postgresql
Search vendor "Postgresql"
Postgresql Jdbc Driver
Search vendor "Postgresql" for product "Postgresql Jdbc Driver"
< 42.2.26
Search vendor "Postgresql" for product "Postgresql Jdbc Driver" and version " < 42.2.26"
-
Affected
Postgresql
Search vendor "Postgresql"
Postgresql Jdbc Driver
Search vendor "Postgresql" for product "Postgresql Jdbc Driver"
>= 42.3.0 < 42.3.7
Search vendor "Postgresql" for product "Postgresql Jdbc Driver" and version " >= 42.3.0 < 42.3.7"
-
Affected
Postgresql
Search vendor "Postgresql"
Postgresql Jdbc Driver
Search vendor "Postgresql" for product "Postgresql Jdbc Driver"
42.4.0
Search vendor "Postgresql" for product "Postgresql Jdbc Driver" and version "42.4.0"
-
Affected
Postgresql
Search vendor "Postgresql"
Postgresql Jdbc Driver
Search vendor "Postgresql" for product "Postgresql Jdbc Driver"
42.4.0
Search vendor "Postgresql" for product "Postgresql Jdbc Driver" and version "42.4.0"
rc1
Affected
Postgresql
Search vendor "Postgresql"
Postgresql Jdbc Driver
Search vendor "Postgresql" for product "Postgresql Jdbc Driver"
42.4.1
Search vendor "Postgresql" for product "Postgresql Jdbc Driver" and version "42.4.1"
rc1
Affected
Debian
Search vendor "Debian"
Debian Linux
Search vendor "Debian" for product "Debian Linux"
10.0
Search vendor "Debian" for product "Debian Linux" and version "10.0"
-
Affected
Fedoraproject
Search vendor "Fedoraproject"
Fedora
Search vendor "Fedoraproject" for product "Fedora"
35
Search vendor "Fedoraproject" for product "Fedora" and version "35"
-
Affected
Fedoraproject
Search vendor "Fedoraproject"
Fedora
Search vendor "Fedoraproject" for product "Fedora"
36
Search vendor "Fedoraproject" for product "Fedora" and version "36"
-
Affected