Skip to content

Commit 2f2867d

Browse files
Bugfix: Fixed security flaw with the Event Dispatch Thread, where robots could use the SwingUtilities.invokeLater() for running any code they should like
1 parent 1653bc7 commit 2f2867d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

robocode/robocode/security/RobocodeSecurityManager.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,21 @@ public void checkPermission(Permission perm) {
205205
return;
206206
} catch (SecurityException e) {}
207207

208-
// Allow the Event Dispatch Thread
208+
// Check if it was one of the tools for Robocode that was invoked by the Event Dispatch Thread
209209
if (javax.swing.SwingUtilities.isEventDispatchThread()) {
210-
return;
210+
StackTraceElement[] stackTrace = new Throwable().getStackTrace();
211+
212+
for (StackTraceElement element : stackTrace) {
213+
String classname = element.getClassName();
214+
String method = element.getMethodName();
215+
216+
if (classname.equals("codesize.Codesize") && method.equals("processZipFile")) {
217+
return;
218+
}
219+
if (classname.equals("ar.robocode.cachecleaner.CacheCleaner") && method.equals("clean")) {
220+
return;
221+
}
222+
}
211223
}
212224

213225
// For development purposes, allow read any file if override is set.

0 commit comments

Comments
 (0)