Skip to content

Redact credentials in DatabaseMetaData.getURL() and parse errors#1502

Open
sreekanth-db wants to merge 1 commit into
databricks:mainfrom
sreekanth-db:fix/sec-20595-redact-url-credentials
Open

Redact credentials in DatabaseMetaData.getURL() and parse errors#1502
sreekanth-db wants to merge 1 commit into
databricks:mainfrom
sreekanth-db:fix/sec-20595-redact-url-credentials

Conversation

@sreekanth-db

Copy link
Copy Markdown
Collaborator

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 by getURL() and the "Invalid url" parse exception.
  • Internal getConnectionURL() is unchanged (raw), so connection/auth/query flows are unaffected; only the externally exposed surfaces are redacted.
  • Added unit tests.

Compatibility

getURL() now returns masked secrets. Normal usage (reading the URL for display/logging) is unaffected; only the rare pattern of feeding getURL()'s output back into getConnection() to reconnect would need credentials supplied separately — matching PostgreSQL JDBC behavior.

Testing

  • DatabricksConnectionContextTest, DatabricksDatabaseMetaDataTest — all pass (381 tests).
  • Manually verified against a live SQL warehouse (embedded token no longer returned by getURL()).

Full detail tracked privately in the associated security ticket.

This pull request and its description were written by Isaac.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant