Postgresql Jdbc DriverDatabase / datastore · PostgreSQL

CVE-2024-1597

CRITICAL · 9.8 CVSS v3.1 Published 2024-02-19
Fix available
A fix is available. Upgrade to 42.2.28 / 42.3.9 or later.
See remediation →
100/100
Remediation priority · Urgent
Remotely reachable No privileges Zero-click

Official description Straight from the sourceThe vendor's or NVD's own wording, published unedited. Authoritative, but often terse — it says what broke, rarely what to do.

NVD · unedited
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.

Technical summary Written by usOur analysis, written from the advisory, the CVSS vector and the affected-version data. It adds context the advisory leaves out, and never invents facts that are not in the source.

dbcve analysis · high confidence

The PostgreSQL JDBC Driver (pgjdbc) has a SQL injection vulnerability when PreferQueryMode=SIMPLE is enabled. An attacker can inject malicious SQL by crafting a payload where a numeric parameter placeholder is preceded by a minus sign and followed by a string placeholder on the same line, bypassing the protections of parameterized queries.

MitigationUpgrade pgjdbc to version 42.7.2, 42.6.1, 42.5.5, 42.4.4, 42.3.9, or 42.2.28 or later. If upgrading is not immediately possible, avoid using PreferQueryMode=SIMPLE.

Verify against the referenced sources before acting — the references below are authoritative for this CVE, this summary is not.

Affected products & versions What the vendor confirmedThe version ranges the vendor confirmed as vulnerable. If your version sits inside a range here, treat yourself as exposed until you have upgraded.

NVD · CPE data
Postgresql Jdbc DriverDatabase / datastore
Affected:< 42.2.28>= 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
FedoraOperating system
Affected:= 40

CVSS breakdown How the score is builtThe industry scoring standard. It rates how the flaw is reached, what it takes to exploit, and what an attacker gains — the score is derived from those, not the other way round.

From the vector
Attack vector
Network
Complexity
Low
Privileges
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Am I affected? How to checkSteps we derive from the advisory and the affected-version data, so you can decide whether this CVE reaches your setup. They are a guide, not a scan — your own configuration is the authority.

dbcve checks

Work through these to decide whether this CVE applies to you.

  1. Identify pgjdbc driver version
    Locate the pgjdbc jar file in your application classpath or dependencies (typically named pgjdbc-*.jar or managed via Maven/Gradle dependencies). Check the filename or manifest for the version number.
    Affected if The version is less than 42.2.28, or between 42.3.0-42.3.8, 42.4.0-42.4.3, 42.5.0-42.5.4, 42.6.0-42.6.0, or 42.7.0-42.7.1.
  2. Check PreferQueryMode connection property
    Review your JDBC connection string or data source configuration for the property PreferQueryMode. Look for PreferQueryMode=SIMPLE in your connection parameters.
    Affected if PreferQueryMode is explicitly set to SIMPLE.
  3. Verify connection property source
    Inspect all configuration files, environment variables, or application code where JDBC connection properties are defined to confirm whether PreferQueryMode=SIMPLE is in use.
    Affected if PreferQueryMode=SIMPLE is found in any connection configuration.

Your environment is affected if you use a pgjdbc version within the affected ranges AND have PreferQueryMode=SIMPLE enabled in your JDBC connection configuration.

Generated from the published advisory. Verify against your own configuration.

Check your environment

Paste your version and any relevant configuration and it will be compared against the affected criteria above. Do not include secrets or credentials.

AI-assisted, checked against the advisory. Informational, not a guarantee.

Remediation Closing itWhat it takes to close this. Where a vendor fix exists we point at it; where none exists we say so plainly, and can build one. Effort estimates are scoped from the advisory, not from your codebase.

dbcve · scoped
Upgrade available Upgrade to 42.2.28 / 42.3.9 / 42.4.4 or later
Fixed in 42.2.2842.3.942.4.4
Interim mitigation

Upgrade pgjdbc to version 42.7.2, 42.6.1, 42.5.5, 42.4.4, 42.3.9, or 42.2.28 or later. If upgrading is not immediately possible, avoid using PreferQueryMode=SIMPLE.

Recommended fix High confidence

42.7.2 or latest stable 42.x release (e.g., 42.7.3, 42.8.0)

  1. Identify all project build configurations that contain the PostgreSQL JDBC Driver dependency (pom.xml, build.gradle, package.json, or direct JAR references)
  2. For Maven projects: Update the pgjdbc version in pom.xml to 42.7.2 or later: <dependency><groupId>org.postgresql</groupId><artifactId>postgresql</artifactId><version>42.7.2</version></dependency>
  3. For Gradle projects: Update the dependency to implementation 'org.postgresql:postgresql:42.7.2'
  4. For direct JAR deployment: Download the new driver JAR from https://jdbc.postgresql.org/download/ and replace the existing pgjdbc driver in your classpath
  5. Rebuild the project and run tests to verify the upgrade does not break existing functionality
  6. Redeploy the updated application
Caveat Review release notes for potential behavioral changes between your current version and 42.7.x; test thoroughly in non-production first

Generated from the published advisory — verify against the referenced sources before acting.

Fix this in Postgresql Jdbc Driver Scoped from the published advisory
  • Consultation4.0 h
  • Implementation2.0 h
  • Testing8.0 h
  • Review / QA2.0 h
16.0 hours of engineering $2,720
Get the upgrade done

An estimate, not a bill — we confirm scope with you before any work starts. Need it this week? Rush from $4,352.

Scan for this in your stack

Free · runs locally
dbcve dependency scanner

Check whether your project pulls in CVE-2024-1597 — or any other known-vulnerable package — straight from your lock files. Free and open source; it runs locally and uploads nothing.

References Go to the primary sourcePrimary sources — vendor advisories, patches and trackers. Where our summary and a reference disagree, the reference wins.

Primary sources

Practitioner notes

Contributed

Peer-ranked notes from engineers who’ve handled CVE-2024-1597 in production — separate from our analysis above.

No notes yet

Be the first to add a field note for this CVE — a mitigation you’ve verified, a version caveat, or a link to a working fix. Sign in above to contribute.

What this is

A place for practitioners to share what actually worked: a mitigation you’ve tested, a configuration change, a version- or environment-specific caveat, or a link to a verified patch. The most useful notes rise to the top as peers upvote them, so the signal stays high.

What belongs here
  • Verified mitigations, workarounds, and config changes
  • Version or environment caveats, and links to real fixes
  • No weaponised exploit code, or anything meant to cause harm
  • No spam, self-promotion, credentials, or personal data