CVE-2024-1597: SQL Injection in pgjdbc

org.postgresql:postgresql Updated 02 Oct 2025

Summary

19/02/2024
Yes i
Critical
10.0

CVE-2024-1597: Duplicate Advisory: SQL injection in pgjdbc. Affects org.postgresql:postgresql across 6 version ranges.

< 42.2.8 >= 42.3.0, < 42.3.9 >= 42.4.0, < 42.4.4 >= 42.5.0, < 42.5.5 >= 42.6.0, < 42.6.1 >= 42.7.0, < 42.7.2

Fixed in 6 releases; the minimum fixed version depends on the release line you run. How to fix ↓

Also tracked for

The same CVE-2024-1597 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

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 Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

The PostgreSQL JDBC Driver, pgjdbc, is a Java library that allows applications to connect to a PostgreSQL database. It provides a set of classes and methods for executing SQL queries, managing connections, and handling database transactions. pgjdbc is widely used in Java applications that interact with PostgreSQL databases.

Vulnerability Detail

The vulnerability in pgjdbc allows an attacker to inject SQL if using PreferQueryMode=SIMPLE. This vulnerability affects versions before 42.7.2, 42.6.1, 42.5.5, 42.4.4, 42.3.9, and 42.2.8. In the default mode, there is no vulnerability. However, if a placeholder for a numeric value is immediately preceded by a minus and there is a second placeholder for a string value after the first placeholder on the same line, an attacker can construct a matching string payload to inject SQL and alter the query. This bypasses the protections provided by parameterized queries against SQL Injection attacks.

How To Fix

Latest published version: 42.7.14 as of 22 Oct 2026

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 42.2.8 42.2.8
  • >= 42.3.0, < 42.3.9 42.3.9
  • >= 42.4.0, < 42.4.4 42.4.4
  • >= 42.5.0, < 42.5.5 42.5.5
  • >= 42.6.0, < 42.6.1 42.6.1
  • >= 42.7.0, < 42.7.2 42.7.2

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If upgrading to a fixed version is not immediately feasible, a possible workaround is to avoid using PreferQueryMode=SIMPLE. Stick to the default mode or use a different mode that does not have this vulnerability.

Conclusion

The SQL injection vulnerability in pgjdbc can be mitigated by upgrading to the fixed versions or using a different query mode. It is important to promptly update the dependency in your Maven project to ensure the security of your application. For further support on vulnerability remediation, contact DevNack.com.

See every vulnerability recorded for org.postgresql:postgresql →

Share this vulnerability

FAQ

pgjdbc is the PostgreSQL JDBC Driver, a Java library for connecting to PostgreSQL databases.

Versions before 42.7.2, 42.6.1, 42.5.5, 42.4.4, 42.3.9, and 42.2.8 are affected.

The default mode in pgjdbc does not have this vulnerability.

By constructing a specific string payload, an attacker can inject SQL and alter the query, bypassing the protections of parameterized queries.

If upgrading to a fixed version is not possible, using a different query mode or sticking to the default mode can mitigate the vulnerability.

Related vulnerabilities

Recent vulnerabilities recorded for org.postgresql:postgresql.

How To Fix

Latest published version: 42.7.14 as of 22 Oct 2026

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 42.2.8 42.2.8
  • >= 42.3.0, < 42.3.9 42.3.9
  • >= 42.4.0, < 42.4.4 42.4.4
  • >= 42.5.0, < 42.5.5 42.5.5
  • >= 42.6.0, < 42.6.1 42.6.1
  • >= 42.7.0, < 42.7.2 42.7.2

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. 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