CVE-2022-31197: SQL Injection in ResultSet.refreshRow() with malicious column names in pgjdbc
Noroxi assessment
Priority: Monitor (action score 33/100)
- The sources we track (CISA KEV, Exploit-DB, Metasploit, Nuclei, GitHub) show no public exploit code or exploitation in the wild.
- Probability of exploitation in the next 30 days: 2.3% (FIRST EPSS); higher than 83.8% of all records.
- Anyone who can reach it over the internet can trigger it. A low-privileged account is enough. A user must open a link or visit a page. No special conditions are required; it is repeatable.
- Fixed version: postgresql-jdbc (AlmaLinux:9) 42.2.18-6.el9_1; java-postgresql-jdbc (Alpine:v3.16) 42.4.2-r0; libpgjava (Debian:10) 42.2.5-2+deb10u2.
Low priority for now. Upgrade to postgresql-jdbc (AlmaLinux:9) 42.2.18-6.el9_1; java-postgresql-jdbc (Alpine:v3.16) 42.4.2-r0; libpgjava (Debian:10) 42.2.5-2+deb10u2 or later.
Generated automatically from the record's data: CVSS (NVD and CNA), CISA KEV and SSVC, FIRST EPSS, exploit sources, fixed versions. How we calculate it
Primary sources: NVD · CVE.org · FIRST EPSS
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.
- Published
- Aug 3, 2022
- Updated
- Jun 17, 2026
- EPSS
- 2.3% · 83th percentile
- CWE
- CWE-89
Report tools
Action score
33
Monitor
Low priority for now.
- CVSS
- 32 / 40 · 8.0 / 10
- CISA KEV
- 0 / 30 · Not listed
- EPSS
- 1 / 30 · 2.3%
CISA SSVC decision
- Exploitation
- proof of concept
- Automatable
- no
- Technical impact
- total
Vulnrichment: CISA's decision-tree inputs.
CNA vs NVD score
- NVD
- 8.0
- CNA · GitHub_M
- 7.1
- 0.9 point gap
CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H
The score given by the assigning authority versus NVD’s independent score. A gap means the severity is contested.
Get told when this record changes
- Not in KEV: no record of exploitation in the wild
- No public exploit code on record
- A fix has been released
If any of these changes, we'll tell you in the daily email digest.
Running WordPress? Scan your site free with WP Lens
Noroxi analysis
What does it mean in your environment?
The assessment above is generated automatically from the record's data; it doesn't know your environment. Our team verifies on your systems whether this vulnerability is actually exploitable and which mitigation is enough.
We use this product, ask for helpAffected systems
Is your version affected?
Pick the product and type the version you run. It's compared with this record's version ranges in your browser; the version isn't sent anywhere.
| Vendor | Product | CPE |
|---|---|---|
| postgresql | postgresql jdbc driver | cpe:2.3:a:postgresql:postgresql_jdbc_driver |
| debian | debian linux | cpe:2.3:o:debian:debian_linux |
| fedoraproject | fedora | cpe:2.3:o:fedoraproject:fedora |
Affected versions
NVD version ranges (for catalog products). Add the product to your stack with a version and matching uses these.
- debian debian linux10.0
- fedoraproject fedora35
- fedoraproject fedora36
- postgresql postgresql jdbc driver42.3.0 and later · before 42.3.7
- postgresql postgresql jdbc driverbefore 42.2.26
- postgresql postgresql jdbc driver42.4.0
- postgresql postgresql jdbc driver42.4.1
Versions reported by the vendor
Affected version ranges reported by the assigning authority (GitHub_M). Independent of NVD's CPE analysis and usually ahead of it.
pgjdbc pgjdbc
- >= 42.2.0, < 42.2.26, >= 42.3.0, < 42.4.1affected
Package-level exposure
OSV and GitHub Advisory data: ecosystem, package and range. SBOM matching uses this table.
| Ecosystem | Package | Affected range | Fix |
|---|---|---|---|
| AlmaLinux:9 | postgresql-jdbc | before 42.2.18-6.el9_1 | 42.2.18-6.el9_1 |
| Alpine:v3.16 | java-postgresql-jdbc | before 42.4.2-r0 | 42.4.2-r0 |
| Debian:10 | libpgjava | before 42.2.5-2+deb10u2 | 42.2.5-2+deb10u2 |
| Debian:11 | libpgjava | before 42.2.15-1+deb11u2 | 42.2.15-1+deb11u2 |
| Debian:12 | libpgjava | before 42.4.1-1 | 42.4.1-1 |
| Maven | org.postgresql:postgresql | from 42.3.0 · before 42.3.7 | 42.3.7 |
| Maven | org.postgresql:postgresql | from 42.4.0 · before 42.4.1 | 42.4.1 |
| Maven | org.postgresql:postgresql | before 42.2.26 | 42.2.26 |
| openSUSE:Leap 15.3 | postgresql-jdbc | before 42.2.25-150300.3.8.1 | 42.2.25-150300.3.8.1 |
| openSUSE:Leap 15.4 | postgresql-jdbc | before 42.2.25-150400.3.6.1 | 42.2.25-150400.3.6.1 |
| Red Hat:enterprise_linux:9::appstream | postgresql-jdbc | before 0:42.2.18-6.el9_1 | 0:42.2.18-6.el9_1 |
| Rocky Linux:9 | postgresql-jdbc | before 0:42.2.18-6.el9_1 | 0:42.2.18-6.el9_1 |
| SUSE:Linux Enterprise Module for Server Applications 15 SP4 | postgresql-jdbc | before 42.2.25-150400.3.6.1 | 42.2.25-150400.3.6.1 |
| SUSE:Manager Server Module 4.1 | postgresql-jdbc | before 42.2.10-150200.3.11.1 | 42.2.10-150200.3.11.1 |
| SUSE:Manager Server Module 4.2 | postgresql-jdbc | before 42.2.25-150300.3.8.1 | 42.2.25-150300.3.8.1 |
| SUSE:OpenStack Cloud 9 | postgresql-jdbc | before 9.4-3.6.3 | 9.4-3.6.3 |
Same product
postgresql: all recordsOther highest-scoring records for the same primary product.
- CVE-2024-1597pgjdbc SQL Injection via line comment generation40Plan
- CVE-2022-26520In pgjdbc before 42.3.3, an attacker (who controls the jdbc URL or properties) can call java.util.logging.FileHandler to write to arbitrary 40Plan
- CVE-2022-21724Unchecked Class Instantiation when providing Plugin Classes40Plan
Published before and after this one in the same product
- ← EarlierCVE-2018-10936Aug 30, 2018 · A weakness was found in postgresql-jdbc before version 42.2.5.33Monitor
- ← EarlierCVE-2020-13692Jun 4, 2020 · PostgreSQL JDBC Driver (aka PgJDBC) before 42.2.13 allows XXE.31Monitor
- Later →CVE-2022-41946Nov 23, 2022 · TemporaryFolder on unix-like systems does not limit access to created files in pgjdbc22Monitor
Remediation
Which version to upgrade to
Fix versions compiled from the vendor, package registries and Microsoft. Verify the vendor's note before upgrading.
| Product / package | Fixed version | Source |
|---|---|---|
| almalinux:postgresql-jdbc | 42.2.18-6.el9_1 · AlmaLinux:9 | Package registry (OSV) |
| alpine:java-postgresql-jdbc | 42.4.2-r0 · Alpine:v3.16 | Package registry (OSV) |
| debian:libpgjava | 42.4.1-1 · Debian:12 | Package registry (OSV) |
| Maven:org.postgresql:postgresql | 42.2.26 | Package registry (OSV) |
| Maven:org.postgresql:postgresql | 42.3.7 | Package registry (OSV) |
| Maven:org.postgresql:postgresql | 42.4.1 | Package registry (OSV) |
| opensuse:postgresql-jdbc | 42.2.25-150400.3.6.1 · openSUSE:Leap 15.4 | Package registry (OSV) |
| red hat:postgresql-jdbc | 0:42.2.18-6.el9_1 · Red Hat:enterprise_linux:9::appstream | Package registry (OSV) |
| rocky linux:postgresql-jdbc | 0:42.2.18-6.el9_1 · Rocky Linux:9 | Package registry (OSV) |
| suse:postgresql-jdbc | 42.2.25-150400.3.6.1 · SUSE:Linux Enterprise Module for Server Applications 15 SP4 | Package registry (OSV) |
Exploit status
No known public exploit
No public exploit has been observed yet. That doesn't mean you're safe, only that the bar is a little higher.
Research context
For pentesters and researchers: attack profile, score disagreement, timeline, patch commits, credits, variant and chain candidates, bug bounty scope. All derived from existing data; no exploit code.
Timeline
From publication to today: proof of concept, Metasploit module, CISA KEV and fix record. Dates are as reported by the sources.
No dated events beyond publication.
No history yet (it accumulates with the daily EPSS job).
Patch and commit links
Commit, PR and diff links among the references. A starting point for patch-diffing and variant hunting; fixes, not exploits.
Credits
All researchersFinders, reporters and analysts named in the CNA record. Click a name for that researcher’s other records.
No credits in the CNA record.
Variant candidates
Same product, same weakness class, within 18 months. If the patch missed the root cause, the sibling bug is here.
No nightly-computed relations.
Chain candidates
An authentication bypass and a privilege-requiring bug in the same product, published close together: combined they may become an unauthenticated path.
—
Bug bounty scope
No known public program.
Source: bounty-targets-data (public HackerOne, Bugcrowd, Intigriti, YesWeHack listings).
Technical details
Attack conditions
- Anyone who can reach it over the internet can trigger it.
- A low-privileged account is enough.
- A user must open a link or visit a page.
- No special conditions are required; it is repeatable.
If successful
- Confidentiality
- high · data can be read
- Integrity
- high · data or configuration can be modified
- Availability
- high · the service can be disrupted
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- Low
- User interaction
- Required
- Scope
- Unchanged
- Confidentiality impact
- High
- Integrity impact
- High
- Availability impact
- High
Weakness class (CWE)
CWE-89 · Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')CVSS vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H
nvd-primary
Root cause
The query text is built by concatenating user input. The database cannot tell where the data ends and the command begins.
The bug in code
The whole CWE-89 classA representative example of this vulnerability class. Not the vendor's source code; it shows the faulty pattern and its fix.
Vulnerable
const owner = req.query.owner;
const rows = await db.query(
"SELECT * FROM files WHERE owner = '" + owner + "'"
);Fixed
const owner = req.query.owner;
const rows = await db.query(
"SELECT * FROM files WHERE owner = $1",
[owner]
);Attack context
MITRE CAPEC attack patterns and ATT&CK techniques for this weakness class (CWE). A starting point for detection rules and threat hunting.
Attack patterns (CAPEC)
- Command Line Execution through SQL InjectionCAPEC-108likelihood: Low · Very High
- Object Relational Mapping InjectionCAPEC-109likelihood: Low · High
- SQL Injection through SOAP Parameter TamperingCAPEC-110likelihood: High · Very High
- Expanding Control over the Operating System from the DatabaseCAPEC-470Very High
- SQL InjectionCAPEC-66likelihood: High · High
- Blind SQL InjectionCAPEC-7likelihood: High · High
ATT&CK techniques
—
Change log
- Fix✗ → ✓
For records you follow, these changes also arrive as notifications. →
References
Show all references (4 more)Show less
- lists.debian.org/debian-lts-announce/2022/10/msg00009.html
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/I6WHUADTZBBQLVHO4YG4XCWDGWBT4LRP/
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UTFE6SV33P5YYU2GNTQZQKQRVR3GYE4S/
- lists.debian.org/debian-lts-announce/2024/12/msg00017.html
Vendor advisories and official records. Exploit/PoC links are deliberately left out.