CVE-2026-134842: pgjdbc simple query mode quotes parameters for the wrong standard_conforming_strings value
pgjdbc, the PostgreSQL JDBC Driver, can quote a string parameter for the wrong value of standardconformingstrings when preferQueryMode=simple is set. A statement, trigger or configuration reload can turn the setting off during a session. A parameter value with a backslash and a quote then ends the literal, and the rest of the value runs as SQL. Before 42.7.6 any session with the setting off was affected. The statement cache can also reuse a parse made under the other setting. With allowEncodingChanges=true and the EUCJP or SJIS client encoding, the yen sign acts as a backslash. All versions before 42.7.15 are affected, and 42.7.15 fixes the problem.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 42.7.15
Event History
Frequently Asked Questions
Which deployments are exposed to this issue?
Deployments using pgjdbc versions before 42.7.15 are affected when preferQueryMode=simple is set. The issue can be triggered if standard_conforming_strings is turned off during a session; before 42.7.6, any session with that setting off was affected.
What conditions are needed for SQL injection?
An attacker needs to control a string parameter containing both a backslash and a quote after the driver has quoted it for the wrong standard_conforming_strings setting. The quote can terminate the SQL literal and cause the remaining parameter content to execute as SQL.
Are there encoding-specific considerations?
Yes. With allowEncodingChanges=true and an EUC_JP or SJIS client encoding, a yen sign is treated as a backslash, which can satisfy the backslash condition.
What should be done if an immediate upgrade is not possible?
Avoid preferQueryMode=simple and prevent standard_conforming_strings from being turned off during sessions. Also avoid allowEncodingChanges=true with EUC_JP or SJIS client encodings.
What version fixes the issue?
pgjdbc 42.7.15 fixes the problem. All versions before 42.7.15 are affected.