Redact credentials in DatabaseMetaData.getURL() and parse errors#1502
Open
sreekanth-db wants to merge 1 commit into
Open
Redact credentials in DatabaseMetaData.getURL() and parse errors#1502sreekanth-db wants to merge 1 commit into
sreekanth-db wants to merge 1 commit into
Conversation
getURL() returned the connection URL verbatim, exposing any secret embedded in it (PWD, Auth_AccessToken, OAuth2Secret, etc.); the same raw URL was embedded in parse-error messages. Secret parameter values are now masked while the URL is otherwise unchanged. The internal raw URL and all connection/auth/query flows are untouched. Co-authored-by: Isaac Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DatabaseMetaData.getURL()returned the connection URL verbatim, so any secret embedded in the URL (e.g.PWD,Auth_AccessToken,OAuth2Secret) was exposed to callers; the same raw URL was also embedded in connection parse-error messages. This masks the values of secret-bearing parameters while leaving the rest of the URL unchanged.This aligns with other JDBC drivers — PostgreSQL strips sensitive values from
getURL(), and the SQL Server driver omits credentials. The JDBC spec only requires "the URL for this DBMS", with no obligation to include credentials.Changes
DatabricksConnectionContext.redactConnectionURL(...): masks values of secret params (case-insensitive keys), preserving URL structure and all non-secret params. Used bygetURL()and the "Invalid url" parse exception.getConnectionURL()is unchanged (raw), so connection/auth/query flows are unaffected; only the externally exposed surfaces are redacted.Compatibility
getURL()now returns masked secrets. Normal usage (reading the URL for display/logging) is unaffected; only the rare pattern of feedinggetURL()'s output back intogetConnection()to reconnect would need credentials supplied separately — matching PostgreSQL JDBC behavior.Testing
DatabricksConnectionContextTest,DatabricksDatabaseMetaDataTest— all pass (381 tests).getURL()).Full detail tracked privately in the associated security ticket.
This pull request and its description were written by Isaac.