SQL Injection Vulnerability in PostgreSQL JDBC Driver (libpgjava) - CVE-2022-31197

libpgjava Updated 02 Oct 2025

Summary

03/08/2022
N/A
No i
High
7.1

UBUNTU-CVE-2022-31197: PostgreSQL JDBC Driver (PgJDBC for short) allows Java programs to connect to a PostgreSQL database using standard, database independent Java code. Affects libpgjava versions 9.2-1002-1. No fix is published. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The PostgreSQL JDBC Driver, commonly referred to as PgJDBC, is a crucial library that enables Java applications to connect to PostgreSQL databases using standard Java code. It is widely used in various applications for database interactions. The driver provides a set of functionalities that allow developers to execute SQL queries, retrieve results, and manage database connections efficiently. However, a significant vulnerability has been identified in the implementation of the java.sql.ResultRow.refreshRow() method, which could expose applications to SQL injection attacks if not addressed promptly.

Vulnerability Detail

The vulnerability arises from the PgJDBC implementation of the refreshRow() method, which fails to properly escape column names. This oversight allows an attacker to inject malicious SQL commands by crafting a column name that includes a statement terminator, such as a semicolon (;). If a user application invokes this method on a ResultSet that queries a database controlled by an attacker, it could lead to the execution of unauthorized SQL commands as the application's JDBC user. This vulnerability is particularly concerning for applications running with elevated privileges, as it could allow attackers to execute commands in the context of a privileged user.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

There are no known workarounds for this vulnerability. The best course of action is to apply the available patches as soon as possible.

Conclusion

The CVE-2022-31197 vulnerability in the PostgreSQL JDBC Driver poses a serious risk of SQL injection attacks due to improper handling of column names. Users are strongly advised to upgrade to the patched versions to secure their applications against potential exploitation. Regular monitoring for vulnerabilities using tools like Vulert can help maintain application security.

See every vulnerability recorded for libpgjava →

Share this vulnerability

FAQ

CVE-2022-31197 is a vulnerability in the PostgreSQL JDBC Driver that allows for SQL injection through the improper handling of column names in the refreshRow() method.

You can check if your application is affected by using the Vulert playground, which allows you to monitor and alert for open-source vulnerabilities without needing to sign up.

If exploited, this vulnerability could allow attackers to execute unauthorized SQL commands, potentially compromising sensitive data and application integrity.

Yes, patched versions of the PostgreSQL JDBC Driver are available. Users should upgrade to versions 42.2.26 or 42.4.1.

While there are no workarounds available, it is crucial to prioritize the upgrade to mitigate the risk associated with this vulnerability.

Related vulnerabilities

Recent vulnerabilities recorded for libpgjava.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback