CVE-2024-1597

10.0 CRITICAL

📋 TL;DR

This SQL injection vulnerability in the PostgreSQL JDBC Driver (pgjdbc) allows attackers to bypass parameterized query protections when using PreferQueryMode=SIMPLE configuration. Only applications using this non-default configuration are affected. Attackers can inject malicious SQL by crafting specific numeric and string parameter combinations.

💻 Affected Systems

Products:
  • PostgreSQL JDBC Driver (pgjdbc)
Versions: Versions before 42.7.2, 42.6.1, 42.5.5, 42.4.4, 42.3.9, and 42.2.28
Operating Systems: All operating systems running Java applications with pgjdbc
Default Config Vulnerable: ✅ No
Notes: Only vulnerable when PreferQueryMode=SIMPLE is explicitly configured (not the default). Applications using default configuration are not affected.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete database compromise including data theft, modification, deletion, or potential remote code execution on the database server.

🟠

Likely Case

Data exfiltration, unauthorized data modification, or privilege escalation within the database.

🟢

If Mitigated

No impact if using default configuration or properly patched versions.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: MEDIUM

Exploit requires specific parameter ordering and placement conditions but is well-documented in advisories.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 42.7.2, 42.6.1, 42.5.5, 42.4.4, 42.3.9, or 42.2.28 depending on your version line

Vendor Advisory: https://github.com/pgjdbc/pgjdbc/security/advisories/GHSA-24rp-q3w6-vc56

Restart Required: Yes

Instructions:

1. Identify your current pgjdbc version. 2. Upgrade to the patched version for your release line. 3. Restart all Java applications using the driver. 4. Verify the new version is in use.

🔧 Temporary Workarounds

Disable PreferQueryMode=SIMPLE

all

Switch to default configuration which is not vulnerable

Remove or change PreferQueryMode=SIMPLE configuration to default

Input validation for numeric parameters

all

Add server-side validation for numeric parameters to prevent injection

🧯 If You Can't Patch

  • Disable PreferQueryMode=SIMPLE configuration immediately
  • Implement strict input validation and sanitization for all database parameters

🔍 How to Verify

Check if Vulnerable:

Check if application uses PreferQueryMode=SIMPLE and pgjdbc version is below patched versions

Check Version:

Check Maven/Gradle dependencies or examine pgjdbc JAR file metadata

Verify Fix Applied:

Confirm pgjdbc version is 42.7.2, 42.6.1, 42.5.5, 42.4.4, 42.3.9, or 42.2.28 or higher

📡 Detection & Monitoring

Log Indicators:

  • Unusual SQL query patterns with minus signs before numeric parameters
  • Database errors from malformed queries
  • Unexpected query results

Network Indicators:

  • Unusual database query patterns from application servers

SIEM Query:

Search for database errors containing SQL syntax errors or unusual parameter patterns

🔗 References

📤 Share & Export