Repository navigation
fix(spanner): redact connection URI secrets in ConnectionOptions - #15321
Draft
sakthivelmanii wants to merge 2 commits into
Draft
sakthivelmanii wants to merge 2 commits into
sakthivelmanii wants to merge 2 commits into
Conversation
## Problem Statement - `ConnectionOptions` retained raw `oauthToken`, `encodedCredentials`, and `password` query parameters from connection URIs, exposing them through `ConnectionOptions.getUri()`, `toString()`, warning logs, exception messages, and JVM heap memory. - Malformed valueless URI segments (such as the tail of a secret containing an unescaped `;` or `?`) were echoed verbatim in validation errors and warnings. - Sensitive startup credential properties were only partially cleared from connection state after initialization, leaving raw secrets retained in reset values and on unused authentication branches. ## Solution - Redact `oauthToken`, `encodedCredentials`, and `password` query parameter values (and malformed valueless URI segments) with `REDACTED` when constructing `ConnectionOptions`, so `getUri()`, `toString()`, logs, and error messages never expose raw secrets while preserving authentication behavior. - Replace raw text of malformed valueless URI tokens with `REDACTED` in URI property validation errors and warnings while keeping unknown `key=value` property diagnostics intact. - Unconditionally clear both current and reset values for `oauthToken`, `encodedCredentials`, and `password` from initial connection state across all authentication paths once credentials are constructed.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive sanitization and redaction of sensitive connection properties (such as oauthToken, encodedCredentials, and password) within ConnectionOptions and ConnectionState. It adds a redactUri helper to replace sensitive values and malformed segments in URIs with REDACTED, and ensures that raw secrets are unconditionally cleared from the initial connection state to prevent them from remaining on the heap. Additionally, extensive unit tests have been added across multiple test classes to verify that secrets are correctly redacted in URIs, exceptions, warnings, logs, and connection properties. There are no review comments to address, and the implementation looks solid.
sakthivelmanii
marked this pull request as draft
December 1, 2026 14:19
This branch has not been deployed
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.
Problem Statement
ConnectionOptionsretained rawoauthToken,encodedCredentials, andpasswordquery parameters from connection URIs, exposing them throughConnectionOptions.getUri(),toString(), warning logs, exception messages, and JVM heap memory.Solution
oauthToken,encodedCredentials, andpasswordquery parameter values withREDACTEDwhen constructingConnectionOptions(rebuilding from parsed URI tokens when a sensitive parameter is present, and returning URIs without secrets unchanged), sogetUri(),toString(), logs, and error messages never expose raw secrets while preserving authentication behavior.oauthToken,encodedCredentials, andpasswordfrom initial connection state across all authentication paths once credentials are constructed.