high

CVE

CVE-2026-134841, CVE-2026-134842, CVE-2026-134843, CVE-2026-134844, CVE-2026-134845, CVE-2026-134846, CVE-2026-134847, CVE-2026-134848

CWE

CWE-89, CWE-319, CWE-74, CWE-427

Affected Surface

  • Maven `org.postgresql:postgresql` (pgjdbc) 42.7.14 and earlier; fixed in 42.7.15
  • Java and JVM applications that use the PostgreSQL JDBC driver directly or through Hibernate, Spring Data JPA, jOOQ, MyBatis, Flyway, Liquibase and similar tools, when they build SQL text with JDBC escapes or run in `preferQueryMode=simple`

TL;DR

pgjdbc, the PostgreSQL JDBC driver, rewrites SQL text before sending it. It turns JDBC escapes such as {ts '2024-01-01'} and {fn right(a, 2)} into PostgreSQL syntax, finds ? placeholders, and splits multi-statement strings. To do that safely it has to know where every string literal, quoted identifier, dollar quote and comment begins and ends. Version 42.7.15 fixes several places where it got that wrong, and the result each time was the same: text that the application had quoted correctly was treated as SQL.

The two worst issues share CVSS 3.1 8.1:

  • CVE-2026-134841 (GHSA-4743-5rfh-f7mp) covers the parser. A } inside a literal ended a {d}, {t}, {ts}, {oj} or {escape} escape, dollar quotes with non-ASCII tags weren’t recognised, a doubled quote inside E'' confused the scanner, and {fn right()} and {fn timestampdiff()} could produce -- from a negative argument. Escape processing is on by default, so the first case affects ordinary Statement code that splices escaped user input into an escape.
  • CVE-2026-134842 (GHSA-6rxc-3r4p-gpff) only matters with preferQueryMode=simple, where the driver writes parameter values into the SQL text itself. It escaped them for the last standard_conforming_strings value it had seen, and an earlier statement, a trigger or a config reload could change the setting underneath it. Then \' ended the literal.

The release fixes 12 more advisories. Six have CVEs: a half-written message left on the socket after an unchecked exception (7.5), catalog metadata queries that ran operators from other roles’ schemas (7.5), ssl=1, ssl=on or ssl=verify-full silently meaning sslmode=prefer (7.4), NUL bytes in the database name or options injecting startup parameters (7.4), GSS encryption that a forged packet could switch off (6.5), and BigDecimal values stored as a different number (6.5). The other six are low or moderate denial of service and hardening fixes with GHSA IDs only. The pgjdbc team published all the advisories on 23 November, about two hours after the release, and the PostgreSQL CNA published the CVE records the same afternoon. Nothing suggests exploitation, there are no EPSS scores yet, and none of the CVEs are in CISA KEV.

What to do now:

  1. Upgrade org.postgresql:postgresql to 42.7.15. Spring Boot pins the driver version through its dependency management, so set postgresql.version to 42.7.15 rather than waiting for a Boot release.
  2. Test anything that sets ssl= without sslmode=. Values other than true, false or empty now refuse to connect. Replace them with an explicit sslmode=verify-full (or the mode you actually want).
  3. Search your code for user input concatenated into SQL that contains {ts, {d, {t, {fn or {oj, and for preferQueryMode=simple in connection strings. Those are the places where the two injection bugs could be reached. Move them to PreparedStatement parameters in the default extended query mode.

Affected packages and projects

EcosystemPackageAffected versionsFixed or safe version
Mavenorg.postgresql:postgresqlAll versions through 42.7.14 (CVE-2026-134841, CVE-2026-134842, CVE-2026-134843, CVE-2026-134844, CVE-2026-134848)42.7.15
Mavenorg.postgresql:postgresql9.4.1208 to 42.7.14 for the ssl values; 42.3.2 to 42.7.14 for service in Properties; 42.2.6 to 42.7.14 for BaseDataSource.setUrl() (CVE-2026-134845)42.7.15
Mavenorg.postgresql:postgresql42.2.15 to 42.7.14 (GSS encryption, CVE-2026-134846); 42.3.0 to 42.7.14 (BigDecimal, CVE-2026-134847)42.7.15

42.7.15 is the only fixed version; the advisories list no backports to older branches. Before 42.7.6 the simple-mode escaping always assumed standard_conforming_strings was on, so on those versions any session with the setting off was affected by CVE-2026-134842.

AdvisoryCVECVSS 3.1Issue
GHSA-4743-5rfh-f7mpCVE-2026-1348418.1Quoted text parsed as SQL in JDBC escapes, dollar quotes and E'' strings
GHSA-6rxc-3r4p-gpffCVE-2026-1348428.1Simple mode quotes for the wrong standard_conforming_strings value
GHSA-cww3-qmc2-mjmrCVE-2026-1348437.5Half-written message left on the connection after an unchecked exception
GHSA-j75g-99q3-vr5cCVE-2026-1348447.5Catalog queries can run objects of other database roles
GHSA-3mrw-838h-x9j9CVE-2026-1348457.4TLS not enforced for some ssl, service and DataSource settings
GHSA-36wf-f6m2-v42mCVE-2026-1348487.4Startup parameter injection through embedded NUL characters
GHSA-hcjc-54fp-2p42CVE-2026-1348466.5GSS encryption accepts replayed packets and can stop encrypting
GHSA-cjcw-9r77-4gwmCVE-2026-1348476.5BigDecimal outside the binary numeric range stored as a different number
GHSA-5hpm-qxj5-h4wwNone5.9Column label interner slows down with colliding labels
GHSA-79c7-9m5j-vqqv, GHSA-fpmr-jv7c-hwff, GHSA-fxh3-3646-629r, GHSA-8f43-r57c-hghq, GHSA-52f2-8qjr-7mw4None3.1 to 3.7CPU and memory exhaustion from server data, ALPN not checked with sslNegotiation=direct, URL properties through a DataSource server name, external DTDs with some SAX drivers, repeated SCRAM derivation

Technical analysis

CVE-2026-134841: a brace inside a literal ended the escape

In Parser.parseSql(), the escape states had their own small loop that copied characters until the first }. That loop didn’t know about quotes. The advisory’s proof of concept shows why doubling the quotes doesn’t help:

String since = "2024-01-01 }{fn locate($$ */ $$,$$ is null)::int))) UNION SELECT token FROM api_keys --$$,{oj (/*";
stmt.executeQuery("SELECT 1 WHERE now() >= {ts '" + since.replace("'", "''") + "'}");
// The escape ends at the } inside the literal, and the UNION SELECT runs.

The application escaped every quote in since, and the value contains none anyway. The driver reads {ts '2024-01-01 }, closes the escape at the } inside the literal, and keeps parsing the rest of the value as SQL. The {fn locate(...)} escape that follows gets translated, which moves where the literal ends, and the UNION SELECT that was meant to be data runs against the server as the application’s database role.

The fix (5d71308630d3) moves the escape states into the same branch as normal SQL, so literals, quoted identifiers, dollar quotes and comments are copied whole and only a brace outside them closes the escape:

       switch (state) {
         case IN_SQLCODE:
+        case ESC_DATE:
+        case ESC_TIME:
+        case ESC_TIMESTAMP:
+        case ESC_FUNCTION_END:
+        case ESC_OUTERJOIN:
+        case ESC_ESCAPECHAR:
+          // A brace inside a literal, quoted identifier or comment does not end an escape.
           if (c == '$') {
             int i0 = i;
             i = parseDollarQuotes(sql, i);
@@
+          } else if (state != SqlParseState.IN_SQLCODE) {
+            if (c == '}') {
+              state = SqlParseState.IN_SQLCODE; // end of escape code.
+              break;
+            }
           } else if (c == '(') { // begin nested sql
@@
         case ESC_FUNCTION:
           i = escapeFunction(sql, i, newsql, stdStrings);
-          state = SqlParseState.IN_SQLCODE; // end of escaped function (or query)
-          break;
-        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);
-          }
+          state = SqlParseState.ESC_FUNCTION_END;
           break;

An unterminated literal inside an escape now fails in the driver instead of being passed through. Three more commits close the other cases in the same advisory: the parser accepts the same non-ASCII dollar-quote tag characters as the server, an E'' string with a doubled quote is scanned as one escape string (1db316b69e1f), and {fn right()} and {fn timestampdiff()} wrap the subtracted argument in parentheses so - and a negative argument can’t form -- (77f378ddf05e):

-        .append(")+1-")
+        .append(")+1-(")
 ...
-    return buf.append("))").toString();
+    return buf.append(")))").toString();

CVE-2026-134842: escaping for a setting that had changed

In the default extended query mode, parameters travel separately from the SQL and quoting never comes into it. With preferQueryMode=simple, pgjdbc writes each value into the query text as a literal. When it believed standard_conforming_strings was on, it doubled quotes and left backslashes alone, which is correct for that setting. If the server’s setting was actually off, the server treats \' as an escaped quote, the literal keeps going, and the rest of the value becomes SQL:

// preferQueryMode=simple, autocommit off
PreparedStatement ps = conn.prepareStatement("SET LOCAL standard_conforming_strings = off; SELECT ?");
ps.setString(1, "\\'), (SELECT $$injected$$) --");
ps.execute(); // The subquery runs as SQL.

An earlier statement in the same query or batch, a trigger or a configuration reload can all change the setting without the driver hearing about it before it builds the next literal. The fix (b417fae54d95) stops relying on the driver’s copy of the setting. Any value containing a backslash is sent as an E'' literal, which the server reads the same way under either setting:

-  private static String quoteAndCast(String text, @Nullable String type, boolean standardConformingStrings) {
+  private static String quoteAndCast(String text, @Nullable String type) {
     StringBuilder sb = new StringBuilder((text.length() + 10) / 10 * 11); // Add 10% for escaping.
-    sb.append("('");
+    // The driver's standard_conforming_strings can be out of date when the backend parses the
+    // literal, so a value with a backslash is sent as E'' which reads the same either way.
+    boolean hasBackslash = text.indexOf('\\') >= 0;
+    sb.append(hasBackslash ? "(E'" : "('");
     try {
-      Utils.escapeLiteral(sb, text, standardConformingStrings);
+      Utils.escapeLiteral(sb, text, !hasBackslash);

Two related fixes are in the same advisory. Cached statements parsed under the other setting are no longer reused (a simple-mode statement with a parameter and a backslash that was prepared before the change now fails with SQLState 55000). And with allowEncodingChanges=true and an EUC_JP or Shift_JIS client encoding, the JDK encodes the yen sign U+00A5 as byte 0x5C, which is a backslash to the server, so the driver now escapes it too.

The TLS and startup fixes

Two of the other fixes change behaviour you may notice when you upgrade. Before 42.7.15, ssl=1, ssl=on, ssl=yes, ssl=require or ssl=verify-full without an sslmode silently gave sslmode=prefer. That mode carries on without TLS if the peer refuses it and accepts any certificate, so a connection string that looked strict was not (CVE-2026-134845). Those values now fail with “Invalid ssl value” and SQLState 08001. The same advisory covers a service passed in Properties being ignored along with the sslmode in its pg_service.conf entry, and BaseDataSource.setUrl() keeping an older sslmode when called a second time.

The startup message is a list of NUL-terminated strings, so a NUL in the database name, currentSchema or options (or %00 in a URL) ended the value early and let the rest set other parameters such as user or replication (CVE-2026-134848). The driver now refuses such values with SQLState 22023.

IOCs

There are no malicious packages or attacker infrastructure. Signs that someone probed the injection bugs:

  • Values reaching the database layer containing }{fn, {oj, or $$ followed by SQL keywords such as UNION SELECT
  • In simple-mode applications, parameter values beginning with \' or a yen sign followed by '
  • PostgreSQL logs (log_statement = 'all' or log_min_error_statement) showing statements whose literal ends early and is followed by UNION, SELECT ... FROM on tables the application doesn’t query, or a trailing --

Detection and remediation

Find the driver version in your builds:

# Maven
mvn -q dependency:tree -Dincludes=org.postgresql:postgresql

# Gradle
./gradlew dependencyInsight --dependency org.postgresql:postgresql --configuration runtimeClasspath

# Fat jars and container images
find / -name 'postgresql-42.*.jar' 2>/dev/null
unzip -l app.jar | grep 'postgresql-42'

Pin the fixed version:

<!-- Maven, plain -->
<dependency>
  <groupId>org.postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>42.7.15</version>
</dependency>

<!-- Spring Boot parent or BOM -->
<properties>
  <postgresql.version>42.7.15</postgresql.version>
</properties>
// Gradle with the Spring dependency-management plugin
extra["postgresql.version"] = "42.7.15"

Find code and configuration that can reach the two injection bugs:

# String-built SQL that contains JDBC escapes
rg -n --type java '"[^"]*\{(ts|d|t|fn|oj|escape)\b[^"]*"\s*\+'

# Simple query mode, and ssl= values the new release rejects
rg -n 'preferQueryMode=simple|preferQueryMode"\s*,\s*"simple'
rg -n 'ssl=(1|on|yes|require|verify-full|verify-ca)\b' --glob '*.{properties,yml,yaml,xml,java,kt,env}'

Then run your integration tests against 42.7.15 and look for “Invalid ssl value” (SQLState 08001) and SQLState 55000 from simple-mode statements prepared before a standard_conforming_strings change. If logs show a successful injection, rotate the credentials of the database role the application uses, and any secrets stored in tables that role can read.

Timeline

  • 2026-10-07: pgjdbc 42.7.14 is released.
  • 2026-11-21: The parser and quoting fixes are committed to pgjdbc master, with commit messages citing OSS Scanner report IDs.
  • 2026-11-23 14:01 UTC: pgjdbc 42.7.15 is published on GitHub and Maven Central.
  • 2026-11-23 15:46 to 15:51 UTC: The pgjdbc repository publishes 14 security advisories.
  • 2026-11-23: The PostgreSQL CNA publishes CVE-2026-134841 to CVE-2026-134848, and NVD receives them at 17:17 UTC. No EPSS scores, no exploitation reported, and none in CISA KEV.

From research to remediation

Check whether this pattern exists in your codebase

Turn this research into a remediation workflow. Scan dependencies and package manifests for similar supply-chain risk, then prioritize fixes with reachability context.

References