Skip to content

Commit 4373385

Browse files
Merge pull request #182 from AikidoSec/fix-wrappers-and-fix-inet
Fix InetAddress issue with null and add logs on error to sys wrappers
2 parents 38611d5 + 14234f7 commit 4373385

File tree

7 files changed

+20
-12
lines changed

7 files changed

+20
-12
lines changed

agent/src/main/java/dev/aikido/agent/wrappers/InetAddressWrapper.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static class InetAdvice {
3434
// To bypass this issue we load collectors from a .jar file
3535
@Advice.OnMethodExit
3636
public static void after(
37-
@Advice.Enter String hostname,
37+
@Advice.Argument(0) String hostname,
3838
@Advice.Return InetAddress[] inetAddresses
3939
) throws Throwable {
4040
String jarFilePath = System.getProperty("AIK_agent_api_jar");
@@ -64,15 +64,9 @@ public static void after(
6464
throw invocationTargetException.getCause();
6565
}
6666
// Ignore non-aikido throwables.
67-
} catch(Throwable e) {}
68-
}
69-
@Advice.OnMethodEnter
70-
public static String before(
71-
@Advice.This(typing = DYNAMIC, optional = true) Object target,
72-
@Advice.Origin Executable method,
73-
@Advice.Argument(0) Object argument
74-
) {
75-
return argument.toString();
67+
} catch(Throwable e) {
68+
System.out.println("AIKIDO: " + e.getMessage());
69+
}
7670
}
7771
}
7872
}

agent/src/main/java/dev/aikido/agent/wrappers/PathWrapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public static void before(
7272
}
7373
// Ignore non-aikido throwables.
7474
} catch(Throwable e) {
75+
System.out.println("AIKIDO: " + e.getMessage());
7576
}
7677
classLoader.close(); // Close the class loader
7778
}

agent/src/main/java/dev/aikido/agent/wrappers/PathsWrapper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public static void before(
7171
throw invocationTargetException.getCause();
7272
}
7373
// Ignore non-aikido throwables.
74-
} catch(Throwable e) {}
74+
} catch(Throwable e) {
75+
System.out.println("AIKIDO: " + e.getMessage());
76+
}
7577
classLoader.close(); // Close the class loader
7678
}
7779
}

agent/src/main/java/dev/aikido/agent/wrappers/RuntimeExecWrapper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ public static void before(
7373
throw invocationTargetException.getCause();
7474
}
7575
// Ignore non-aikido throwables.
76-
} catch(Throwable e) {}
76+
} catch(Throwable e) {
77+
System.out.println("AIKIDO: " + e.getMessage());
78+
}
7779
}
7880
}
7981
}

agent/src/main/java/dev/aikido/agent/wrappers/file/FileConstructorMultiArgumentWrapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public static void before(
8484
}
8585
// Ignore non-aikido throwables.
8686
} catch (Throwable e) {
87+
System.out.println("AIKIDO: " + e.getMessage());
8788
}
8889
}
8990
}

agent/src/main/java/dev/aikido/agent/wrappers/file/FileConstructorSingleArgumentWrapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public static void before(
8282
}
8383
// Ignore non-aikido throwables.
8484
} catch (Throwable e) {
85+
System.out.println("AIKIDO: " + e.getMessage());
8586
}
8687
}
8788
}

agent_api/src/test/java/wrappers/InetAddressTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ public void testSSRFWithoutPort() throws Exception {
7676
assertEquals(1, StatisticsStore.getStatsRecord().operations().get("java.net.InetAddress.getAllByName").getAttacksDetected().get("blocked"));
7777
}
7878

79+
@Test
80+
public void testCanHandleNullInput() {
81+
assertDoesNotThrow(() -> {
82+
InetAddress.getAllByName(null);
83+
});
84+
}
85+
7986
@Test
8087
public void testSSRFWithoutPortAndWithoutContext() {
8188
setContextAndLifecycle("http://localhost:80");

0 commit comments

Comments
 (0)