Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed illegal reflection access in kerberos authentication #839

Merged
merged 45 commits into from
Oct 27, 2018

Conversation

lilgreenbird
Copy link
Contributor

@lilgreenbird lilgreenbird commented Oct 20, 2018

  1. Removed illegal reflection access, DNSKerberosLocator will handle validation
  2. removed unused test

@codecov-io
Copy link

codecov-io commented Oct 20, 2018

Codecov Report

Merging #839 into dev will increase coverage by 0.29%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##                dev     #839      +/-   ##
============================================
+ Coverage     48.29%   48.58%   +0.29%     
- Complexity     2781     2790       +9     
============================================
  Files           116      116              
  Lines         27877    27867      -10     
  Branches       4651     4649       -2     
============================================
+ Hits          13462    13539      +77     
+ Misses        12200    12127      -73     
+ Partials       2215     2201      -14
Flag Coverage Δ Complexity Δ
#JDBC42 48.09% <0%> (+0.28%) 2748 <0> (+8) ⬆️
#JDBC43 48.49% <0%> (+0.26%) 2786 <0> (+7) ⬆️
Impacted Files Coverage Δ Complexity Δ
...crosoft/sqlserver/jdbc/dns/DNSKerberosLocator.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...m/microsoft/sqlserver/jdbc/KerbAuthentication.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...om/microsoft/sqlserver/jdbc/ReaderInputStream.java 43.95% <0%> (-3.3%) 15% <0%> (ø)
...m/microsoft/sqlserver/jdbc/SQLServerException.java 75.93% <0%> (-1.51%) 30% <0%> (-1%)
...m/microsoft/sqlserver/jdbc/SQLServerResultSet.java 32.46% <0%> (-0.31%) 253% <0%> (-3%)
...soft/sqlserver/jdbc/SQLServerDatabaseMetaData.java 33.49% <0%> (+0.15%) 63% <0%> (+1%) ⬆️
.../microsoft/sqlserver/jdbc/SQLServerConnection.java 48.09% <0%> (+0.17%) 335% <0%> (+1%) ⬆️
...oft/sqlserver/jdbc/SQLServerPreparedStatement.java 51.96% <0%> (+0.18%) 212% <0%> (ø) ⬇️
...rc/main/java/com/microsoft/sqlserver/jdbc/dtv.java 62.23% <0%> (+0.23%) 0% <0%> (ø) ⬇️
...om/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java 52.58% <0%> (+0.24%) 264% <0%> (+3%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5167636...aa6e18e. Read the comment docs.

@lilgreenbird lilgreenbird changed the title Kerb Removed Illegal reflection access Oct 21, 2018
@lilgreenbird lilgreenbird changed the title Removed Illegal reflection access Removed illegal reflection access in kerberos authentication Oct 21, 2018
@cheenamalhotra cheenamalhotra added this to the 7.1.2 milestone Oct 23, 2018
@@ -350,8 +315,8 @@ private String findRealmFromHostname(RealmValidator realmValidator, String hostn
int index = 0;
while (index != -1 && index < hostname.length() - 2) {
String realm = hostname.substring(index);
if (authLogger.isLoggable(Level.FINEST)) {
authLogger.finest(toString() + " looking up REALM candidate " + realm);
if (authLogger.isLoggable(Level.FINER)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make it consistent with the rest of the logging in this file

if (realmName.startsWith(".")) {
realmName = realmName.substring(1);
}
try {
Set<DNSRecordSRV> records = DNSUtilities.findSrvRecords("_kerberos._udp." + realmName);
return !records.isEmpty();
} catch (NameNotFoundException wrongDomainException) {
// config error - domain controller can not be located via DNS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot

@@ -30,13 +32,15 @@ public static boolean isRealmValid(String realmName) throws NamingException {
if (realmName == null || realmName.length() < 2) {
return false;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this

@pierresouchay
Copy link
Contributor

This code removal will break Kerberos cross DC authentication on many JVMs, most notably on Windows

@ulvii
Copy link
Contributor

ulvii commented Jan 29, 2019

Hi @pierresouchay,

Starting from JDK 9, users get a massive warning in their applications complaining about illegal reflective access when doing Kerberos authentication. Unfortunately, it seemed like there was no alternative that would let us preserve the same functionality and we removed the piece of code that contained the reflection. It is, however in our backlog to revisit PR #40 in the future and we would appreciate if you could give us suggestions on how to achieve the same functionality without illegal reflective access.

I should also mention that, the removal of reflection did not break any tests in our test lab and it would be really helpful if you guided us to reproduce the regression with exact test scenario and environment details.

@pierresouchay
Copy link
Contributor

@ulvii Yes, I explained a bit the reason, but it is clear it will break the feature. I will blacklist next versions of the driver in our company then. See my comments here: #918 (comment)

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.

7 participants