From 6ce0de9d05cf8ed64acd546a115fb2e94a393870 Mon Sep 17 00:00:00 2001 From: tkomlodi <6026319+tkomlodi@users.noreply.github.com> Date: Tue, 14 Nov 2023 10:05:31 -0500 Subject: [PATCH] Fixed file upload tmp directory creation when root directory is not writtable by application #449. --- .../vulnerability/fileupload/UnrestrictedFileUpload.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/sasanlabs/service/vulnerability/fileupload/UnrestrictedFileUpload.java b/src/main/java/org/sasanlabs/service/vulnerability/fileupload/UnrestrictedFileUpload.java index 0e05276f..adb5f95d 100644 --- a/src/main/java/org/sasanlabs/service/vulnerability/fileupload/UnrestrictedFileUpload.java +++ b/src/main/java/org/sasanlabs/service/vulnerability/fileupload/UnrestrictedFileUpload.java @@ -92,10 +92,10 @@ public UnrestrictedFileUpload() throws IOException, URISyntaxException { "If you are running vulnerableApp as a Jar then UnrestrictedFileUpload will not work. " + "For more information: https://github.com/SasanLabs/VulnerableApp/issues/255", e); - if (root != null) { + if (root == null || !root.toFile().exists()) { root = Files.createTempDirectory(null); } - if (contentDispositionRoot != null) { + if (contentDispositionRoot == null || !contentDispositionRoot.toFile().exists()) { contentDispositionRoot = Files.createTempDirectory(null); } }