/

CVE-2026-134843

Severity:

HIGH RISK

(7.5)

SQL Injection (CWE-89) in PostgreSQL JDBC Driver Protocol

CVE-2026-134843

Awaiting Analysis

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89, CWE-755

Impact:

SQL Injection

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

pgjdbc can leave a PostgreSQL protocol message incomplete when an unchecked exception interrupts a request, allowing later bytes sent on the same connection to be interpreted as SQL. If an attacker can influence data sent over a connection that is subsequently reused after such an interruption, this may enable SQL injection.

Affected context

The issue affects pgjdbc versions before 42.7.15 when an unchecked exception interrupts communication and the connection remains in use. The described triggers include certain repeated executions involving a setBinaryStream() value without a length, driver retries after SQLState 0A000 or 26000, and application-provided streams that throw unchecked exceptions. The resulting risk depends on whether the connection is reused and whether an attacker can influence later data sent through it.

Exploit preconditions

  • Attack surface: Application database requests sent through a pgjdbc connection
  • Required access: Ability to influence data or operations sent over a connection that is reused; the exact access depends on the application
  • Trigger point: An unchecked exception interrupts a request, including the described stream or driver-retry cases
  • Why exploitation is possible: The connection may retain part of a Bind message in its send buffer, so subsequent bytes can be interpreted by the server as the remainder of that message and potentially as SQL

Why this happens

An unchecked exception can interrupt request processing without the connection being safely closed or otherwise prevented from reuse. This leaves the PostgreSQL protocol stream out of sync: bytes from a later value may be consumed as part of an earlier Bind message. If those bytes can be interpreted as SQL, the behavior can lead to CWE-89: SQL Injection. The failure to handle exceptional conditions safely is also associated with CWE-755: Improper Handling of Exceptional Conditions.

Potential impact

  • A later value sent on the affected connection could be interpreted as SQL.
  • An attacker who can influence that value may be able to alter database operations.
  • Database data may be exposed, modified, or deleted, depending on the application's database privileges.
  • Application operations relying on the affected connection may fail or behave unexpectedly.

General mitigation guidance

Defensive patterns focus on preserving protocol integrity and reducing the trust and authority of database requests:

  • Treat a connection as unusable after an unchecked exception may have interrupted protocol communication; avoid returning potentially desynchronized connections to a pool.
  • Make error handling and retry logic ensure that retries cannot reuse a connection with uncertain protocol state.
  • Prefer APIs and stream-handling patterns that make input length and failure behavior explicit where practical.
  • Use parameterized queries and keep SQL structure separate from data.
  • Limit database account privileges to the operations the application requires.
  • Validate and constrain externally influenced data before it reaches database operations.

How teams detect issues like this

  • Review exception-handling and connection-pool paths for connections being reused after unchecked failures during request transmission.
  • Inspect retry logic, especially around database error states, for assumptions that a failed request leaves the connection synchronized.
  • Use static analysis or code review checks to identify stream-based parameter handling and SQL construction that mixes data with query structure.
  • Enforce policies for parameterized queries, safe connection lifecycle handling, and least-privilege database accounts.
  • Add tests that simulate unchecked stream failures and verify that affected connections are discarded rather than reused.

Sources

SourceLink
github.comgithub.com/pgjdbc/pgjdbc/security/advisories/GHSA-cww3-qmc2-mjmr

Frequently asked

questions

It is not described as an unauthenticated, standalone network attack. Exploitation depends on application behavior, including whether an affected connection is reused and whether an attacker can influence data sent through it.

The relevant prerequisite is the ability to influence operations or values sent over a connection that has encountered the triggering exception. How an attacker could obtain that influence depends on the application.

Do not reuse a connection when an exception may have left its protocol state uncertain. Ensure connection-pool and retry behavior preserves this rule.

Handle exceptional I/O paths defensively, test stream failures and retries, use parameterized queries, and limit database privileges.

Find out what's already
exploitable in your codebase.