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 insideE''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 ordinaryStatementcode 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 laststandard_conforming_stringsvalue 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:
- Upgrade
org.postgresql:postgresqlto 42.7.15. Spring Boot pins the driver version through its dependency management, so setpostgresql.versionto42.7.15rather than waiting for a Boot release. - Test anything that sets
ssl=withoutsslmode=. Values other thantrue,falseor empty now refuse to connect. Replace them with an explicitsslmode=verify-full(or the mode you actually want). - Search your code for user input concatenated into SQL that contains
{ts,{d,{t,{fnor{oj, and forpreferQueryMode=simplein connection strings. Those are the places where the two injection bugs could be reached. Move them toPreparedStatementparameters in the default extended query mode.
Affected packages and projects
| Ecosystem | Package | Affected versions | Fixed or safe version |
|---|---|---|---|
| Maven | org.postgresql:postgresql | All versions through 42.7.14 (CVE-2026-134841, CVE-2026-134842, CVE-2026-134843, CVE-2026-134844, CVE-2026-134848) | 42.7.15 |
| Maven | org.postgresql:postgresql | 9.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 |
| Maven | org.postgresql:postgresql | 42.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.
| Advisory | CVE | CVSS 3.1 | Issue |
|---|---|---|---|
| GHSA-4743-5rfh-f7mp | CVE-2026-134841 | 8.1 | Quoted text parsed as SQL in JDBC escapes, dollar quotes and E'' strings |
| GHSA-6rxc-3r4p-gpff | CVE-2026-134842 | 8.1 | Simple mode quotes for the wrong standard_conforming_strings value |
| GHSA-cww3-qmc2-mjmr | CVE-2026-134843 | 7.5 | Half-written message left on the connection after an unchecked exception |
| GHSA-j75g-99q3-vr5c | CVE-2026-134844 | 7.5 | Catalog queries can run objects of other database roles |
| GHSA-3mrw-838h-x9j9 | CVE-2026-134845 | 7.4 | TLS not enforced for some ssl, service and DataSource settings |
| GHSA-36wf-f6m2-v42m | CVE-2026-134848 | 7.4 | Startup parameter injection through embedded NUL characters |
| GHSA-hcjc-54fp-2p42 | CVE-2026-134846 | 6.5 | GSS encryption accepts replayed packets and can stop encrypting |
| GHSA-cjcw-9r77-4gwm | CVE-2026-134847 | 6.5 | BigDecimal outside the binary numeric range stored as a different number |
| GHSA-5hpm-qxj5-h4ww | None | 5.9 | Column 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-7mw4 | None | 3.1 to 3.7 | CPU 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 asUNION SELECT - In simple-mode applications, parameter values beginning with
\'or a yen sign followed by' - PostgreSQL logs (
log_statement = 'all'orlog_min_error_statement) showing statements whose literal ends early and is followed byUNION,SELECT ... FROMon 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
- pgjdbc release REL42.7.15 (23 November 2026)
- GHSA-4743-5rfh-f7mp: pgjdbc parses quoted text as SQL in JDBC escapes, dollar quotes and E strings
- GHSA-6rxc-3r4p-gpff: pgjdbc simple query mode quotes parameters for the wrong standard_conforming_strings value
- NVD: CVE-2026-134841
- NVD: CVE-2026-134842
- pgjdbc commit 5d71308630d3: do not end a JDBC escape at a brace inside a literal
- pgjdbc commit b417fae54d95: send simple mode string parameters with a backslash as E''
- GHSA-3mrw-838h-x9j9: pgjdbc does not enforce TLS for some ssl, service and DataSource settings
- GHSA-36wf-f6m2-v42m: Startup parameter injection via embedded NUL characters
- Maven Central: org.postgresql:postgresql