CVE-2022-31197: SQL Injection in PgJDBC ResultSet.refreshRow()
- Vendors
- Debian ProjectFedora ProjectPostgresql
CVE-2022-31197 is an SQL injection vulnerability in the PostgreSQL JDBC Driver (PgJDBC) implementation of java.sql.ResultSet.refreshRow(). The driver constructs SQL using result-set column names without correctly escaping those identifiers. A malicious column name containing a statement terminator can therefore inject additional SQL statements when an application invokes refreshRow() on the affected ResultSet. Injected statements execute with the privileges of the JDBC connection user.
Impact, mitigation & remediation
What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.
Impact
What an attacker gets, and what they’ve been doing with it.
Successful exploitation permits execution of attacker-supplied SQL commands as the application's JDBC user. Depending on that user's database privileges, this can enable unauthorized reading, modification, or deletion of data; DDL changes; and abuse of privileges in schemas accessible to that user. The risk is particularly significant where a privileged application account queries schemas that can be created or modified by less-privileged or malicious database users.
Mitigation
If you can’t patch tonight, do this now.
No complete workaround is available other than updating. Until patched, avoid invoking ResultSet.refreshRow(). Where its use cannot be removed, prevent application JDBC accounts from querying attacker-controlled databases or schemas, restrict untrusted users from creating or altering tables and column names in schemas visible to the application, and apply least privilege to JDBC accounts.
Remediation
Patch, then assume compromise.
Upgrade PgJDBC to a fixed release in the applicable maintenance branch: 42.2.26, 42.3.7, 42.4.1, or later. Update transitive PgJDBC dependencies in affected application platforms and rebuild or redeploy applications as necessary.
Exploits
No public exploits tracked yet. Mallory keeps watching.
Affected products & vendors
Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.
References
Frequently asked questions
- Is CVE-2022-31197 exploited in the wild?
- Yes. As of Oct 16, 2026, Mallory has reports of exploitation in the wild.
- Is there a public exploit for CVE-2022-31197?
- Yes. As of Oct 16, 2026, Mallory has reports of a public exploit for CVE-2022-31197.
- Is there a patch for CVE-2022-31197?
- Upgrade PgJDBC to a fixed release in the applicable maintenance branch: 42.2.26, 42.3.7, 42.4.1, or later. Update transitive PgJDBC dependencies in affected application platforms and rebuild or redeploy applications as necessary.
- What products are affected by CVE-2022-31197?
- Postgresql Jdbc Driver, Debian Project Debian Linux, and Fedora Project Fedora.
- How severe is CVE-2022-31197?
- CVE-2022-31197 has a CVSS v3.1 score of 8.0 (High) and an EPSS score of 2.4% (84th percentile) as of Oct 16, 2026.
Recent activity
7 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.