diff --git a/tools/aegis4j/build.gradle b/tools/aegis4j/build.gradle index 3d3d4ebeb2..b179618b11 100644 --- a/tools/aegis4j/build.gradle +++ b/tools/aegis4j/build.gradle @@ -30,7 +30,6 @@ dependencies { testImplementation('log4j:apache-log4j-extras:1.2.17') { exclude group: 'log4j', module: 'log4j' } - // testImplementation group: 'com.ea.agentloader', name: 'ea-agent-loader', version: '1.0.3' testImplementation "com.google.guava:guava:$guava_version" testImplementation "org.yaml:snakeyaml:1.33" } diff --git a/tools/aegis4j/src/test/java/net/gredler/aegis4j/CVE_2020_8908.java b/tools/aegis4j/src/test/java/net/gredler/aegis4j/CVE_2020_8908.java new file mode 100644 index 0000000000..0a526b16aa --- /dev/null +++ b/tools/aegis4j/src/test/java/net/gredler/aegis4j/CVE_2020_8908.java @@ -0,0 +1,30 @@ +/* Copyright (c) 2022, Daniel Gredler. All rights reserved. */ + +package net.gredler.aegis4j; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + +/** + * Tests Guava blocking. + */ +public class CVE_2020_8908 { + @AfterAll + public static void uninstallAgent() throws Exception { + System.clearProperty("aegis4j.additional.args"); + } + + @Test + public void test() throws Exception { + TestUtils.installAgent("path=../resources/test/guava-mods.properties"); + try { + com.google.common.io.Files.createTempDir(); + fail("Exception expected"); + } catch (RuntimeException e) { + assertEquals("Guava createTempDir blocked by aegis4j", e.getMessage()); + } + } +} diff --git a/tools/aegis4j/src/test/resources/guava-mods.properties b/tools/aegis4j/src/test/resources/guava-mods.properties new file mode 100644 index 0000000000..4646669410 --- /dev/null +++ b/tools/aegis4j/src/test/resources/guava-mods.properties @@ -0,0 +1,3 @@ +# format: ..= +# CVE-2020-8908 +GUAVA.com.google.common.io.Files.createTempDir=throw new java.lang.RuntimeException("Guava createTempDir blocked by aegis4j"); \ No newline at end of file