diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index 7b882b73..40a033bd 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -149,6 +149,7 @@ public static void addLauncherClassBindings(Map bindings) { public static void main(String... args) throws Throwable { JVMHelper.verifySystemProperties(Launcher.class, true); + EnvHelper.checkDangerousParametrs(); LogHelper.printVersion("Launcher"); // Start Launcher Instant start = Instant.now(); diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 044653ab..d00431ac 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -415,6 +415,7 @@ public static void main(String... args) throws Throwable { } checkJVMBitsAndVersion(); JVMHelper.verifySystemProperties(ClientLauncher.class, true); + EnvHelper.checkDangerousParametrs(); LogHelper.printVersion("Client Launcher"); // Read and delete params file LogHelper.debug("Reading ClientLauncher params"); diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/EnvHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/EnvHelper.java index 7e0406fe..057d799a 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/EnvHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/EnvHelper.java @@ -8,13 +8,10 @@ import ru.gravit.launcher.LauncherAPI; -@LauncherAPI public class EnvHelper { private static final boolean TST; private static final boolean HASXM; - @LauncherAPI public static final String[] toTest; - @LauncherAPI public static final Pattern[] test; static { @@ -24,7 +21,6 @@ public class EnvHelper { HASXM = check1(); } - @LauncherAPI public static void addEnv(ProcessBuilder builder) { if (hasOptsVar()) { Map repl = new HashMap<>(); @@ -35,6 +31,14 @@ public static void addEnv(ProcessBuilder builder) { JVMHelper.appendVars(builder, repl); } } + public static void checkDangerousParametrs() + { + for(String t : toTest) + { + String env = System.getenv(t); + if(env.contains("-javaagent") || env.contains("-agentpath") || env.contains("-agentlib")) throw new SecurityException("JavaAgent in global optings not allow"); + } + } private static boolean check0() { for (String test : toTest) if (System.getProperty(test) != null) return true;