CVE-2024-1597pgjdbc SQL Injection via line comment generation
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
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
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.
| Release | Package | Status | Fixed version | Advisory |
|---|---|---|---|---|
| Ubuntu 26.04 | libpgjava | Not affected vulnerable_code_not_present | ||
| Ubuntu 25.10 | libpgjava | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | libpgjava | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | libpgjava | Under investigation | UBUNTU-CVE-2024-1597 | |
| Ubuntu 20.04 | libpgjava | Fix pending | UBUNTU-CVE-2024-1597 | |
| Ubuntu 18.04 | libpgjava | Fix pending | UBUNTU-CVE-2024-1597 | |
| Ubuntu 16.04 | libpgjava | Fix pending | ||
| Ubuntu 14.04 | libpgjava | Fix pending | UBUNTU-CVE-2024-1597 | |
| Debian 14 | libpgjava | Fixed | 42.7.2-1 | DEBIAN-CVE-2024-1597 |
| Debian 13 | libpgjava | Fixed | 42.7.2-1 | DEBIAN-CVE-2024-1597 |
| Debian 12 | libpgjava | Fixed | 42.5.5-0+deb12u1 | DEBIAN-CVE-2024-1597 |
| Red Hat Enterprise Linux 9 | postgresql-jdbc | Fixed Will not fix | 0:42.2.28-1.el9_3 | RHSA-2024:1436 |
| Red Hat Enterprise Linux 8 | postgresql-jdbc | Fixed Will not fix | 0:42.2.14-3.el8_9 | RHSA-2024:1435 |
| Red Hat Enterprise Linux 8 | postgresql-jdbc-javadoc | Fixed Will not fix | 0:42.2.14-3.el8_9 | RHSA-2024:1435 |
| Red Hat Enterprise Linux 7 | postgresql-jdbc | Not affected | ||
| Red Hat Enterprise Linux 7 | postgresql-jdbc-javadoc | Not affected | ||
| Red Hat Enterprise Linux 6 | postgresql-jdbc | Not affected | ||
| AlmaLinux 9 | postgresql-jdbc | Fixed | 42.2.28-1.el9_3 | ALSA-2024:1436 |
| AlmaLinux 8 | postgresql-jdbc | Fixed | 42.2.14-3.el8_9 | ALSA-2024:1435 |
| AlmaLinux 8 | postgresql-jdbc-javadoc | Fixed | 42.2.14-3.el8_9 | ALSA-2024:1435 |
| Rocky Linux 9 | postgresql-jdbc | Fixed | 0:42.2.28-1.el9_3 | RLSA-2024:1436 |
| Rocky Linux 8 | postgresql-jdbc | Fixed | 0:42.2.14-3.el8_9 | RLSA-2024:1435 |
| Alpine Linux 3.24 | java-postgresql-jdbc | Fixed | 42.6.2-r0 | ALPINE-CVE-2024-1597 |
| Alpine Linux 3.23 | java-postgresql-jdbc | Fixed | 42.6.2-r0 | ALPINE-CVE-2024-1597 |
| Alpine Linux 3.22 | java-postgresql-jdbc | Fixed | 42.6.2-r0 | ALPINE-CVE-2024-1597 |
| Alpine Linux 3.21 | java-postgresql-jdbc | Fixed | 42.6.2-r0 | ALPINE-CVE-2024-1597 |
| Alpine Linux 3.20 | java-postgresql-jdbc | Fixed | 42.6.2-r0 | ALPINE-CVE-2024-1597 |
| Alpine Linux 3.19 | java-postgresql-jdbc | Fixed | 42.6.2-r0 | ALPINE-CVE-2024-1597 |
| Maven library | org.postgresql:postgresql | Fixed | 42.7.2 | GHSA-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.
- pgjdbc: affected: < 42.7.2, < 42.6.1, < 42.5.5, < 42.4.4, < 42.3.9, < 42.2.28
Workaround: Don't use SimpleQuery mode
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
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.