Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public abstract class RunTask extends DefaultTestClustersTask {

private Boolean debug = false;
private Boolean cliDebug = false;
private Boolean entitlementsEnabled = false;

private Boolean apmServerEnabled = false;

private Boolean preserveData = false;
Expand Down Expand Up @@ -74,9 +74,7 @@ public void setCliDebug(boolean enabled) {
option = "entitlements",
description = "Use the Entitlements agent system in place of SecurityManager to enforce sandbox policies."
)
public void setEntitlementsEnabled(boolean enabled) {
this.entitlementsEnabled = enabled;
}
public void setEntitlementsEnabled(boolean enabled) {}

@Input
public Boolean getDebug() {
Expand All @@ -90,7 +88,7 @@ public Boolean getCliDebug() {

@Input
public Boolean getEntitlementsEnabled() {
return entitlementsEnabled;
return true;
}

@Input
Expand Down Expand Up @@ -240,9 +238,7 @@ else if (node.getSettingKeys().contains("telemetry.metrics.enabled") == false) {
if (cliDebug) {
enableCliDebug();
}
if (entitlementsEnabled) {
enableEntitlements();
}
enableEntitlements();
}

@TaskAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.jdk.RuntimeVersionFeature;

import java.io.IOException;
Expand All @@ -28,9 +27,8 @@ static List<String> systemJvmOptions(Settings nodeSettings, final Map<String, St
String distroType = sysprops.get("es.distribution.type");
String javaType = sysprops.get("es.java.type");
boolean isHotspot = sysprops.getOrDefault("sun.management.compiler", "").contains("HotSpot");
boolean entitlementsExplicitlyEnabled = Booleans.parseBoolean(sysprops.getOrDefault("es.entitlements.enabled", "true"));
// java 24+ only supports entitlements, but it may be enabled on earlier versions explicitly
boolean useEntitlements = RuntimeVersionFeature.isSecurityManagerAvailable() == false || entitlementsExplicitlyEnabled;

boolean useEntitlements = true;
return Stream.of(
Stream.of(
/*
Expand Down
8 changes: 8 additions & 0 deletions docs/changelog/125117.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pr: 125117
summary: "Permanently switch from Java SecurityManager to Entitlements.
The Java SecurityManager has been deprecated since Java 17, and it is now completely disabled in Java 24. In order
to retain an similar level of protection, Elasticsearch implemented its own protection mechanism, Entitlements.
Starting with this version, Entitlements will permanently replace the Java SecurityManager."
area: Infra/Core
type: upgrade
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
import org.apache.tika.parser.ParserDecorator;
import org.elasticsearch.SpecialPermission;
import org.elasticsearch.bootstrap.FilePermissionUtils;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.PathUtils;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.jdk.JarHell;
import org.elasticsearch.jdk.RuntimeVersionFeature;

import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -129,9 +127,7 @@ static String parse(final byte content[], final Metadata metadata, final int lim
: null;

private static boolean isUsingSecurityManager() {
boolean entitlementsEnabled = Booleans.parseBoolean(System.getProperty("es.entitlements.enabled"), false)
|| RuntimeVersionFeature.isSecurityManagerAvailable() == false;
return entitlementsEnabled == false;
return false;
}

// compute some minimal permissions for parsers. they only get r/w access to the java temp directory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.elasticsearch.common.transport.BoundTransportAddress;
import org.elasticsearch.common.util.concurrent.RunOnce;
import org.elasticsearch.core.AbstractRefCounted;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.CheckedConsumer;
import org.elasticsearch.core.IOUtils;
import org.elasticsearch.core.SuppressForbidden;
Expand Down Expand Up @@ -129,9 +128,8 @@ private static Bootstrap initPhase1() {
final PrintStream out = getStdout();
final PrintStream err = getStderr();
final ServerArgs args;
final boolean entitlementsEnabled = Booleans.parseBoolean(System.getProperty("es.entitlements.enabled", "true"));
// java 24+ only supports entitlements, but it may be enabled on earlier versions explicitly
final boolean useEntitlements = RuntimeVersionFeature.isSecurityManagerAvailable() == false || entitlementsEnabled;

final boolean useEntitlements = true;
try {
initSecurityProperties();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class ExampleSecurityExtension implements SecurityExtension {

static {
final boolean useEntitlements = Boolean.parseBoolean(System.getProperty("es.entitlements.enabled"));
final boolean useEntitlements = true;
if (useEntitlements == false && RuntimeVersionFeature.isSecurityManagerAvailable()) {
// check that the extension's policy works.
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
Expand Down
Loading