JDK-8066931 : SeedGenerator.getSystemEntropy() fails without network adapters
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 8u25
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86
  • Submitted: 2014-12-04
  • Updated: 2022-01-20
  • Resolved: 2022-01-20
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.
Other
tbdResolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.2.9200] (Azure)

EXTRA RELEVANT SYSTEM CONFIGURATION :
No network interfaces are available, i.e. "ipconfig" gives "Access denied"

A DESCRIPTION OF THE PROBLEM :
When running a Java website on Azure you don't have access to the network interfaces. Since http://hg.openjdk.java.net/jdk8u/jdk8u20/jdk/rev/c6836440c427 the way SecureRandom works is to add the network addresses to the seed hash which causes the application to not work when deployed on Azure. Because no a lot of applications use the SecureRandom class they cannot be used as an Azure web site with the current JDK version.

Stack trace:
Exception in thread "main" 
java.lang.Error: IP Helper Library GetIfTable function failed
	at java.net.NetworkInterface.getAll(Native Method)
	at java.net.NetworkInterface.getNetworkInterfaces(NetworkInterface.java:343)
	at sun.security.provider.SeedGenerator.addNetworkAdapterInfo(SeedGenerator.java:233)
	at sun.security.provider.SeedGenerator.access$000(SeedGenerator.java:80)
	at sun.security.provider.SeedGenerator$1.run(SeedGenerator.java:183)
	at sun.security.provider.SeedGenerator$1.run(SeedGenerator.java:168)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.security.provider.SeedGenerator.getSystemEntropy(SeedGenerator.java:168)
	at sun.security.provider.SecureRandom$SeederHolder.<clinit>(SecureRandom.java:201)
	at sun.security.provider.SecureRandom.engineNextBytes(SecureRandom.java:221)
	at java.security.SecureRandom.nextBytes(SecureRandom.java:457)
	at java.security.SecureRandom.next(SecureRandom.java:480)
	at java.util.Random.nextInt(Random.java:329)
	at com.example.Main.main(Main.java:9)

REGRESSION.  Last worked in version 7u51

ADDITIONAL REGRESSION INFORMATION: 
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The following application throws an exception on 8u25 but not 7u51:

package com.example;

import java.security.SecureRandom;

public class Main {
	public static void main(String[] args) {
		SecureRandom random = new SecureRandom();

		System.out.println("Random: " + random.nextInt());
	}
}


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should see a result "Random: 12345"
ACTUAL -
Exception in thread "main" 
java.lang.Error: IP Helper Library GetIfTable function failed
	at java.net.NetworkInterface.getAll(Native Method)
	at java.net.NetworkInterface.getNetworkInterfaces(NetworkInterface.java:343)
	at sun.security.provider.SeedGenerator.addNetworkAdapterInfo(SeedGenerator.java:233)
	at sun.security.provider.SeedGenerator.access$000(SeedGenerator.java:80)
	at sun.security.provider.SeedGenerator$1.run(SeedGenerator.java:183)
	at sun.security.provider.SeedGenerator$1.run(SeedGenerator.java:168)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.security.provider.SeedGenerator.getSystemEntropy(SeedGenerator.java:168)
	at sun.security.provider.SecureRandom$SeederHolder.<clinit>(SecureRandom.java:201)
	at sun.security.provider.SecureRandom.engineNextBytes(SecureRandom.java:221)
	at java.security.SecureRandom.nextBytes(SecureRandom.java:457)
	at java.security.SecureRandom.next(SecureRandom.java:480)
	at java.util.Random.nextInt(Random.java:329)
	at com.example.Main.main(Main.java:9)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package com.example;

import java.security.SecureRandom;

public class Main {
	public static void main(String[] args) {
		SecureRandom random = new SecureRandom();

		System.out.println("Random: " + random.nextInt());
	}
}

---------- END SOURCE ----------


Comments
This is fixed by JDK-8275319. The method now throws a SocketException, which is silently swallowed by the SeedGenerator.
20-01-2022

JDK-8065078 reports a similar issue, albeit triggered through ThreadLocalRandom. Another question: should SecureRandom be dependent on Networking code, see JDK-8066397, for a similar issue with TLR.
09-12-2014

Checked with 7u72 and 8u25 and couldn't reproduce the issue as claimed by the submitter.
09-12-2014