SQL Injection in ResultSet.refreshRow() with malicious column names in pgjdbc
Key facts
- Attack vector
- Network
- Privileges required
- Low
- User interaction
- Required
- Attack complexity
- Low
- Impact type
- SQL injection
- Confidentiality · integrity · availability
- High · High · High
- Fix status
- Partial Red Hat: 4 fixed, 4 without a fix
Attack profile from CVSS 3.1 · NVD. Fix status from CNA, GitHub and Red Hat. Impact type from CWE-89.
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.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- Poc
- Automatable
- No
- Technical impact
- Total
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| PostgreSQL | pgjdbc | 42.2.0 to before 42.2.26; 42.3.0 to before 42.4.1 | 42.2.26, 42.4.1 | Patch available | CNA |
| — | org.postgresql:postgresql (Maven) | before 42.2.26 | 42.2.26 | Patch available | GHSA-r38f-c4h4-hqq2 |
| — | org.postgresql:postgresql (Maven) | 42.4.0 to before 42.4.1 | 42.4.1 | Patch available | GHSA-r38f-c4h4-hqq2 |
| — | org.postgresql:postgresql (Maven) | 42.3.0 to before 42.3.7 | 42.3.7 | Patch available | GHSA-r38f-c4h4-hqq2 |
- pgjdbc VendorPostgreSQL Affected 42.2.0 to before 42.2.26; 42.3.0 to before 42.4.1 Fixed in 42.2.26, 42.4.1 Patch available CNA
- org.postgresql:postgresql (Maven) Vendor— Affected before 42.2.26 Fixed in 42.2.26 Patch available GHSA-r38f-c4h4-hqq2
- org.postgresql:postgresql (Maven) Vendor— Affected 42.4.0 to before 42.4.1 Fixed in 42.4.1 Patch available GHSA-r38f-c4h4-hqq2
- org.postgresql:postgresql (Maven) Vendor— Affected 42.3.0 to before 42.3.7 Fixed in 42.3.7 Patch available GHSA-r38f-c4h4-hqq2
CPE configurations NVD · 7
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:postgresql:postgresql_jdbc_driver:*:*:*:*:*:*:*:* | before 42.2.26; 42.3.0 to before 42.3.7 | Vulnerable | PostgreSQL |
| cpe:2.3:a:postgresql:postgresql_jdbc_driver:42.4.0:-:*:*:*:*:*:* | 42.4.0 | Vulnerable | PostgreSQL |
| cpe:2.3:a:postgresql:postgresql_jdbc_driver:42.4.0:rc1:*:*:*:*:*:* | 42.4.0 rc1 | Vulnerable | PostgreSQL |
| cpe:2.3:a:postgresql:postgresql_jdbc_driver:42.4.1:rc1:*:*:*:*:*:* | 42.4.1 rc1 | Vulnerable | PostgreSQL |
| cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:* | 10.0 | Vulnerable | Debian |
| cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:* | 35 | Vulnerable | Fedoraproject |
| cpe:2.3:o:fedoraproject:fedora:36:*:*:*:*:*:*:* | 36 | Vulnerable | Fedoraproject |
- cpe:2.3:a:postgresql:postgresql_jdbc_driver:*:*:*:*:*:*:*:* Versions before 42.2.26; 42.3.0 to before 42.3.7 Vulnerable ·PostgreSQL
- cpe:2.3:a:postgresql:postgresql_jdbc_driver:42.4.0:-:*:*:*:*:*:* Versions 42.4.0 Vulnerable ·PostgreSQL
- cpe:2.3:a:postgresql:postgresql_jdbc_driver:42.4.0:rc1:*:*:*:*:*:* Versions 42.4.0 rc1 Vulnerable ·PostgreSQL
- cpe:2.3:a:postgresql:postgresql_jdbc_driver:42.4.1:rc1:*:*:*:*:*:* Versions 42.4.1 rc1 Vulnerable ·PostgreSQL
- cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:* Versions 10.0 Vulnerable ·Debian
- cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:* Versions 35 Vulnerable ·Fedoraproject
- cpe:2.3:o:fedoraproject:fedora:36:*:*:*:*:*:*:* Versions 36 Vulnerable ·Fedoraproject
Remediation
- Fix · CNA pgjdbc (pgjdbc) Fixed in 42.2.26, 42.4.1
- Fix · GHSA-r38f-c4h4-hqq2 org.postgresql:postgresql (Maven) Fixed in 42.2.26 Advisory →
- Fix · GHSA-r38f-c4h4-hqq2 org.postgresql:postgresql (Maven) Fixed in 42.4.1 Advisory →
- Fix · GHSA-r38f-c4h4-hqq2 org.postgresql:postgresql (Maven) Fixed in 42.3.7 Advisory →
Red Hat 4 advisories
- RHSA-2023:1006 Released 2023-03-08 · Red Hat rating ImportantRed Hat build of Quarkus 2.7.7 release and security update
- Red Hat build of Quarkus 2.7.7
- RHSA-2023:0318 Released 2023-01-23 · Red Hat rating Moderatepostgresql-jdbc security update
- Red Hat Enterprise Linux AppStream (v. 9) postgresql-jdbc-42.2.18-6.el9_1
- RHSA-2022:9023 Released 2022-12-14 · Red Hat rating ImportantRed Hat build of Quarkus 2.13.5 release and security update
- Red Hat build of Quarkus 2.13.5
Show 1 more Red Hat advisories
- RHSA-2022:8652 Released 2022-11-28 · Red Hat rating ImportantRed Hat Fuse 7.11.1 release and security update
- Red Hat Fuse 7.11.1
Vendor assessments
Red Hat
Red Hat rating: Moderate. Red Hat's page for this CVE →
| Product | Status | Plan or fix |
|---|---|---|
| Red Hat Decision Manager 7 | Affected | No fix planned: Out of support scope |
| Red Hat Enterprise Linux 8 | Affected | No fix planned: Will not fix |
| Red Hat Process Automation 7 | Affected | No fix planned: Out of support scope |
| Red Hat build of Apicurio Registry 2 | Affected | No fix yet |
| Red Hat Enterprise Linux AppStream (v. 9) | Fixed | RHSA-2023:0318 |
| Red Hat Fuse 7.11.1 | Fixed | RHSA-2022:8652 |
| Red Hat build of Quarkus 2.13.5 | Fixed | RHSA-2022:9023 |
| Red Hat build of Quarkus 2.7.7 | Fixed | RHSA-2023:1006 |
Not affected: 5 products
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
- Red Hat Integration Camel K 1
- Red Hat Integration Camel Quarkus 1
- Red Hat Single Sign-On 7
Timeline
- 2026-10-02 Threatist record created from CVE-2022-31197
- 2026-10-03 Alias added: GHSA-r38f-c4h4-hqq2
References
Advisory 4
Other 6
- https://github.com/pgjdbc/pgjdbc
- https://lists.debian.org/debian-lts-announce/2024/12/msg00017.html
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/I6WHUADTZBBQLVHO4YG4XCWDGWBT4LRP
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UTFE6SV33P5YYU2GNTQZQKQRVR3GYE4S
- https://lists.fedoraproject.org/archives/list/[email protected]/message/I6WHUADTZBBQLVHO4YG4XCWDGWBT4LRP
- https://lists.fedoraproject.org/archives/list/[email protected]/message/UTFE6SV33P5YYU2GNTQZQKQRVR3GYE4S
More Postgresql Jdbc Driver vulnerabilities
- TI-2024-01491 pgjdbc SQL Injection via line comment generation CVSS 3.1CRITICAL 10.0
- TI-2022-06097 Unchecked Class Instantiation when providing Plugin Classes CVSS 3.1CRITICAL 9.8
- TI-2022-09860 In pgjdbc before 42.3.3, an attacker (who controls the jdbc URL or properties) can call… CVSS 3.1CRITICAL 9.8
- TI-2026-30519 pgjdbc: Unbounded PBKDF2 iterations in SCRAM authentication allows CPU exhaustion DoS CVSS 3.1HIGH 7.5
- TI-2025-31226 pgjdbc Client Allows Fallback to Insecure Authentication Despite channelBinding=require Configuration CVSS 3.1HIGH 8.2
- TI-2020-10739 PostgreSQL JDBC Driver (aka PgJDBC) before 42.2.13 allows XXE. CVSS 3.1HIGH 7.7
Sources
- CVE-2022-31197 · CVE Program
- CVE-2022-31197 · NVD
- FIRST EPSS
- GHSA-r38f-c4h4-hqq2 · GitHub Advisory Database · CC BY 4.0
- CVE-2022-31197 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences