CVE-2026-134841

SQL Injection
Affects
PostgreSQL JDBC Driver
in
PostgreSQL JDBC Driver
No items found.
Versions
<42.7.15

Patch Available.

Exclamation circle icon
Patch Available

This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.

Overview

The PostgreSQL JDBC Driver (pgJDBC) is the open-source JDBC driver that lets Java programs connect to a PostgreSQL database using standard, database-independent Java code. It is a pure Java (Type 4) driver that speaks the PostgreSQL native network protocol. It is published to Maven Central as org.postgresql:postgresql, and Spring Boot 2.7 manages its 42.3 line.

A command injection vulnerability (CVE-2026-134841) has been identified in the PostgreSQL JDBC Driver's query parser, which allows attackers who control a value that the application quotes to inject SQL that runs with the privileges of the application's database role. The driver misreads quoted text inside JDBC escapes, in dollar quotes whose tag contains a non-ASCII symbol or a space, and in E'' strings with a doubled quote, and the {fn right} and {fn timestampdiff} escapes can turn a negative argument into a -- comment.

Per OWASP: A SQL injection attack consists of insertion or "injection" of a SQL query via the input data from the client to the application. A successful SQL injection exploit can read sensitive data from the database, modify database data (Insert/Update/Delete), execute administration operations on the database (such as shutdown the DBMS), recover the content of a given file present on the DBMS file system and in some cases issue commands to the operating system.

This issue affects all versions of the PostgreSQL JDBC Driver before 42.7.15.

Details

Module Info

Vulnerability Info

This High-severity vulnerability is found in the org.postgresql:postgresql package in all versions of the PostgreSQL JDBC Driver before 42.7.15. Before it sends a query, the driver rewrites it in org.postgresql.core.Parser: it translates JDBC escapes such as {ts '...'} and {fn ...}, and it finds parameter placeholders and statement boundaries. To do that, the parser has to know which parts of the text are quoted. In four places its idea of where a quoted value ends differs from the server's, so text that the application quoted correctly can be read as SQL.

First, inside a {d}, {t}, {ts}, {oj} or {escape} escape, Parser.parseSql ends the escape at the first } it sees, even when that } is inside a string literal, quoted identifier, dollar quote or comment. The rest of the literal is then translated as SQL. {fn ...} escapes copy everything up to the next } in the same way. Doubling the quotes in the value does not help:

case ESC_DATE:
case ESC_TIME:
case ESC_TIMESTAMP:
case ESC_OUTERJOIN:
case ESC_ESCAPECHAR:
  if (c == '}') {
    state = SqlParseState.IN_SQLCODE; // end of escape code.
  } else {
    newsql.append(c);
  }
  break;
// go to the end of the function copying anything found
i++;
while (i < sql.length && sql[i] != '}') {
  newsql.append(sql[i++]);
}

For example, an application that builds "SELECT 1 WHERE now() >= {ts '" + since.replace("'", "''") + "'}" ends the escape at a } placed inside since, and an attacker can append a UNION SELECT that the server runs.

Second, parseDollarQuotes decides which characters may form a dollar-quote tag through isIdentifierStartChar and isIdentifierContChar, which follow Java's identifier rules rather than PostgreSQL's. A tag that contains a non-ASCII symbol or space character (such as U+00A7) is therefore not recognized as a dollar quote, even though the server accepts it as one. The driver then finds placeholders and statement breaks inside the quoted text, and escape processing can create a closing tag:

public static boolean isIdentifierStartChar(char c) {
  return Character.isJavaIdentifierStart(c);
}

public static boolean isIdentifierContChar(char c) {
  return Character.isJavaIdentifierPart(c);
}

Third, parseSingleQuotes returns at the first ', and the caller calls it again for the part after a doubled quote. On that second call it decides whether backslashes are escapes from the character before the quote, so after a doubled quote in an E'' string the rest is scanned as a standard string. A \' then ends the string for the driver but not for the server. With preferQueryMode=simple, the driver inlines parameter values into the query text, so a parameter value can then run as SQL:

if (standardConformingStrings
    && offset >= 2
    && (query[offset - 1] == 'e' || query[offset - 1] == 'E')
    && charTerminatesIdentifier(query[offset - 2])) {
  standardConformingStrings = false;
}

Fourth, EscapedFunctions2.sqlright and sqltimestampdiff (and the matching methods in EscapedFunctions) write a bare minus sign in front of an argument. When that argument is negative, the output contains --, which comments out the rest of the line. Text after the next newline, even inside a literal, then runs as SQL:

buf.append("substring(");
buf.append(parsedArgs.get(0))
    .append(" from (length(")
    .append(parsedArgs.get(0))
    .append(")+1-")
    .append(parsedArgs.get(1));
buf.append("))");
buf.append("extract( ")
    .append(constantToDatePart(buf, parsedArgs.get(0).toString()))
    .append(" from (")
    .append(parsedArgs.get(2))
    .append("-")
    .append(parsedArgs.get(1))
    .append("))");

JDBC escape processing is on by default, so the escape, dollar-quote and {fn} cases need no special configuration. The E'' case with parameters requires preferQueryMode=simple.

Mitigation

The PostgreSQL JDBC Driver's security policy ships security fixes by default only for the latest 42.x release line and for 42.2.x, and for other versions only upon request. Upstream has made no 42.3.x release since 42.3.10 (March 2024), so no 42.3.x release is available to address this issue. For more information, see here.

Users of the affected components should apply one of the following mitigations:

  • Upgrade affected applications to a currently supported release of the PostgreSQL JDBC Driver that contains the fix.
  • Leverage a commercial support partner like HeroDevs for post-EOL security support.

Credits

  • Anthropic OSS Scanner (finder)
Vulnerability Details
Severity
Level
CVSS Assessment
Low
>=0 <4
Medium
>=4 <6
High
>=6 <8
Critical
>=8 <10
High
ID
CVE-2026-134841
PROJECT Affected
PostgreSQL JDBC Driver
Versions Affected
<42.7.15
NES Versions Affected
Published date
November 23, 2026
≈ Fix date
December 4, 2026
Category
SQL Injection
Vex Document
Download VEXHow do I use it?
Sign up for the latest vulnerability alerts fixed in
NES for PostgreSQL JDBC Driver
Rss feed icon
Subscribe via RSS
or

By submitting the form I acknowledge receipt of our Privacy Policy.

Thanks for signing up for our Newsletter! We look forward to connecting with you.
Oops! Something went wrong while submitting the form.