GHSA-673j-qm5f-xpv8: Postgresql Pgjdbc Arbitrary File Write Vulnerability Vulnerability

MODERATE
Published
Advisory Summary

GHSA-673j-qm5f-xpv8 is a MODERATE pgjdbc arbitrary file write vulnerability vulnerability (General Security Weakness) affecting Postgresql libraries in the Maven ecosystem. The issue involves pgjdbc arbitrary file write vulnerability. Remediation is available by upgrading affected packages to version 42.3.3.

GHSA-673j-qm5f-xpv8 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-673j-qm5f-xpv8
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Postgresql
Package Ecosystem Maven
Published Date
Last Updated

How to Fix GHSA-673j-qm5f-xpv8

To remediate this vulnerability, upgrade all affected Postgresql dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

org.postgresql:postgresql fixed: 42.3.3
<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.3.3</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=org.postgresql

How to Check if You Are Affected

To determine whether your Java application is affected by GHSA-673j-qm5f-xpv8, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=org.postgresql

Analyze the terminal output to locate any version of Postgresql in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 42.3.3), your application is affected.

Note: The mvn dependency:tree -Dincludes=org.postgresql command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under General Security Weakness. In Postgresql, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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

GHSA-673j-qm5f-xpv8 Affected Postgresql Versions

1 component(s)
Fixed Versions:
42.3.3
Product / Package Ecosystem Affected Versions Fixed Version
org.postgresql:postgresql
Maven
≥ 42.1.0
< 42.3.3
42.3.3

References

Frequently Asked Questions

What is GHSA-673j-qm5f-xpv8?
GHSA-673j-qm5f-xpv8 is a security vulnerability in Postgresql involving pgjdbc Arbitrary File Write Vulnerability under General Security Weakness.
Which Postgresql versions are affected?
Affected versions include releases prior to 42.3.3 across affected packages: org.postgresql:postgresql.
What version fixes GHSA-673j-qm5f-xpv8?
Upgrading to 42.3.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is postgresql affected?
Yes, org.postgresql:postgresql is affected in releases prior to 42.3.3. Upgrade your dependency to 42.3.3 or later.
What CWE is associated with GHSA-673j-qm5f-xpv8?
GHSA-673j-qm5f-xpv8 is classified under General Security Weakness.
How can I check Maven dependencies for GHSA-673j-qm5f-xpv8?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.postgresql'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-673j-qm5f-xpv8",
  "modified" : "2024-01-22T19:35:00Z",
  "published" : "2022-02-16T00:08:18Z",
  "aliases" : [ ],
  "summary" : "pgjdbc Arbitrary File Write Vulnerability",
  "details" : "### Overview\nThe 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.\n\nIt'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.\n\nWhile 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.\n\nIf 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.\n\n### Impact\nIt is possible to specify an arbitrary filename in the loggerFileName connection parameter\n\"jdbc:postgresql://localhost:5432/test?user=test&password=test&loggerLevel=DEBUG&loggerFile=./blah.jsp&<%Runtime.getRuntime().exec(request.getParameter(\\\"i\\\"));%>\"\n\nThis creates a valid JSP file which could lead to a Remote Code Execution \n\n### Patches\nLoggerFile implementation has been removed and will be ignored by the driver, fixed in 42.3.3\n\n### Workarounds\nsanitize the inputs to the driver\n\nReported by Allan Lou v3ged0ge@gmail.com",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.postgresql:postgresql"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "42.1.0"
      }, {
        "fixed" : "42.3.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pgjdbc/pgjdbc/security/advisories/GHSA-673j-qm5f-xpv8"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pgjdbc/pgjdbc/commit/f6d47034a4ce292e1a659fa00963f6f713117064"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pgjdbc/pgjdbc"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-02-16T00:08:18Z",
    "nvd_published_at" : null
  }
}