SQL Injection in PgJDBC ResultSet.refreshRow()
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.
What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.
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.
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.
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.
No public exploits tracked yet. Mallory keeps watching.
Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.
7 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.