Enhancement: Harden getReference() to omit sensitive connection properties from JNDI Reference - #2992
Merged
Muskan Gupta (muskan124947) merged 1 commit intoJul 24, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens SQLServerDataSource#getReference() so that sensitive credential-bearing connection properties are omitted from the returned JNDI Reference, reducing the risk of information exposure (CWE-200) when JNDI references are persisted or inspected.
Changes:
- Add a sensitive-property filter (
isSensitiveReferenceProperty) that omits known credential properties and any property names ending withpassword/secretfromgetReferenceInternal. - Add unit tests asserting that sensitive properties are not serialized into the JNDI
Reference.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java | Adds denylist + suffix-based filtering to prevent credential properties from being added to the JNDI Reference. |
| src/test/java/com/microsoft/sqlserver/jdbc/unit/SQLServerDataSourceReferenceSecurityTest.java | Adds regression/unit tests to validate sensitive property omission behavior. |
…rties from JNDI Reference Replaced the narrow substring-based password filter in getReferenceInternal() with an explicit denylist of credential-bearing property names (password, accessToken, keyStoreSecret, keyVaultProviderClientKey, clientKeyPassword, AADSecurePrincipalSecret) plus suffix-based defense-in-depth for properties ending in 'password' or 'secret'. Added unit tests validating the filtering behavior.
Muskan Gupta (muskan124947)
force-pushed
the
users/muskgupta/fix-datasource-reference-secret-leak
branch
from
July 23, 2026 09:48
a8a081e to
04c5043
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2992 +/- ##
============================================
+ Coverage 59.25% 59.35% +0.10%
- Complexity 5046 5079 +33
============================================
Files 153 153
Lines 36350 36368 +18
Branches 6650 6654 +4
============================================
+ Hits 21538 21588 +50
+ Misses 11053 11046 -7
+ Partials 3759 3734 -25 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Mahendra Chavan (machavan)
approved these changes
Jul 24, 2026
Ananya Garg (Ananya2)
approved these changes
Jul 24, 2026
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.
Enhancement
SQLServerDataSource.getReference()now uses an explicit denylist and suffix-based matching to ensure credential-bearing connection properties are never serialized into the JNDIReferenceobject.Problem
The previous implementation relied on a single
propertyName.contains("password")check (case-sensitive substring match) to filter properties. This missed several sensitive properties that were added over time:accessTokenkeyStoreSecretkeyVaultProviderClientKeyclientKeyPassword(capital P — not caught by substring "password")AADSecurePrincipalSecretChanges
SQLServerDataSource.java— Replaced the fragile substring check with:SENSITIVE_REFERENCE_PROPERTIESset containing all known credential property names (case-insensitive lookup)isSensitiveReferenceProperty()helper that also applies suffix matching (*password,*secret) as defense-in-depth for future propertiesSQLServerDataSourceReferenceSecurityTest.java(new) — Unit tests (no SQL Server required) verifying:serverName,databaseName,user) are preservedTesting
mvn clean test -P jre21 -Dtest=SQLServerDataSourceReferenceSecurityTest— 2 tests pass