JDK-8151788 : NullPointerException from ntlm.Client.type3
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 8u73,9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2016-03-01
  • Updated: 2020-10-12
  • Resolved: 2016-07-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9 Other
8u251Fixed 9 b128Fixed openjdk8u272Fixed
Description
FULL PRODUCT VERSION :
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux daisy.blackducksoftware.com 2.6.32-573.12.1.el6.x86_64 #1 SMP Tue Dec 15 21:19:08 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
and other Linux variants

A DESCRIPTION OF THE PROBLEM :
Attempting to create a connection to an NTLM proxy fails with a NullPointerException from the JRE.

NTLM Client: Type 1 created
0000: 4E 54 4C 4D 53 53 50 00������ 01 00 00 00 07 82 08 00������NTLMSSP.........
0010: 00 00 00 00 00 00 00 00������ 00 00 00 00 00 00 00 00������................

NTLM Client: Type 2 received
0000: 4E 54 4C 4D 53 53 50 00������ 02 00 00 00 00 00 00 00������NTLMSSP.........
0010: 00 00 00 00 05 82 89 00������ 0B 87 81 B6 2D 6E 8B C1������............-n..
0020: 00 00 00 00 00 00 00 00������ 00 00 00 00 00 00 00 00������................

java.lang.RuntimeException: java.lang.NullPointerException
������������������������at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1455)
������������������������at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
������������������������at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2979)
������������������������at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:489)
������������������������at com.blackduck.proxy.TestProxyHttpUrlConnection.connect(TestProxyHttpUrlConnection.java:43)
������������������������at com.blackduck.proxy.TestProxyHttpUrlConnection.main(TestProxyHttpUrlConnection.java:31)
Caused by: java.lang.NullPointerException
������������������������at com.sun.security.ntlm.Client.type3(Client.java:161)
������������������������at sun.net.www.protocol.http.ntlm.NTLMAuthentication.buildType3Msg(NTLMAuthentication.java:241)
������������������������at sun.net.www.protocol.http.ntlm.NTLMAuthentication.setHeaders(NTLMAuthentication.java:216)
������������������������at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1607)
������������������������at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
������������������������at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
������������������������... 2 more

Inspecting the code Client.type3() assumes that NTLM.readSecurityBuffer will never return null, but it will return null if the optional target information is not present.

REGRESSION.  Last worked in version 7u80

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Connect to an http proxy that returns NTLM challenge data shown above.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The connection attempt should succeed if valid credentials are supplied.
ACTUAL -
NullPointerException

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.RuntimeException: java.lang.NullPointerException
������������������������at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1455)
������������������������at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
������������������������at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2979)
������������������������at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:489)
������������������������at com.blackduck.proxy.TestProxyHttpUrlConnection.connect(TestProxyHttpUrlConnection.java:43)
������������������������at com.blackduck.proxy.TestProxyHttpUrlConnection.main(TestProxyHttpUrlConnection.java:31)
Caused by: java.lang.NullPointerException
������������������������at com.sun.security.ntlm.Client.type3(Client.java:161)
������������������������at sun.net.www.protocol.http.ntlm.NTLMAuthentication.buildType3Msg(NTLMAuthentication.java:241)
������������������������at sun.net.www.protocol.http.ntlm.NTLMAuthentication.setHeaders(NTLMAuthentication.java:216)
������������������������at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1607)
������������������������at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
������������������������at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
������������������������... 2 more

REPRODUCIBILITY :
This bug can be reproduced always.


Comments
8u Fix Request: I would like to backport this patch to 8u, as Oracle parity. The original patch applies cleanly after file path change. However, I modified the new test, removed its @modules annotation. 8u patch has been reviewed: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2020-June/011979.html
16-06-2020