/

CVE-2026-134841

Severity:

HIGH RISK

(8.1)

SQL Injection (CWE-89) in PostgreSQL JDBC Query Parser

CVE-2026-134841

Awaiting Analysis

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

SQL execution with the application's database role

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

A query-parser flaw in pgjdbc can cause certain quoted text to be reinterpreted as SQL instead of remaining a literal. If an attacker can influence text included in a query handled by the driver, the resulting SQL may execute with the privileges of the application's database role.

Affected context

The issue affects pgjdbc when its query parser processes particular quoting and escape patterns. Cases described include a closing brace inside a literal following a JDBC escape, dollar-quote tags containing a non-ASCII symbol or space, doubled quotes in E-strings, and negative arguments to {fn right} or {fn timestampdiff}. Versions before 42.7.15 are affected; the issue is fixed in 42.7.15.

Exploit preconditions

  • Attack surface: Application SQL statements processed by the PostgreSQL JDBC Driver.
  • Required access: An attacker must be able to influence text incorporated into a query that reaches the affected parser; database credentials are not necessarily required.
  • Trigger point: The driver parses a statement containing one of the affected quoting, escape, or function patterns.
  • Why exploitation is possible: Parser misclassification can cause text intended to remain quoted to be translated or interpreted as SQL, potentially changing the statement's meaning.

Why this happens

The query parser mishandles lexical boundaries in certain quoted strings, dollar-quoted strings, and JDBC escape expressions. As a result, correctly quoted application text may be treated as SQL syntax or may alter how subsequent text is parsed. This is an SQL injection weakness mapped to CWE-89, involving failure to preserve the distinction between data and executable query syntax.

Potential impact

  • An attacker may cause unintended SQL statements or expressions to execute.
  • Database records could be read, changed, or deleted within the application's role permissions.
  • Database operations or application workflows could be disrupted.
  • Access to other database resources may be possible if the application role has broad privileges.

General mitigation guidance

Defensive approaches focus on preserving a strict separation between query structure and data:

  • Use parameterized queries and avoid constructing SQL by concatenating untrusted text.
  • Prefer query APIs and parsing behavior that safely handle literals and escape syntax.
  • Reduce the amount of attacker-controlled content that enters SQL statements.
  • Apply least-privilege permissions to application database roles.
  • Review use of JDBC escape syntax and unusual quoting patterns where dynamic query construction is necessary.

How teams detect issues like this

  • Use static analysis to identify SQL built through string concatenation or other dynamic construction involving untrusted values.
  • Review code paths that combine user-controlled text with JDBC escape expressions or unusual string-literal forms.
  • Add regression tests for parser-sensitive quoting and escape cases, verifying that input remains data rather than changing query structure.
  • Enforce policies requiring parameterized queries and least-privilege database roles.
  • Automated code review tools can help flag risky query-construction patterns.

Sources

SourceLink
github.comgithub.com/pgjdbc/pgjdbc/security/advisories/GHSA-4743-5rfh-f7mp

Frequently asked

questions

Exploitation depends on an application sending attacker-influenced text through an affected pgjdbc query-parsing path. The resulting SQL runs with the application's database role's permissions.

Not necessarily. The key prerequisite is the ability to influence text incorporated into a query handled by the driver; the application's exposed inputs and query construction determine whether that is possible.

Keep query structure separate from data by using parameterized queries, and avoid composing SQL from untrusted strings.

Combine parameterized-query policies with review and testing of parser-sensitive quoting, static analysis of dynamic SQL construction, and least-privilege database roles.

Find out what's already
exploitable in your codebase.