CVE-2026-134848
Patch Available.
This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.
Overview
The PostgreSQL JDBC Driver (pgJDBC) is the open-source JDBC driver that lets Java programs connect to a PostgreSQL database using standard, database-independent Java code. It is a pure Java (Type 4) driver that speaks the PostgreSQL native network protocol. It is published to Maven Central as org.postgresql:postgresql, and Spring Boot 2.7 manages its 42.3 line.
A resource injection vulnerability (CVE-2026-134848) has been identified in the PostgreSQL JDBC Driver's connection startup, which allows attackers who control part of a JDBC URL or a connection property to inject additional startup parameters and override the database user, database or replication mode the application intended to use. The connection must still pass the server's authentication for the injected role, so the impact depends on the server's authentication configuration.
Per OWASP: This attack consists of changing resource identifiers used by an application in order to perform a malicious task. When an application defines a resource type or location based on user input, such as a file name or port number, this data can be manipulated to execute or access different resources.
This issue affects all versions of the PostgreSQL JDBC Driver before 42.7.15.
Details
Module Info
- Product: PostgreSQL JDBC Driver
- Affected packages:
org.postgresql:postgresql - Affected versions: <42.7.15
- GitHub repository: https://github.com/pgjdbc/pgjdbc
- Published packages: https://central.sonatype.com/artifact/org.postgresql/postgresql
- Package manager: Maven
- Fixed in:
- OSS PostgreSQL JDBC Driver 42.7.15
- NES for PostgreSQL JDBC Driver v42.3.13
Vulnerability Info
This High-severity vulnerability is found in the org.postgresql:postgresql package in all versions of the PostgreSQL JDBC Driver before 42.7.15.
When it opens a connection, the driver sends the server a StartupMessage, which is a list of NUL-terminated parameter names and values. ConnectionFactoryImpl.getParametersForStartup builds that list from the connection settings, copying the user, the database name and the ApplicationName, replication, currentSchema (sent as search_path) and options properties without checking their content:
private List<String[]> getParametersForStartup(String user, String database, Properties info) {
List<String[]> paramList = new ArrayList<String[]>();
paramList.add(new String[]{"user", user});
paramList.add(new String[]{"database", database});
// ...
String currentSchema = PGProperty.CURRENT_SCHEMA.get(info);
if (currentSchema != null) {
paramList.add(new String[]{"search_path", currentSchema});
}
String options = PGProperty.OPTIONS.get(info);
if (options != null) {
paramList.add(new String[]{"options", options});
}
return paramList;
}sendStartupPacket then writes the UTF-8 bytes of each name and value, each followed by a single NUL terminator:
for (byte[] encodedParam : encodedParams) {
pgStream.send(encodedParam);
pgStream.sendChar(0);
}Because a value may itself contain a NUL character, the server reads the bytes after it as further name and value pairs. A NUL can come from a property set by the application or from %00 in a JDBC URL, which the driver URL-decodes. PostgreSQL keeps the last occurrence of a repeated startup parameter, so an injected pair overrides the one the driver sent first. For example, an application that connects as appuser and takes currentSchema from untrusted input can be given the value public\0user\0postgres, and the server then sees user=postgres as the login role. The connection still has to authenticate as the injected role: with trust authentication it succeeds as any role, with scram-sha-256 it succeeds when the injected role has the same password, and with md5 it fails because the driver computes the password hash with the original user name. An injected replication=database or other startup parameter can also change the session's behavior or cause the connection to fail.
Mitigation
The PostgreSQL JDBC Driver's security policy ships security fixes by default only for the latest 42.x release line and for 42.2.x, and for other versions only upon request. Upstream has made no 42.3.x release since 42.3.10 (March 2024), so no 42.3.x release is available to address this issue. For more information, see here.
Users of the affected components should apply one of the following mitigations:
- Upgrade affected applications to a currently supported release of the PostgreSQL JDBC Driver that contains the fix.
- Leverage a commercial support partner like HeroDevs for post-EOL security support.
Credits
- Sehrope Sarkuni (finder)