Skip to content

Commit

Permalink
feat: prevent path traversal when loading dump
Browse files Browse the repository at this point in the history
  • Loading branch information
diogotcorreia committed Jul 15, 2024
1 parent 075427a commit b4f7e99
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/src/main/java/com/rexcantor64/triton/debug/LoadDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public static List<Component> getMessagesFromDump(String dumpName, int startLine
Path dumpFolderPath = tritonFolderPath.resolve(DUMP_FOLDER_NAME);
Path dumpPath = dumpFolderPath.resolve(dumpName);

if (!dumpPath.toAbsolutePath().normalize().startsWith(dumpFolderPath.toAbsolutePath().normalize())) {
// path traversal attack
throw new IOException("Tried to access file outside dump folder");
}

File dumpFile = dumpPath.toFile();

@Cleanup
Expand Down

0 comments on commit b4f7e99

Please sign in to comment.