# CVE-2024-1597: pgjdbc SQL Injection via line comment generation

> Attackers can inject SQL via crafted numeric and string placeholders when PreferQueryMode is set to SIMPLE, bypassing parameterized query protections.

- **Severity:** Critical 10.0 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 19 Feb 2024
- **Updated:** 3 Nov 2025
- **Also known as:** ALSA-2024:1435, ALSA-2024:1436, BIT-postgresql-jdbc-driver-2024-1597, CLEANSTART-2026-DW89349, CLSA-2025-1754870602, CLSA-2025-1762243790, DEBIAN-CVE-2024-1597, DLA-3812-1, GHSA-24rp-q3w6-vc56, MGASA-2024-0120, MINI-29hr-h2v4-458g, MINI-m295-6px4-49mx, MINI-qg9w-fhw8-2m4r, OESA-2024-1237, RHSA-2024:1435, RHSA-2024:1436, RHSA-2024:1649, RHSA-2024:1999, RHSA-2024:2624, RHSA-2024:3313, RHSA-2024:4375, RHSA-2024:4402, RLSA-2024:1435, RLSA-2024:1436, ROOT-APP-MAVEN-CVE-2024-1597, SUSE-SU-2024:0769-1, SUSE-SU-2024:0771-1, SUSE-SU-2024:0773-1, UBUNTU-CVE-2024-1597, openSUSE-SU-2024:13734-1

## What is CVE-2024-1597?

CVE-2024-1597 is a critical SQL injection vulnerability in Fedoraproject Fedora, published on 19 Feb 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

pgjdbc, the PostgreSQL JDBC Driver, allows attacker to inject SQL if using PreferQueryMode=SIMPLE. Note this is not the default. In the default mode there is no vulnerability. A placeholder for a numeric value must be immediately preceded by a minus. There must be a second placeholder for a string value after the first placeholder; both must be on the same line. By constructing a matching string payload, the attacker can inject SQL to alter the query,bypassing the protections that parameterized queries bring against SQL Injection attacks. Versions before 42.7.2, 42.6.1, 42.5.5, 42.4.4, 42.3.9, and 42.2.28 are affected.

Weakness: CWE-89 (Improper Neutralization of Special Elements used in an SQL Command)

## Which versions are affected by CVE-2024-1597?

13 open source packages ship an affected version, including org.postgresql:postgresql and postgresql-jdbc-driver. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.postgresql:postgresql` | Maven | All versions | 42.2.28 |
| `org.postgresql:postgresql` | Maven | All versions | 42.2.28 |
| `org.postgresql:postgresql` | Maven | From 42.3.0 | 42.3.9 |
| `org.postgresql:postgresql` | Maven | From 42.3.0 | 42.3.9 |
| `org.postgresql:postgresql` | Maven | From 42.4.0 | 42.4.4 |
| `org.postgresql:postgresql` | Maven | From 42.4.0 | 42.4.4 |
| `org.postgresql:postgresql` | Maven | From 42.5.0 | 42.5.5 |
| `org.postgresql:postgresql` | Maven | From 42.5.0 | 42.5.5 |
| `org.postgresql:postgresql` | Maven | From 42.6.0 | 42.6.1 |
| `org.postgresql:postgresql` | Maven | From 42.6.0 | 42.6.1 |
| `org.postgresql:postgresql` | Maven | From 42.7.0 | 42.7.2 |
| `org.postgresql:postgresql` | Maven | From 42.7.0 | 42.7.2 |
| `postgresql-jdbc-driver` | Bitnami | All versions | 42.2.28, 42.3.9, 42.4.4, 42.5.5, 42.6.1, 42.7.2 |
| `postgresql-jdbc` | AlmaLinux:8 | All versions | 42.2.14-3.el8_9 |
| `postgresql-jdbc-javadoc` | AlmaLinux:8 | All versions | 42.2.14-3.el8_9 |
| `postgresql-jdbc` | AlmaLinux:9 | All versions | 42.2.28-1.el9_3 |
| `postgresql-jdbc` | Red Hat:enterprise_linux:8::appstream | All versions | 0:42.2.14-3.el8_9 |
| `postgresql-jdbc-javadoc` | Red Hat:enterprise_linux:8::appstream | All versions | 0:42.2.14-3.el8_9 |
| `postgresql-jdbc` | Red Hat:enterprise_linux:9::appstream | All versions | 0:42.2.28-1.el9_3 |
| `postgresql-jdbc` | Red Hat:rhel_aus:8.2::appstream | All versions | 0:42.2.3-5.el8_2 |
| `postgresql-jdbc-javadoc` | Red Hat:rhel_aus:8.2::appstream | All versions | 0:42.2.3-5.el8_2 |
| `postgresql-jdbc` | Red Hat:rhel_aus:8.4::appstream | All versions | 0:42.2.3-7.el8_4 |
| `postgresql-jdbc-javadoc` | Red Hat:rhel_aus:8.4::appstream | All versions | 0:42.2.3-7.el8_4 |
| `postgresql-jdbc` | Red Hat:rhel_aus:8.6::appstream | All versions | 0:42.2.3-5.el8_6 |
| `postgresql-jdbc-javadoc` | Red Hat:rhel_aus:8.6::appstream | All versions | 0:42.2.3-5.el8_6 |
| `postgresql-jdbc` | Red Hat:rhel_e4s:8.2::appstream | All versions | 0:42.2.3-5.el8_2 |
| `postgresql-jdbc-javadoc` | Red Hat:rhel_e4s:8.2::appstream | All versions | 0:42.2.3-5.el8_2 |
| `postgresql-jdbc` | Red Hat:rhel_e4s:8.4::appstream | All versions | 0:42.2.3-7.el8_4 |
| `postgresql-jdbc-javadoc` | Red Hat:rhel_e4s:8.4::appstream | All versions | 0:42.2.3-7.el8_4 |
| `postgresql-jdbc` | Red Hat:rhel_e4s:8.6::appstream | All versions | 0:42.2.3-5.el8_6 |
| `postgresql-jdbc-javadoc` | Red Hat:rhel_e4s:8.6::appstream | All versions | 0:42.2.3-5.el8_6 |
| `postgresql-jdbc` | Red Hat:rhel_eus:8.8::appstream | All versions | 0:42.2.14-5.el8_8 |
| `postgresql-jdbc-javadoc` | Red Hat:rhel_eus:8.8::appstream | All versions | 0:42.2.14-5.el8_8 |
| `postgresql-jdbc` | Red Hat:rhel_eus:9.0::appstream | All versions | 0:42.2.28-1.el9_0 |
| `postgresql-jdbc` | Red Hat:rhel_eus:9.2::appstream | All versions | 0:42.2.28-1.el9_2 |
| `postgresql-jdbc` | Red Hat:rhel_tus:8.2::appstream | All versions | 0:42.2.3-5.el8_2 |
| `postgresql-jdbc-javadoc` | Red Hat:rhel_tus:8.2::appstream | All versions | 0:42.2.3-5.el8_2 |
| `postgresql-jdbc` | Red Hat:rhel_tus:8.4::appstream | All versions | 0:42.2.3-7.el8_4 |
| `postgresql-jdbc-javadoc` | Red Hat:rhel_tus:8.4::appstream | All versions | 0:42.2.3-7.el8_4 |
| `postgresql-jdbc` | Red Hat:rhel_tus:8.6::appstream | All versions | 0:42.2.3-5.el8_6 |

Products: Fedoraproject Fedora, Postgresql Postgresql Jdbc Driver.

## How do I fix CVE-2024-1597?

Upgrade org.postgresql:postgresql to a fixed version for your release line: 42.2.28, 42.3.9, 42.4.4 or 42.5.5.

## Is CVE-2024-1597 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-1597 exists.

## Other vulnerabilities in Fedoraproject Fedora

- [CVE-2024-4577](https://insights.sbomify.com/CVE-2024-4577/): PHP-CGI OS Command Injection (critical 9.8, exploited in the wild)
- [CVE-2021-39226](https://insights.sbomify.com/CVE-2021-39226/): Grafana Authentication Bypass (critical 9.8, exploited in the wild)
- [CVE-2019-5544](https://insights.sbomify.com/CVE-2019-5544/): VMware ESXi and Horizon DaaS OpenSLP Heap-Based Buffer Overflow (critical 9.8, exploited in the wild)
- [CVE-2024-4947](https://insights.sbomify.com/CVE-2024-4947/): Google Chromium V8 Type Confusion (critical 9.6, exploited in the wild)
- [CVE-2024-4671](https://insights.sbomify.com/CVE-2024-4671/): Google Chromium Visuals Use-After-Free (critical 9.6, exploited in the wild)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-1597 and fix it if it is affected.

What it is: CVE-2024-1597 is a critical SQL injection vulnerability in Fedoraproject Fedora, published on 19 Feb 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-1597 exists.

Affected packages and fixed versions:
- org.postgresql:postgresql (Maven): affected all versions; fixed in 42.2.28
- org.postgresql:postgresql (Maven): affected all versions; fixed in 42.2.28
- org.postgresql:postgresql (Maven): affected from 42.3.0; fixed in 42.3.9
- org.postgresql:postgresql (Maven): affected from 42.3.0; fixed in 42.3.9
- org.postgresql:postgresql (Maven): affected from 42.4.0; fixed in 42.4.4
- org.postgresql:postgresql (Maven): affected from 42.4.0; fixed in 42.4.4
- org.postgresql:postgresql (Maven): affected from 42.5.0; fixed in 42.5.5
- org.postgresql:postgresql (Maven): affected from 42.5.0; fixed in 42.5.5
- org.postgresql:postgresql (Maven): affected from 42.6.0; fixed in 42.6.1
- org.postgresql:postgresql (Maven): affected from 42.6.0; fixed in 42.6.1
- org.postgresql:postgresql (Maven): affected from 42.7.0; fixed in 42.7.2
- org.postgresql:postgresql (Maven): affected from 42.7.0; fixed in 42.7.2

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-1597/ (Markdown: https://insights.sbomify.com/CVE-2024-1597/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-1597
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-1597
- OSV: https://osv.dev/vulnerability/CVE-2024-1597

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-1597/
Summaries are generated and may contain mistakes; the official description above is the record.
