# GHSA-4743-5RFH-F7MP: pgjdbc parses quoted text as SQL in JDBC escapes, dollar quotes and E strings

- Database: GitHub
- Severity: CVSS 8.1 (High)
- Published: 2026-11-23
- Modified: 2026-11-23

## Tracked as

- [CVE-2026-134841](https://cve.now/CVE-2026-134841.md): pgjdbc SQL injection in query parser for quoted text

## Affected versions

- org.postgresql:postgresql (Maven): through 42.7.14

## Description

### Summary

The pgjdbc query parser misread some quoted text. Text that the application quoted correctly could then run as SQL.

### Details

A `}` inside a string literal, quoted identifier, dollar quote or comment ended a `{d}`, `{t}`, `{ts}`, `{oj}` or `{escape}` escape. The driver then translated the rest of the literal as SQL. Doubling the quotes did not help.

The parser did not see a dollar quote whose tag had a non-ASCII symbol or space, such as `U+00A7`. It found placeholders and statement breaks in the quoted text. Escape processing could also create a closing tag.

After a doubled quote in an `E''` string, the driver read the rest as a standard string. A `\'` then ended the string for the driver but not for the server. In simple query mode a parameter value could then run as SQL.

`{fn right(a, b)}` and `{fn timestampdiff(t, b, c)}` wrote a minus sign before an argument. A negative argument made `--`, which commented out the rest of the line. Text after the next newline then ran as SQL, even inside a literal.

### Proof of concept

```java
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.
```


### Impact

An attacker who controls a value that the application quotes can run SQL as the application's database role. The value must be inside a JDBC escape, a dollar quote with such a tag, or an `E''` string with a doubled quote, or follow a negative `right` or `timestampdiff` argument. Escape processing is on by default. The `E''` case with parameters needs `preferQueryMode=simple`.

## References

- https://github.com/pgjdbc/pgjdbc/security/advisories/GHSA-4743-5rfh-f7mp

Page: https://cve.now/GHSA-4743-5RFH-F7MP

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
