pg.ddx.io  GitHub: pgjdbc/pgjdbc (issues + PRs as email threads)  
help / color / mirror / Atom feed
From: vlsi (@vlsi) <noreply+vlsi@github.com>
To: pgjdbc/pgjdbc <noreply+pgjdbc-pgjdbc@github.com>
Subject: Re: [pgjdbc/pgjdbc] PR #4512: fix: mask credentials in the JDBC URLs the driver logs
Date: Thu, 05 Nov 2026 12:10:27 +0000
Message-ID: <gh-pgjdbc-pgjdbc-4512-rc4480244891@github.com> (raw)
In-Reply-To: <gh-pgjdbc-pgjdbc-4512@github.com>
References: <gh-pgjdbc-pgjdbc-4512@github.com>

(on pgjdbc/src/main/java/org/postgresql/util/PGPropertyUtil.java)

**major**: a password in the user-info part reaches a WARNING and the exception

libpq accepts `postgresql://alice:s3cret@db/app`, so users paste that form into a JDBC URL. `parseURL` splits the address at the last `:`, so the port becomes `s3cret@db`, and `propertiesConsistencyCheck` logs `JDBC URL invalid port number: s3cret@db` at `WARNING` (`PGPropertyUtil.java:78`), which the default JUL configuration prints. `Driver.connect` then throws `Unable to parse URL jdbc:postgresql://alice:s3cret@db/app`, because `maskSensitiveValues` returns a URL without `?` unchanged. `BaseDataSource.setUrl` throws `URL invalid jdbc:postgresql://alice:s3cret@db/app` after the same warning.

With an explicit port, `jdbc:postgresql://alice:s3cret@db:5432/app` parses, `setURL` accepts it, and the host becomes `alice:s3cret@db`. The password then reaches the `FINE` records `Connecting with URL: jdbc:postgresql://alice:s3cret@db:5432/app` and `Trying to establish a protocol version 3 connection to alice:s3cret@db:5432`, and the cause of the `PSQLException` the caller gets is `java.net.UnknownHostException: alice:s3cret@db`.

Please refuse an `@` in the host part in `parseURL`, with a message that says user info is not supported and names neither the user nor the password, and mask the user-info part (everything before the last `@` in the authority) in `maskSensitiveValues` for the `Unable to parse URL` and `URL invalid` messages. The port warnings can then keep the raw value, which is what makes a typo such as `54x2` easy to find. Tests with `jdbc:postgresql://alice:s3cret@db/app` and `jdbc:postgresql://alice:s3cret@db:5432/app` would cover both forms.

view thread (25+ messages)  latest in thread

Message-ID: <gh-pgjdbc-pgjdbc-4512-rc4480244891@github.com>
Permalink:  ../gh-pgjdbc-pgjdbc-4512-rc4480244891@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox