WaratekVRT Sign in

CVE-2022-31197 PostgreSQL JDBC Driver

Affected softwarePostgreSQL JDBC Driver
Severity8.0 High CVSS 3.1 2 scores
Fixed in42.2.26, 42.4.1, 42.3.7
WeaknessSQL injection (CWE-89)
Published3 Aug 2022
Updated17 Jun 2026

Description

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.

Exploitation status

Exploited

Real-world exploitation reported by VulnCheck KEV. CISA has not confirmed it.

  • CISA KEV not listed
  • VulnCheck KEV listed Exploitation reported in the wild. 1 citation · earliest 2025-12-08.
  • CISA Vulnrichment exploitation: poc CISA recorded that an exploit has been demonstrated. Automatable: no, technical impact: total.
  • Indexed PoC none indexed
  • EPSS 2.4% chance in 30 days

VulnCheck KEV

Exploitation evidence from VulnCheck Known Exploited Vulnerabilities (VulnCheck KEV), used under VulnCheck's community terms. View CVE-2022-31197 in VulnCheck (free account).

EvidenceSourceDetailDate
Reported exploitation f5.com /labs/articles/shellshock-makes-a-comeback-and-rondodox-changes-tactics 2025-12-08

Waratek protection

Protected by Waratek

Waratek has a rule that blocks attacks on this vulnerability.

Decided by A vulnerability class already blocked by an ARMR security rule
Finding Protected by Waratek's ARMR sql-injection security rule, which blocks this class of attack at the JVM level without a rule written for this CVE specifically. The CVE's weakness is CWE-89: SQL Injection.
Candidate fix https://github.com/pgjdbc/pgjdbc/commit/739e599d52ad80f8dcd6efedc6157859b1a9d637 : a commit: the change itself

How to mitigate CVE-2022-31197

Upgrade PostgreSQL JDBC Driver to a release that fixes it: 42.2.26, 42.4.1 or 42.3.7. Until you can, Waratek RASP blocks exploitation with its SQL injection rule. It runs inside the Java application, with no code changes.

Waratek RASP Runtime protection for Java applications

CVSS

8.0 HIGH v3.1 CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H 2 metrics

We show the highest score from the newest CVSS version. Scores from different versions can't be compared, and the first score listed is sometimes a 0.0 placeholder.

VersionScoreBandVectorAssignerType
CVSS 3.1 8.0 HIGH CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H NVD Primary published
CVSS 3.1 7.1 HIGH CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H security-advisories@github.com Secondary

Affected software and releases

Oracle advisories

AdvisoryTypeQuarterProducts Oracle names in its risk matrix
Oracle Critical Patch Update July 2023 ↗ CPU 2023-Q3 Oracle Fusion Middleware / General (PostgreSQL JDBC Driver) (12.2.1.4.0)

Oracle components and versions

FamilyComponentVersions, as Oracle lists themRead as
Oracle Fusion Middleware General (PostgreSQL JDBC Driver) 12.2.1.4.0 12.2.1.4.0

Maven packages

Affected and fixed versions, from OSV.dev
PackageIntroducedFixedLast affected
org.postgresql:postgresql 0 42.2.26 unbounded
org.postgresql:postgresql 42.4.0 42.4.1 unbounded
org.postgresql:postgresql 42.3.0 42.3.7 unbounded

Products and versions

4 products, 11 version entries
SourceVendorProductSchemeAffected versions
nvd debian debian linux generic 10.0
nvd fedoraproject fedora generic 35 · 36
osv org.postgresql postgresql generic < 42.2.26 · ≥ 42.3.0 and < 42.3.7 · ≥ 42.4.0 and < 42.4.1
nvd postgresql postgresql jdbc driver generic < 42.2.26 · ≥ 42.3.0 and < 42.3.7 · 42.4.0 · 42.4.0:rc1 · 42.4.1:rc1

References

URLTags
https://github.com/pgjdbc/pgjdbc/commit/739e599d52ad80f8dcd6efedc6157859b1a9d637 commit
https://github.com/pgjdbc/pgjdbc/security/advisories/GHSA-r38f-c4h4-hqq2 WEB
https://github.com/pgjdbc/pgjdbc PACKAGE
https://lists.debian.org/debian-lts-announce/2022/10/msg00009.html WEB
https://lists.debian.org/debian-lts-announce/2024/12/msg00017.html WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/I6WHUADTZBBQLVHO4YG4XCWDGWBT4LRP WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UTFE6SV33P5YYU2GNTQZQKQRVR3GYE4S WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/I6WHUADTZBBQLVHO4YG4XCWDGWBT4LRP WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/UTFE6SV33P5YYU2GNTQZQKQRVR3GYE4S WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/I6WHUADTZBBQLVHO4YG4XCWDGWBT4LRP/

Timeline

Published2022-08-03By the CVE Program.
VulnCheck KEV: earliest evidence2025-12-08Date of the oldest evidence of exploitation in VulnCheck KEV's record. VulnCheck does not publish the date it listed the CVE.
NVD record modified2026-06-17NVD's own last-modified date for this record.