CVEfocus › CVE database › CVE-2024-1597

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

CVSS 10.0 CriticalEPSS 3.1% (higher than 88% of CVEs)Published 2024-02-19Updated 2025-11-03Assigner: PostgreSQL

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.

CWE-89

What to do

Fixed builds are available from AlmaLinux, Alpine, Debian, Maven, Red Hat, Rocky Linux: see the table below for the fixed version per release.

Ubuntu has not shipped a fix for every release yet.

Is your server affected? One read-only command checks every installed package against this CVE and all others, using each vendor's fixed versions. Get started or get a free API key.

curl -sS "https://api.cvefocus.com/v1/check?format=text" -H "Authorization: Bearer $CVEFOCUS_KEY" \
  -H "Content-Type: text/plain" --data-binary @inventory.txt

Vendor status at a glance

18Fixed
4Fix pending
1Under investigation
6Not affected

Status by vendor and release

From each vendor's own security data and VEX statements. "Fixed" means a fixed build is published for that release.

ReleasePackageStatusFixed versionAdvisory
Ubuntu 26.04libpgjavaNot affected
vulnerable_code_not_present
Ubuntu 25.10libpgjavaNot affected
vulnerable_code_not_present
Ubuntu 24.04libpgjavaNot affected
vulnerable_code_not_present
Ubuntu 22.04libpgjavaUnder investigationUBUNTU-CVE-2024-1597
Ubuntu 20.04libpgjavaFix pendingUBUNTU-CVE-2024-1597
Ubuntu 18.04libpgjavaFix pendingUBUNTU-CVE-2024-1597
Ubuntu 16.04libpgjavaFix pending
Ubuntu 14.04libpgjavaFix pendingUBUNTU-CVE-2024-1597
Debian 14libpgjavaFixed42.7.2-1DEBIAN-CVE-2024-1597
Debian 13libpgjavaFixed42.7.2-1DEBIAN-CVE-2024-1597
Debian 12libpgjavaFixed42.5.5-0+deb12u1DEBIAN-CVE-2024-1597
Red Hat Enterprise Linux 9postgresql-jdbcFixed
Will not fix
0:42.2.28-1.el9_3RHSA-2024:1436
Red Hat Enterprise Linux 8postgresql-jdbcFixed
Will not fix
0:42.2.14-3.el8_9RHSA-2024:1435
Red Hat Enterprise Linux 8postgresql-jdbc-javadocFixed
Will not fix
0:42.2.14-3.el8_9RHSA-2024:1435
Red Hat Enterprise Linux 7postgresql-jdbcNot affected
Red Hat Enterprise Linux 7postgresql-jdbc-javadocNot affected
Red Hat Enterprise Linux 6postgresql-jdbcNot affected
AlmaLinux 9postgresql-jdbcFixed42.2.28-1.el9_3ALSA-2024:1436
AlmaLinux 8postgresql-jdbcFixed42.2.14-3.el8_9ALSA-2024:1435
AlmaLinux 8postgresql-jdbc-javadocFixed42.2.14-3.el8_9ALSA-2024:1435
Rocky Linux 9postgresql-jdbcFixed0:42.2.28-1.el9_3RLSA-2024:1436
Rocky Linux 8postgresql-jdbcFixed0:42.2.14-3.el8_9RLSA-2024:1435
Alpine Linux 3.24java-postgresql-jdbcFixed42.6.2-r0ALPINE-CVE-2024-1597
Alpine Linux 3.23java-postgresql-jdbcFixed42.6.2-r0ALPINE-CVE-2024-1597
Alpine Linux 3.22java-postgresql-jdbcFixed42.6.2-r0ALPINE-CVE-2024-1597
Alpine Linux 3.21java-postgresql-jdbcFixed42.6.2-r0ALPINE-CVE-2024-1597
Alpine Linux 3.20java-postgresql-jdbcFixed42.6.2-r0ALPINE-CVE-2024-1597
Alpine Linux 3.19java-postgresql-jdbcFixed42.6.2-r0ALPINE-CVE-2024-1597
Maven libraryorg.postgresql:postgresqlFixed42.7.2GHSA-24rp-q3w6-vc56

What the vendor says

As published in the CVE record by PostgreSQL, the CVE's assigner (usually the vendor). Check the vendor's advisory before acting.

Workaround: Don't use SimpleQuery mode

References

About this page

Compiled by CVEfocus from the CVE List, the security data and VEX statements of Ubuntu, Debian, Red Hat, AlmaLinux, Rocky Linux and Microsoft, CISA's Known Exploited Vulnerabilities catalog and FIRST EPSS, refreshed several times a day (data status). Information only; see the disclaimer. Official record: cve.org · NVD.