/

CVE-2026-134842

Severity:

HIGH RISK

(8.1)

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

CVE-2026-134842

Awaiting Analysis

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

SQL injection and unintended execution of SQL statements

Severity:

HIGH RISK

(8.1)

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 incorrectly quote parameter values in simple query mode when the session's standard_conforming_strings setting changes or a cached parse is reused under a different setting. If an attacker can influence a parameter containing the relevant quote and backslash characters, the value may escape its intended SQL literal and be interpreted as SQL.

Affected context

The issue affects pgjdbc when preferQueryMode=simple is used and parameter values are rendered into SQL statements. Risk arises when standard_conforming_strings changes during a session or a statement cache reuses a parse made under a different setting. With allowEncodingChanges=true, the EUC_JP and SJIS client encodings can also make the yen sign act as a backslash. The description identifies versions before 42.7.15 as affected; earlier behavior also depended on the session setting and query conditions.

Exploit preconditions

  • Attack surface: SQL statements issued through pgjdbc in simple query mode.
  • Required access: An attacker must be able to influence a value supplied as a query parameter; the description does not establish that database access is unauthenticated.
  • Trigger point: The driver quotes the parameter while the session setting or cached parse state differs from the state used for quoting.
  • Why exploitation is possible: The value can end its intended SQL literal, causing subsequent content to be parsed as SQL.
  • Additional condition: The encoding-related case involves allowEncodingChanges=true with EUC_JP or SJIS client encoding.

Why this happens

The driver's quoting behavior can rely on a stale or incorrect understanding of standard_conforming_strings. In simple query mode, parameter values are inserted into SQL text, so incorrect escaping can change the boundary between data and SQL syntax. This is a CWE-89: SQL Injection flaw: input intended as data can instead affect the structure of a database query.

Potential impact

  • An attacker who can influence affected parameter values could cause unintended SQL statements to run.
  • Depending on database permissions and query context, this could expose, alter, or delete data.
  • Database-side effects could disrupt application workflows or affect other users.

General mitigation guidance

Defensive patterns include:

  • Prefer protocol modes that transmit parameter values separately from SQL text rather than relying on client-side literal quoting.
  • Keep session settings that affect parsing and quoting consistent, and avoid changing them unexpectedly during a session.
  • Treat statement-cache entries as valid only for the session state under which they were created.
  • Restrict encoding changes and use configurations that avoid the described encoding ambiguity.
  • Apply least-privilege database roles so that query execution has only the permissions required by the application.

How teams detect issues like this

  • Use static analysis and code review to identify simple query mode and code paths that interpolate or quote parameter values into SQL text.
  • Review session-setting changes, statement-cache behavior, and configurations that enable encoding changes with EUC_JP or SJIS.
  • Enforce application policies that prefer separately bound parameters and restrict risky driver or connection settings.
  • Test query handling across relevant session-setting and encoding states; automated security review tools may help identify suspicious patterns.

Sources

SourceLink
github.comgithub.com/pgjdbc/pgjdbc/security/advisories/GHSA-6rxc-3r4p-gpff

Frequently asked

questions

It concerns pgjdbc parameter quoting in simple query mode when session settings or cached parse state cause quoting to use the wrong assumptions. The described encoding case applies with allowEncodingChanges=true and EUC_JP or SJIS.

An attacker must be able to influence a parameter value processed by an affected query path. The exact access required depends on how the application accepts and validates input.

Prefer query execution modes that send parameters separately from SQL text, and keep parsing-related session state consistent.

Avoid client-side SQL literal construction where possible, review driver and connection settings, test state changes and cache behavior, and use least-privilege database roles.

Find out what's already
exploitable in your codebase.