-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8362268 : NPE thrown from SASL GSSAPI impl when TLS is used with QOP auth-int against Active Directory #26566
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
base: master
Are you sure you want to change the base?
Conversation
…ed with QOP auth-int against Active Directory
👋 Welcome back wxiao! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
|
Webrevs
|
The bug title says "Java 11+" but the affects version field also contains 8u401 - does it also affect 8u? In general, I would avoid putting release versions in the title of the bug as the affects version field is the right place to add that info, so please remove "on Java 11+" from the title. |
Since this fix in the security-libs area, I think the component and subcomponent should be changed to security-libs/javax.security. Also, please add a "noreg-hard" label to the bug with a comment explaining why it is too hard to write a regression test. |
Original report in OpenJDK mail list mentioned it could not be duplicated in jdk8, but actually the defect exists also in JDK8. The failure only happened when Sasl.QOP set with the value of auth-int or auth-conf. It needs a ldap server with the setting of SASL authentication. It is not available in OpenJDK community. |
I am the reporter of this bug in the mailing list. @seanjmullan, yes it is also present in JDK 8. confirmed myself on HP-UX where the JDK is provided by HPE. They have either cherry-picked the faulty commit or used an already updated tree. @weibxiao I do not fully understand this fix. It does not really fix the issue, does it? It converts one NPE into another. From my PoV the regression should be reverted and another, better fix should be employed. As @wangweij writes here, let LDAP complete the |
My "here" was
However, I'm not sure if this correct. This means the security guaranteed by the SASL layer is lost and I also don't know if the peer can parse it correctly. @michael-o What have JDK 8 and |
I can not revert the previous change. It will close the unused sockets in JVM before next GC to clean them. Once simple fix in application cod for this NPE is increasing buffer size by setting javax.security.sasl.maxbuffer in the context to overwrite the hard coded buffer size in AbstractSaslImpl.java. This NPE is more or less related to the timing. The context was cleared earlier than output stream got flush, but the later code is actually running earlier, but completed later. |
I will get back to you tomorrow or Monday as soon as I have access to the environment. |
I see.
No, that will not solve the problem here at all. Active Directory does not support auth-int/-conf on a TLS wrapped connection. It sends a message to notify the client. The client (Java JNDI) does not know this and reads the first bytes assuming the SASL buffer size, but it is a non-wrapped message. I can provide pcaps, if you like.
Yes, but how will this change solve the problem? Do you intend to add another PR to address it? |
JDK 8 is here: Create a TLS connection to Active Directory, bind with SASL GSSAPI and
libldap does properly signal in the invalid buffer size and shows the I think I have described the issue quite well in https://mail.openjdk.org/pipermail/security-dev/2025-April/045574.html. pcap and keylog file are available for inspection. The opposite side does not send an |
So, it seems we should NOT revert to the raw stream. We can either return earlier in |
I agree that if the opposite side did close the connection without properly advertising it and we try to send a request and it fails, it should be clearly signalled to the user. |
Let LDAP client implementation to close the resource associated with Connection. It allows SASL client to handle failure message. |
webrev.zip
NPE thrown from SASL GSSAPI impl on Java 11+ when TLS is used with QOP auth-int against Active Directory.
When the exception is triggered, LDAP Connection will do "clean-up" operation and output stream get flushed and closed the context while GssKrb5Client is still wrapping the message and SaslOuput Stream is writing the content of the buffer; and at the time GSSContext is disposed and it is null. That's the reason to throw NPE.
No test file is attached for this MR since it needs Sasl LDAP server with security setup. Attached webrev for the reference.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26566/head:pull/26566
$ git checkout pull/26566
Update a local copy of the PR:
$ git checkout pull/26566
$ git pull https://git.openjdk.org/jdk.git pull/26566/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26566
View PR using the GUI difftool:
$ git pr show -t 26566
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26566.diff
Using Webrev
Link to Webrev Comment