cve.bz

CVE-2022-31197 SQL Injection

8.0 highExploit referenceEPSS 2.4%Fix available

High (8.0). EPSS 2.4% estimated probability of exploitation activity in the next 30 days. Fixed in org.postgresql:postgresql 42.2.26, 42.3.7, 42.4.1.

On this page
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.

Severity

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
EPSS
2.4% (unchanged from 2.4% a week ago; 2.4% 30 days ago) estimated probability of exploitation activity in the next 30 days; 84th percentile. Scored 2026-11-22. A forecast for this CVE across the internet, not for your own systems.
CISA's assessment (SSVC)
Exploitation: PoC · Automatable: no · Technical impact: total, assessed 2025-04-22. From CISA's Vulnrichment in the CVE List: whether it is exploited, whether exploiting it can be automated, and how much control it gives.
CWE
CWE-89 Improper Neutralization of Special Elements used in an SQL Command (SQL Injection)
OWASP Top 10
A05:2025 Injection
Published
Modified
NVD analysis
Analyzed, since modified
Record from
the NVD, synced

Fix and patched versions

Ask an AI about this CVE

Show the promptExplain CVE-2022-31197 for an engineer deciding whether to act. Use https://cve.bz/api/public/cves/CVE-2022-31197?via=ask-ai-copy and https://cve.bz/cve/CVE-2022-31197?via=ask-ai-copy as the source of truth: what is affected and which versions fix it, whether it is in CISA KEV, public exploits, and its EPSS (an internet-wide 30-day estimate of exploitation activity, not a forecast for my systems). If they give no fixed versions, use the CVE record https://cveawg.mitre.org/api/cve/CVE-2022-31197 or the vendor advisory, not third-party mirrors. Tell me how to check whether I am affected and how to verify a fix. Cite the sources and say where they are uncertain.

Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this CVE's id and public links.

Affected

Versions

From the NVD's CPE matches.

ProductAffected
postgresql:postgresql_jdbc_driverbefore 42.2.26
postgresql:postgresql_jdbc_driverfrom 42.3.0 before 42.3.7
postgresql:postgresql_jdbc_driver42.4.0
postgresql:postgresql_jdbc_driver42.4.0:rc1
postgresql:postgresql_jdbc_driver42.4.1:rc1
debian:debian_linux10.0
fedoraproject:fedora35
fedoraproject:fedora36

Packages (OSV)

AdvisoryEcosystemPackageAffectedFixed in
GHSA-r38f-c4h4-hqq2Mavenorg.postgresql:postgresql<42.2.2642.2.26
GHSA-r38f-c4h4-hqq2Mavenorg.postgresql:postgresql>=42.4.0 <42.4.142.4.1
GHSA-r38f-c4h4-hqq2Mavenorg.postgresql:postgresql>=42.3.0 <42.3.742.3.7

Linux distributions

DistributionReleasePackageFixed inAdvisory
Debian10libpgjava42.2.5-2+deb10u2DLA-3140-1
Debian11libpgjava42.2.15-1+deb11u2DLA-3995-1
Debian12, 13, 14libpgjava42.4.1-1DEBIAN-CVE-2022-31197
Ubuntu14.04:LTS, 16.04:LTS, 22.04:LTS and 6 morelibpgjavano fix listedUBUNTU-CVE-2022-31197
Red Hatenterprise_linux:9::appstreampostgresql-jdbc0:42.2.18-6.el9_1RHSA-2023:0318
SUSELinux Enterprise Module for Server Applications 15 SP3, Manager Server Module 4.2postgresql-jdbc42.2.25-150300.3.8.1SUSE-SU-2022:3613-1
SUSELinux Enterprise Module for Server Applications 15 SP4postgresql-jdbc42.2.25-150400.3.6.1SUSE-SU-2022:3537-1
SUSELinux Enterprise Server 12 SP2-BCL, Linux Enterprise Server 12 SP3-BCL, Linux Enterprise Server 12 SP4-LTSS and 5 morepostgresql-jdbc9.4-3.6.3SUSE-SU-2022:3541-1
SUSEManager Server Module 4.1postgresql-jdbc42.2.10-150200.3.11.1SUSE-SU-2022:3705-1
openSUSELeap 15.3postgresql-jdbc42.2.25-150300.3.8.1SUSE-SU-2022:3613-1
openSUSELeap 15.4postgresql-jdbc42.2.25-150400.3.6.1SUSE-SU-2022:3537-1
AlmaLinux9postgresql-jdbc42.2.18-6.el9_1ALSA-2023:0318
Rocky Linux9postgresql-jdbc0:42.2.18-6.el9_1RLSA-2023:0318
Alpinev3.16, v3.17, v3.18 and 6 morejava-postgresql-jdbc42.4.2-r0ALPINE-CVE-2022-31197

From the distributions' data via OSV.dev: the Debian Security Tracker; Ubuntu Security Notices © Canonical Ltd., CC BY-SA 4.0; Red Hat Security Data © Red Hat, Inc., CC BY 4.0; SUSE security data, CC BY 4.0; AlmaLinux's OSV database, MIT; Rocky Linux's errata, BSD-3-Clause; the Alpine secdb, CC BY-SA 4.0. Modified: reformatted and linked to CVE records. Credits. On the distributions' own pages: Debian · Ubuntu · Red Hat · SUSE · openSUSE · Alpine.

Red Hat

Red Hat rates this Moderate.

Red Hat's statement

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

Red Hat Fuse 7 is now in Maintenance Support Phase and details about its fix should be presented soon. However, Red Hat Fuse Online (Syndesis) does will not contain the fix for this flaw.

ProductPackageStateAdvisory
Red Hat build of Quarkus 2.13.5postgresqlFixed 2022-12-14RHSA-2022:9023
Red Hat build of Quarkus 2.7.7Fixed 2023-03-08RHSA-2023:1006
Red Hat Enterprise Linux 9postgresql-jdbc-0:42.2.18-6.el9_1Fixed 2023-01-23RHSA-2023:0318
Red Hat Fuse 7.11.1jdbc-postgresqlFixed 2022-11-28RHSA-2022:8652
Red Hat build of Apicurio Registry 2quarkus-jdbc-postgresql-deploymentAffected
Red Hat Decision Manager 7jdbc-postgresqlOut of support scope
Red Hat Enterprise Linux 6postgresql-jdbcNot affected
Red Hat Enterprise Linux 7postgresql-jdbcNot affected
Red Hat Enterprise Linux 8libreoffice:flatpak/libreofficeWill not fix
Red Hat Enterprise Linux 8postgresql-jdbcWill not fix
Red Hat Integration Camel K 1quarkus-jdbc-postgresql-deploymentNot affected
Red Hat Integration Camel Quarkus 1quarkus-jdbc-postgresql-deploymentNot affected
Red Hat Process Automation 7jdbc-postgresqlOut of support scope
Red Hat Single Sign-On 7jdbc-postgresqlNot affected

Contains Red Hat Security Data © Red Hat, Inc., licensed under CC BY 4.0. Source: https://access.redhat.com/security/data. Modified: reformatted. Red Hat's page for CVE-2022-31197.

Attack patterns (CAPEC)

  • CAPEC-7 Blind SQL Injection Likelihood: High · Severity: High
  • CAPEC-66 SQL Injection Likelihood: High · Severity: High
  • CAPEC-108 Command Line Execution through SQL Injection Likelihood: Low · Severity: Very High
  • CAPEC-109 Object Relational Mapping Injection Likelihood: Low · Severity: High
  • CAPEC-110 SQL Injection through SOAP Parameter Tampering Likelihood: High · Severity: Very High
  • CAPEC-470 Expanding Control over the Operating System from the Database Severity: Very High

The attack patterns MITRE's CAPEC relates to this record's weaknesses, as MITRE names them. Credits.

References

Check your stackJSON