Skip to content
Fencer Vulns
high 7.1

CVE-2022-31197 json

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

published 2022-08-03 4 y ago modified 2026-09-10 1 mo ago also BIT-postgresql-jdbc-driver-2022-31197 , EUVD-2022-6614 , GHSA-r38f-c4h4-hqq2

cvss
7.1
version 3.1, CNA
cisa kev
Not listed
not in CISA's catalog
epss
2.4%
EPSS 2.4% chance of exploitation in 30 days, percentile 83%
public exploits
0
none known

Summary

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.

Patch / fix

  • maven org.postgresql:postgresql 42.2.26, 42.3.7, 42.4.1
  • bitnami postgresql-jdbc-driver 42.2.26, 42.3.7
  • postgresql postgresql_jdbc_driver 42.2.26, 42.3.7
  • libpgjava Debian 14, Debian 13, Debian 12 42.4.1-1

debian advisories DEBIAN-CVE-2022-31197

  • postgresql-jdbc RHEL 9 42.2.18-6.el9_1

red hat advisories RHSA-2023:0318

  • postgresql-jdbc Manager Server Module 4.1 42.2.10-150200.3.11.1
  • postgresql-jdbc SLE Module for Server Applications 15 SP3, openSUSE Leap 15.3, Manager Server Module 4.2 42.2.25-150300.3.8.1
  • postgresql-jdbc SLES for SAP 12 SP5, SLES for SAP 12 SP4, SLES 12 SP5 +5 more 9.4-3.6.3
  • postgresql-jdbc SLE Module for Server Applications 15 SP4, openSUSE Leap 15.4 42.2.25-150400.3.6.1

suse advisories SUSE-SU-2022:3705-1SUSE-SU-2022:3613-1SUSE-SU-2022:3541-1SUSE-SU-2022:3537-1

  • postgresql-jdbc AlmaLinux 9 42.2.18-6.el9_1

almalinux advisories ALSA-2023:0318

  • postgresql-jdbc Rocky Linux 9 42.2.18-6.el9_1

rocky linux advisories RLSA-2023:0318

  • java-postgresql-jdbc Alpine 3.24, Alpine 3.23, Alpine 3.22 +6 more 42.4.2-r0

alpine advisories ALPINE-CVE-2022-31197

Alpine secdb © Alpine Linux, from https://secdb.alpinelinux.org via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0

Vendor advisories

What the vendors themselves say about their products: affected, fixed or not affected, and what to do.

red hat product security vex CVE-2022-31197 updated cvss 8.0

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

  • Red Hat build of Apicurio Registry 2 quarkus-jdbc-postgresql-deployment
    affected: no fix available
  • Red Hat Decision Manager 7 jdbc-postgresql jdbc-postgresql
    affected: no fix planned “Out of support scope”
  • Red Hat Enterprise Linux 8 autocorr-af, autocorr-bg, autocorr-ca, autocorr-cs, autocorr-da, autocorr-de, +100 more
    affected: no fix planned “Will not fix”
  • Red Hat Process Automation 7 jdbc-postgresql jdbc-postgresql
    affected: no fix planned “Out of support scope”
  • Red Hat build of Quarkus 2.7.7
    fixed: vendor fix RHSA-2023:1006
  • Red Hat build of Quarkus 2.13.5
    fixed: vendor fix RHSA-2022:9023
  • Red Hat Enterprise Linux AppStream (v. 9) postgresql-jdbc 42.2.18-6.el9_1
    fixed: vendor fix RHSA-2023:0318
  • Red Hat Fuse 7.11.1
    fixed: vendor fix RHSA-2022:8652
show 1 more
  • Red Hat Enterprise Linux 6 postgresql-jdbc Red Hat Enterprise Linux 7 postgresql-jdbc, postgresql-jdbc-javadoc Red Hat Integration Camel K 1 quarkus-jdbc-postgresql-deployment Red Hat Integration Camel Quarkus 1 quarkus-jdbc-postgresql-deployment Red Hat Single Sign-On 7 jdbc-postgresql jdbc-postgresql
    not affected: vulnerable code not present

Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf

CISA SSVC

Exploitation
Proof of concept is public
Automatable
no
Technical impact
total
Assessed
18 mo ago

Exploit prediction

2.35% chance of exploitation in the next 30 days, higher than 83% of all scored CVEs (FIRST EPSS, 2026-11-08).

Exploits and checks

  • github.com https://github.com/pgjdbc/pgjdbc/security/advisories/GHSA-r38f-c4h4-hqq2 referenced PoC, tagged "exploit" by a source, unverified

CVSS scores

assigned by version score vector
CNA 3.1 7.1 CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H
GitHub 3.1 7.1 CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H
NVD 3.1 8.0 CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H
OSV 3.1 8.0 CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H

Affected packages

ecosystem package affected fixed in
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
bitnami postgresql-jdbc-driver
<42.2.26
>=42.3.0, <42.3.7
>=42.4.0, <=42.4.0
42.2.26
42.3.7

Affected products

  • pgjdbc pgjdbc

Classification

Weakness
  • CWE-89 Improper Neutralization of Special Elements used in an SQL Command

References

Sources

Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.