Your RSA-2048 keys break in 2030. Find every one of them before attackers do.
Maven
Not in CISA KEV
HIGH severity

CVE-2022-31197 postgresql

HIGHFix: pgjdbc/pgjdbc@739e599

CVE-2022-31197 is a high-severity (CVSS 7.1) SQL Injection vulnerability in org.postgresql:postgresql. 1 public exploit reference exists, so weaponization risk is real. A fix is available for org.postgresql:postgresql — see the affected versions and patch details below.

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

Also known asBIT-postgresql-jdbc-driver-2022-31197GHSA-r38f-c4h4-hqq2
Published
Aug 3, 2022
Updated
Aug 12, 2026
Affected
3 pkgs
Patched
3 / 3
Exploits
1 known
Exploitation data as of Sep 21, 2026 · OSV.dev, NVD, FIRST.org (EPSS)

Exploitation Status

Proof-of-concept exploit code exists

  • CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
  • A successful exploit gives an attacker total control of the affected component, not partial access.

Exploitation and automatability from CISA’s SSVC triage for CVE-2022-31197.

EPSS Exploitation Probability

via FIRST.org ↗
2.1%probability of exploitation in next 30 days
Lower Risk0.00%
Lower risk than most CVEs80th percentile — riskier than 80% of all scored CVEsHighest risk

EPSS (Exploit Prediction Scoring System) is a daily probability model maintained by FIRST.org. It estimates the likelihood a CVE will be exploited in production environments within the next 30 days, derived from real-world threat intelligence signals.

How urgent is this, really

CVE-2022-31197 plotted by exploitation likelihood (EPSS) against impact (CVSS). The shaded corner — EPSS 50%+ and CVSS 7.0+ — is where this CVE doesn't sit, though severity or exploitability alone can still warrant action.

Where this sits among everything scored

Of 377,333 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Real counts from FIRST.org, not a sample — log-scaled since the landscape is heavily right-skewed.

Real-World Exposure

3 pkgs affected
org.postgresql:postgresqlorg.postgresql:postgresqlorg.postgresql:postgresql

Real-time download stats are indexed for npm and PyPI packages. This vulnerability affects Maven packages — download data is not available via public APIs for these ecosystems.

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.

Affected Packages

3 total 3 fixed
EcosystemPackageVulnerable rangeFix
Mavenorg.postgresql:postgresqlall versions42.2.26org.postgresql:postgresql:42.2.26
Mavenorg.postgresql:postgresql42.4.0&&< 42.4.142.4.1org.postgresql:postgresql:42.4.1
Mavenorg.postgresql:postgresql42.3.0&&< 42.3.742.3.7org.postgresql:postgresql:42.3.7
Exploits & PoCs
1

Research use only. For defensive security, authorized penetration testing, and academic research only. Never execute exploit code against systems without explicit written authorization.

Detection & mitigation playbook

Open-source dependency
  1. Detect

    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for org.postgresql:postgresql, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.

  2. Fix

    Update org.postgresql:postgresql to 42.2.26 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2022-31197 is resolved across your whole dependency graph.

  3. Workarounds

    If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.

  4. How O3 protects you

    O3 Security's impact-aware SCA analyses which vulnerable code paths your application actually calls, so a match like CVE-2022-31197 can be triaged on real exposure rather than presence alone.

Tailored to CVE-2022-31197. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.

Fixing This On Your OS

If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.

Red HatModerate

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.

ProductFixed inAdvisory
Red Hat build of Quarkus 2.13.5postgresqlRHSA-2022:9023
Red Hat build of Quarkus 2.7.7see advisoryRHSA-2023:1006
Red Hat Enterprise Linux 9postgresql-jdbc-0:42.2.18-6.el9_1RHSA-2023:0318
Red Hat Fuse 7.11.1jdbc-postgresqlRHSA-2022:8652

Frequently Asked Questions

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
O3 Security · Impact-Aware SCA

Is CVE-2022-31197 in your dependencies?

O3 Security finds CVE-2022-31197 across Maven dependencies, including transitive ones, and its impact-aware SCA ranks findings by whether your code actually calls the vulnerable path.

CVE-2022-31197: postgresql (High 7.1) | O3 Security