Skip to content

Commit ba37e3c

Browse files
authored
Disable DiagnosticTrustManager in FIPS 140 (#49888)
This commit changes the default behavior for xpack.security.ssl.diagnose.trust when running in a FIPS 140 JVM. More specifically, when xpack.security.fips_mode.enabled is true: - If xpack.security.ssl.diagnose.trust is not explicitly set, the default value of it becomes false and a log message is printed on info level, notifying of the fact that the TLS/SSL diagnostic messages are not enabled when in a FIPS 140 JVM. - If xpack.security.ssl.diagnose.trust is explicitly set, the value of it is honored, even in FIPS mode. This is relevant only for 7.x where we support Java 8 in which SunJSSE can still be used as a FIPS 140 provider for TLS. SunJSSE in FIPS mode, disallows the use of other TrustManager implementations than the one shipped with SunJSSE.
1 parent 6718ce0 commit ba37e3c

File tree

5 files changed

+38
-12
lines changed

5 files changed

+38
-12
lines changed

docs/reference/settings/security-settings.asciidoc

+1
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,7 @@ to establish trust.
15051505
This diagnostic message contains information that can be used to determine the
15061506
cause of the failure and assist with resolving the problem.
15071507
Set to `false` to disable these messages.
1508+
NOTE: This defaults to `false` when `xpack.security.fips_mode.enabled` is `true`.
15081509

15091510
==== Default values for TLS/SSL settings
15101511
In general, the values below represent the default values for the various TLS

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java

+3
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ private XPackSettings() {
140140
/** Setting for enabling or disabling vectors. Defaults to true. */
141141
public static final Setting<Boolean> VECTORS_ENABLED = Setting.boolSetting("xpack.vectors.enabled", true, Setting.Property.NodeScope);
142142

143+
public static final Setting<Boolean> DIAGNOSE_TRUST_EXCEPTIONS_SETTING = Setting.boolSetting(
144+
"xpack.security.ssl.diagnose.trust", true, Setting.Property.NodeScope);
145+
143146
public static final List<String> DEFAULT_SUPPORTED_PROTOCOLS;
144147

145148
static {

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLService.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.elasticsearch.common.Strings;
2020
import org.elasticsearch.common.logging.DeprecationLogger;
2121
import org.elasticsearch.common.logging.LoggerMessageFormat;
22-
import org.elasticsearch.common.settings.Setting;
2322
import org.elasticsearch.common.settings.Settings;
2423
import org.elasticsearch.common.ssl.DiagnosticTrustManager;
2524
import org.elasticsearch.common.ssl.SslDiagnostics;
@@ -72,6 +71,7 @@
7271
import java.util.stream.Collectors;
7372

7473
import static org.elasticsearch.xpack.core.XPackSettings.DEFAULT_SUPPORTED_PROTOCOLS;
74+
import static org.elasticsearch.xpack.core.XPackSettings.DIAGNOSE_TRUST_EXCEPTIONS_SETTING;
7575

7676
/**
7777
* Provides access to {@link SSLEngine} and {@link SSLSocketFactory} objects based on a provided configuration. All
@@ -103,9 +103,6 @@ public class SSLService {
103103
ORDERED_PROTOCOL_ALGORITHM_MAP = Collections.unmodifiableMap(protocolAlgorithmMap);
104104
}
105105

106-
private static final Setting<Boolean> DIAGNOSE_TRUST_EXCEPTIONS_SETTING = Setting.boolSetting(
107-
"xpack.security.ssl.diagnose.trust", true, Setting.Property.NodeScope);
108-
109106
private final Settings settings;
110107
private final boolean diagnoseTrustExceptions;
111108

@@ -143,7 +140,7 @@ public SSLService(Environment environment) {
143140
public SSLService(Settings settings, Environment environment) {
144141
this.settings = settings;
145142
this.env = environment;
146-
this.diagnoseTrustExceptions = DIAGNOSE_TRUST_EXCEPTIONS_SETTING.get(settings);
143+
this.diagnoseTrustExceptions = shouldEnableDiagnoseTrust();
147144
this.sslConfigurations = new HashMap<>();
148145
this.sslContexts = loadSSLConfigurations();
149146
}
@@ -152,7 +149,7 @@ private SSLService(Settings settings, Environment environment, Map<String, SSLCo
152149
Map<SSLConfiguration, SSLContextHolder> sslContexts) {
153150
this.settings = settings;
154151
this.env = environment;
155-
this.diagnoseTrustExceptions = DIAGNOSE_TRUST_EXCEPTIONS_SETTING.get(settings);
152+
this.diagnoseTrustExceptions = shouldEnableDiagnoseTrust();
156153
this.sslConfigurations = sslConfigurations;
157154
this.sslContexts = sslContexts;
158155
}
@@ -187,10 +184,6 @@ SSLContextHolder sslContextHolder(SSLConfiguration sslConfiguration) {
187184
};
188185
}
189186

190-
public static void registerSettings(List<Setting<?>> settingList) {
191-
settingList.add(DIAGNOSE_TRUST_EXCEPTIONS_SETTING);
192-
}
193-
194187
/**
195188
* Create a new {@link SSLIOSessionStrategy} based on the provided settings. The settings are used to identify the SSL configuration
196189
* that should be used to create the context.
@@ -852,4 +845,13 @@ private static String sslContextAlgorithm(List<String> supportedProtocols) {
852845
throw new IllegalArgumentException("no supported SSL/TLS protocol was found in the configured supported protocols: "
853846
+ supportedProtocols);
854847
}
848+
849+
private boolean shouldEnableDiagnoseTrust() {
850+
if (XPackSettings.FIPS_MODE_ENABLED.get(settings) && DIAGNOSE_TRUST_EXCEPTIONS_SETTING.exists(settings) == false ) {
851+
logger.info("diagnostic messages for SSL/TLS trust failures are not enabled in FIPS 140 mode by default.");
852+
return false;
853+
} else {
854+
return DIAGNOSE_TRUST_EXCEPTIONS_SETTING.get(settings);
855+
}
856+
}
855857
}

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ssl/SSLServiceTests.java

+21
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,27 @@ public void testDontWrapTrustManagerWhenDiagnosticsDisabled() {
822822
assertThat(sslService.wrapWithDiagnostics(baseTrustManager, sslConfiguration), sameInstance(baseTrustManager));
823823
}
824824

825+
public void testDontWrapTrustManagerByDefaultWhenInFips(){
826+
final Settings.Builder builder = Settings.builder();
827+
builder.put("xpack.security.fips_mode.enabled", true);
828+
final SSLService sslService = new SSLService(builder.build(), env);
829+
final X509ExtendedTrustManager baseTrustManager = TrustAllConfig.INSTANCE.createTrustManager(env);
830+
final SSLConfiguration sslConfiguration = sslService.getSSLConfiguration("xpack.security.transport.ssl");
831+
assertThat(sslService.wrapWithDiagnostics(baseTrustManager, sslConfiguration), sameInstance(baseTrustManager));
832+
}
833+
834+
public void testWrapTrustManagerWhenInFipsAndExplicitlyConfigured(){
835+
final Settings.Builder builder = Settings.builder();
836+
builder.put("xpack.security.fips_mode.enabled", true);
837+
builder.put("xpack.security.ssl.diagnose.trust", true);
838+
final SSLService sslService = new SSLService(builder.build(), env);
839+
final X509ExtendedTrustManager baseTrustManager = TrustAllConfig.INSTANCE.createTrustManager(env);
840+
final SSLConfiguration sslConfiguration = sslService.getSSLConfiguration("xpack.security.transport.ssl");
841+
final X509ExtendedTrustManager wrappedTrustManager = sslService.wrapWithDiagnostics(baseTrustManager, sslConfiguration);
842+
assertThat(wrappedTrustManager, instanceOf(DiagnosticTrustManager.class));
843+
assertThat(sslService.wrapWithDiagnostics(wrappedTrustManager, sslConfiguration), sameInstance(wrappedTrustManager));
844+
}
845+
825846
class AssertionCallback implements FutureCallback<HttpResponse> {
826847

827848
@Override

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ public static List<Setting<?>> getSettings(boolean transportClientMode, List<Sec
641641
// The following just apply in node mode
642642
settingsList.add(XPackSettings.FIPS_MODE_ENABLED);
643643

644-
SSLService.registerSettings(settingsList);
644+
settingsList.add(XPackSettings.DIAGNOSE_TRUST_EXCEPTIONS_SETTING);
645645
// IP Filter settings
646646
IPFilter.addSettings(settingsList);
647647

@@ -909,7 +909,6 @@ static void validateForFips(Settings settings) {
909909
validationErrors.add("Only PBKDF2 is allowed for password hashing in a FIPS 140 JVM. Please set the " +
910910
"appropriate value for [ " + XPackSettings.PASSWORD_HASHING_ALGORITHM.getKey() + " ] setting.");
911911
}
912-
913912
if (validationErrors.isEmpty() == false) {
914913
final StringBuilder sb = new StringBuilder();
915914
sb.append("Validation for FIPS 140 mode failed: \n");

0 commit comments

Comments
 (0)