LiveActive security incident?Get immediate response
CVE Record

CVE-2022-31197: SQL Injection in ResultSet.refreshRow() with malicious column names in pgjdbc

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.

HighCVSS 7.1Not KEV-listedUpdated
Glexia's TakeAutomated analysishigh

Security readout for executives and security teams

Plain-English summary

This flaw affects Java applications using vulnerable pgjdbc versions when they call ResultSet.refreshRow() on database results from attacker-influenced schemas. A malicious column name could cause extra SQL to run as the application's JDBC user. Most applications are unaffected unless that uncommon method and exposure pattern exist.

Executive priority

Prioritize remediation for Java systems that combine vulnerable pgjdbc, refreshRow() usage, and multi-tenant or user-controlled database schemas. For typical applications that never call refreshRow(), business urgency is lower, but dependency upgrades should still be scheduled.

Technical view

pgjdbc failed to escape column names inside ResultSet.refreshRow(). If an attacker can cause the application to query a table with malicious column names and refresh the row, injected SQL may execute with the JDBC user's privileges. Fixed releases are 42.2.26 and 42.4.1.

Likely exposure

Exposure is likely limited to Java services using pgjdbc 42.2.0-42.2.25 or 42.3.0-42.4.0 that call ResultSet.refreshRow(). Risk rises where applications query schemas, tables, or databases controlled by less-privileged or untrusted users.

Exploitation context

The advisory describes high attack complexity, low privileges, and required user interaction. The attacker must influence database object names and cause application behavior that invokes refreshRow(). The source bundle does not report active exploitation, and KEV status is false.

Researcher notes

Focus validation on the call path and privilege boundary, not only package presence. The important scenario is a privileged JDBC user reading attacker-controlled schema objects. Sources state no known workaround and identify fixed pgjdbc releases.

Mitigation direction

  • Upgrade pgjdbc to 42.2.26, 42.4.1, or a later fixed release.
  • Update distro packages such as libpgjava using Fedora or Debian security updates where applicable.
  • Review applications for ResultSet.refreshRow() use with PostgreSQL JDBC ResultSets.
  • Avoid privileged JDBC accounts querying schemas or tables controlled by less-privileged users.
  • If immediate upgrade is blocked, check current pgjdbc vendor guidance because sources name no workaround.

Validation and detection

  • Inventory Maven, Gradle, and packaged Java applications for affected pgjdbc versions.
  • Search application code for ResultSet.refreshRow() calls against PostgreSQL ResultSets.
  • Confirm whether services query schemas or tables writable by untrusted users.
  • Verify deployed artifacts use the upgraded pgjdbc or patched distro package.
  • Review JDBC account privileges for unnecessary elevated database permissions.
Prepared
Confidence
high
Sources
7

Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.

Potential ATT&CK relevance

Conservative CVE-to-ATT&CK context

These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.

ATT&CK lookup starting points

Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.

cwe · medium confidence lookup

CWE-89: Database access and collection lookup

Injection into data stores can inform collection, data access, and exfiltration detection reviews. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.

Open ATT&CK lookup
description · low confidence lookup

Database behavior lookup

The CVE wording references database injection or access, so collection and exfiltration review may help. This is a Glexia inferred lookup path, not an official MITRE, ATT&CK, or CVE Program mapping.

Open ATT&CK lookup
cve · low confidence lookup

CVE-2022-31197 mapping review

Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.

Open ATT&CK lookup
Vulnerability profileCVE Program record
Severity
High
CVSS
7.1 (3.1)
Known Exploited
No
Published

Vector: CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H

Official CVE source material

CNA and ADP enrichment extracted from CVE v5

These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.

1CVSS vectors
0Timeline events
0ADP providers
7Source links

CVSS vector scores

1 official score

We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.

ScoreVersionSeverityVectorExploitImpactSource
7.1CVSS 3.1HighCVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H1.25.9Primary CVE score

Vulnerability scoring details

Base CVSS 3.1 score

7.1High
CVSS 3.1 vector shape for CVE-2022-31197Attack VectorAttack ComplexityPrivileges RequiredUser InteractionScopeConfidentiality ImpactIntegrity ImpactAvailability Impact

Vector: CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H

Attack Vector
NetworkAdjacentLocalPhysical
Attack Complexity
LowHigh
Privileges Required
NoneLowHigh
User Interaction
NoneRequired
Scope
ChangedUnchanged
Confidentiality Impact
HighLowNone
Integrity Impact
HighLowNone
Availability Impact
HighLowNone
Affected products

Products and packages named in the record

VendorProductVersion / packageStatus
pgjdbcpgjdbc>= 42.2.0, < 42.2.26, >= 42.3.0, < 42.4.1Listed
Weakness

CWE details

CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.