diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java index 980ad55c6a..a9b2133113 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java @@ -1594,6 +1594,9 @@ public class ContentManagementServices { File file = new File(objectInfo); if (file.isFile()) { try { + // Check if a webshell is not uploaded + // This should now be useless after the add of SecuredUpload::isValidFile in GroovyBaseScript for createAnonFile service. + // But I prefer to keep it anyway, it's hard to test all cases, better safe than sorry if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(objectInfo, "All", delegator)) { errorMessage = UtilProperties.getMessage("SecurityUiLabels", "SupportedFileFormatsIncludingSvg", locale); } diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java index bb7539763f..5dd75a73be 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java @@ -460,6 +460,7 @@ public class DataServices { if (UtilValidate.isNotEmpty(textData)) { try (OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);) { out.write(textData); + // Check if a webshell is not uploaded if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(file.getAbsolutePath(), "Text", delegator)) { String errorMessage = UtilProperties.getMessage("SecurityUiLabels", "SupportedTextFileFormats", locale); return ServiceUtil.returnError(errorMessage); diff --git a/applications/product/config/catalog.properties b/applications/product/config/catalog.properties index 64244a3b05..f43ddc6961 100644 --- a/applications/product/config/catalog.properties +++ b/applications/product/config/catalog.properties @@ -21,7 +21,7 @@ # -- Image upload path on the server -#FIXME the image server path need to be move on runtime +#FIXME the image server path need to be moved on runtime image.server.path=${sys:getProperty('ofbiz.home')}/themes/common/images/webapp/images/${tenantId} # -- The prefix to put on auto-generated image urls (can be relative or absolute, whatever you want) @@ -37,7 +37,7 @@ all.product.category=CATALOG1 reactivate.product.from.receipt=Y # Image upload path on the image management -#FIXME the image management path need to be move on runtime +#FIXME the image management path need to be moved on runtime image.management.path=${sys:getProperty('ofbiz.home')}/themes/common/webapp/images/products/management image.management.url=/images/products/management image.management.nameofthumbnail=-100 diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/image/ScaleImage.java b/applications/product/src/main/java/org/apache/ofbiz/product/image/ScaleImage.java index cb8587d5a3..92ac0fa332 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/image/ScaleImage.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/image/ScaleImage.java @@ -224,6 +224,7 @@ public class ScaleImage { try { String fileToCheck = imageServerPath + "/" + newFileLocation + "." + imgExtension; ImageIO.write(bufNewImg, imgExtension, new File(fileToCheck)); + // Check if a webshell is not uploaded if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(fileToCheck, "Image", delegator)) { String errorMessage = UtilProperties.getMessage("SecurityUiLabels", "SupportedImageFormats", locale); return ServiceUtil.returnError(errorMessage); @@ -402,6 +403,7 @@ public class ScaleImage { try { String fileToCheck = imageServerPath + "/" + newFileLocation + "." + imgExtension; ImageIO.write(bufNewImg, imgExtension, new File(fileToCheck)); + // Check if a webshell is not uploaded if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(fileToCheck, "Image", delegator)) { String errorMessage = UtilProperties.getMessage("SecurityUiLabels", "SupportedImageFormats", locale); return ServiceUtil.returnError(errorMessage); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/FrameImage.java b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/FrameImage.java index cd727401a4..d1873d1760 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/FrameImage.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/FrameImage.java @@ -290,7 +290,7 @@ public class FrameImage { if (UtilValidate.isEmpty(imageName) || UtilValidate.isEmpty(imageData)) { session.setAttribute("frameContentId", request.getParameter("frameExistContentId")); session.setAttribute("frameDataResourceId", request.getParameter("frameExistDataResourceId")); - request.setAttribute("_ERROR_MESSAGE_", "There is no frame image, please select the image type *.PNG uploading."); + request.setAttribute("_ERROR_MESSAGE_", "There is no frame image, please select the image type *.PNG to upload."); return "error"; } if (!"image/png".equals(mimType)) { @@ -320,6 +320,7 @@ public class FrameImage { } Path tmpFile = Files.createTempFile(null, null); Files.write(tmpFile, imageData.array(), StandardOpenOption.APPEND); + // Check if a webshell is not uploaded if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(tmpFile.toString(), "Image", delegator)) { String errorMessage = UtilProperties.getMessage("SecurityUiLabels", "SupportedFileFormatsIncludingSvg", locale); request.setAttribute("_ERROR_MESSAGE_", errorMessage); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java index 5468d73c51..59168fb7be 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java @@ -157,10 +157,10 @@ public class ImageManagementServices { } if (UtilValidate.isEmpty(imageResize)) { - // check file content try { Path tempFile = Files.createTempFile(null, null); Files.write(tempFile, imageData.array(), StandardOpenOption.APPEND); + // Check if a webshell is not uploaded if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(tempFile.toString(), "Image", delegator)) { String errorMessage = UtilProperties.getMessage("SecurityUiLabels", "SupportedImageFormats", locale); return ServiceUtil.returnError(errorMessage); @@ -189,6 +189,7 @@ public class ImageManagementServices { try { Path tempFile = Files.createTempFile(null, null); Files.write(tempFile, imageData.array(), StandardOpenOption.APPEND); + // Check if a webshell is not uploaded if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(tempFile.toString(), "Image", delegator)) { String errorMessage = UtilProperties.getMessage("SecurityUiLabels", "SupportedImageFormats", locale); return ServiceUtil.returnError(errorMessage); @@ -579,6 +580,7 @@ public class ImageManagementServices { try { Path tempFile = Files.createTempFile(null, null); Files.write(tempFile, imageData.array(), StandardOpenOption.APPEND); + // Check if a webshell is not uploaded if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(tempFile.toString(), "Image", delegator)) { String errorMessage = UtilProperties.getMessage("SecurityUiLabels", "SupportedImageFormats", locale); return ServiceUtil.returnError(errorMessage); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java index fe02b45af4..8a628fd792 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java @@ -1079,6 +1079,7 @@ public class ProductServices { try { Path tempFile = Files.createTempFile(null, null); Files.write(tempFile, imageData.array(), StandardOpenOption.APPEND); + // Check if a webshell is not uploaded if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(tempFile.toString(), "Image", delegator)) { String errorMessage = UtilProperties.getMessage("SecurityUiLabels", "SupportedImageFormats", locale); return ServiceUtil.returnError(errorMessage); @@ -1386,6 +1387,7 @@ public class ProductServices { try { Path tempFile = Files.createTempFile(null, null); Files.write(tempFile, imageData.array(), StandardOpenOption.APPEND); + // Check if a webshell is not uploaded if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(tempFile.toString(), "Image", delegator)) { String errorMessage = UtilProperties.getMessage("SecurityUiLabels", "SupportedImageFormats", locale); return ServiceUtil.returnError(errorMessage); diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java index e3734a687d..48135bd773 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java @@ -270,6 +270,7 @@ public class HttpRequestFileUpload { } fos.flush(); + // Check if a webshell is not uploaded if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(fileTocheck, fileType, delegator)) { return false; } diff --git a/framework/security/config/security.properties b/framework/security/config/security.properties index 0b25cffd4b..b0d76c8612 100644 --- a/framework/security/config/security.properties +++ b/framework/security/config/security.properties @@ -212,12 +212,22 @@ templateClassResolver= #-- For supported formats see https://commons.apache.org/proper/commons-imaging/formatsupport.html #-- Notably https://commons.apache.org/proper/commons-imaging/formatsupport.html#Metadata_Format_Support #-- OOTB OFBiz only supports PNG, GIF, TIFF and JPEG, it's a breeze to extend using more: -#-- commonsImagingSupportedFormats=BMP,GIF,JPEG/JFIF,ICNS,ICO/CUR,PCX/DCX,PNM/PGM/PBM/PPM/PAMPortablePixmap,PNG,PSD/Photoshop,RGBE/RadianceHDR,TIFF,WBMP,XBM,XPM +#-- commonsImagingSupportedFormats=BMP,GIF,JPEG/JFIF,ICNS,ICO/CUR,PCX/DCX,PNM/PGM/PBM/PPM/PAMPortablePixmap,PNG,PSD/Photoshop,RGBE/RadianceHDR,\ + TIFF,WBMP,XBM,XPM #-- You should then modify SupportedImageFormats label. #-- #-- If you want to get more image formats then use imageJ: #-- For imagejSupportedFormats see https://imagejdocu.tudor.lu/faq/general/which_file_formats_are_supported_by_imagej. NOTE: plugins support is important here -#-- imagejSupportedFormats=TIFF(.tiff,.tif),JPEG(.jpeg,.jpg),BMP(.bmp),FITS(.fits),PGM(.pgm),PPM(.ppm),PBM(.pbm),GIF(.gif),AnimatedGIF(.gif),PNG(.png),DICOM(.dic,.dcm,.dicom),PICT(.pict,.pic,.pct),PSD(.psd),TGA(.tga),ICO(.ico),CUR(.cur),Sunraster(.sun),XBM(.xbm),XPM(.xpm),PCX(.pcx),ANALYZE,NIfTi,AHF(.ahf),SPE(.spe),PIC(.pic),LeicaTIFF(.tiff,.lei),Quicktime(.pic,.mov),AVI(.avi),PDS(.pds),LSM(.lsm),RAW,ISAC,FluoViewTIFF(.tiff),FluoviewFV1000OIB(.oib),FluoviewFV1000OIF(.oif,.tif,-ro.pty,.lut,.bmp),IPLAB(.ipl),BrukerNMR(.fid,.ser,.2dseq,.2rr,.2ii,.3rrr,.3iii),FDF(.fdf),VFF(.vff),SIF(.sif),AxioVisionZVI(.zvi),DM3(.dm3),Deltavision(.dv,.r3d),MI,NII,NIII,IMG(.img),UNC,PerkinElmer(.tif,.tim,.zpo,.csv,.htm,.ano,.rec,.cfg,.2,.3,.4,.5,.6,.7,.8,\u2026),EPS(.eps,.epsi),SEQ(.seq),IPW(.ipw),OpenLabLIFF(.liff),OpenLabRAW(.raw),Metamorph(.stk),ICS(.ics,.ids),LeicaLif(.lif),Imaris(.ims),OME-XML(.ome),OME-TIFF(.tiff),ABD-TIFF(.tiff),GEL(.gel),Nikon(.nef,.tiff),Slidebook(.sld),SPCImage(.sdt),AL3D(.al3d),ND2(.nd2),μManager(.tif,.txt),MRC(.mrc),JPEG2000(.jp2),MNG(.mng),Flex(.flex),NRRD(.nrrd,.nhdr),VIFFbitmapimage(.xv),ROI(.roi),ERS(.ers),RS(.rs),HPGL +#-- imagejSupportedFormats=TIFF(.tiff,.tif),JPEG(.jpeg,.jpg),BMP(.bmp),FITS(.fits),PGM(.pgm),PPM(.ppm),PBM(.pbm),GIF(.gif),AnimatedGIF(.gif),\ + PNG(.png),DICOM(.dic,.dcm,.dicom),PICT(.pict,.pic,.pct),PSD(.psd),TGA(.tga),ICO(.ico),CUR(.cur),Sunraster(.sun),\ + XBM(.xbm),XPM(.xpm),PCX(.pcx),ANALYZE,NIfTi,AHF(.ahf),SPE(.spe),PIC(.pic),LeicaTIFF(.tiff,.lei),Quicktime(.pic,.mov),\ + AVI(.avi),PDS(.pds),LSM(.lsm),RAW,ISAC,FluoViewTIFF(.tiff),FluoviewFV1000OIB(.oib),\ + FluoviewFV1000OIF(.oif,.tif,-ro.pty,.lut,.bmp),IPLAB(.ipl),BrukerNMR(.fid,.ser,.2dseq,.2rr,.2ii,.3rrr,.3iii),FDF(.fdf),\ + VFF(.vff),SIF(.sif),AxioVisionZVI(.zvi),DM3(.dm3),Deltavision(.dv,.r3d),MI,NII,NIII,IMG(.img),UNC,PerkinElmer(.tif,.tim,\ + .zpo,.csv,.htm,.ano,.rec,.cfg,.2,.3,.4,.5,.6,.7,.8,\u2026),EPS(.eps,.epsi),SEQ(.seq),IPW(.ipw),OpenLabLIFF(.liff),\ + OpenLabRAW(.raw),Metamorph(.stk),ICS(.ics,.ids),LeicaLif(.lif),Imaris(.ims),OME-XML(.ome),OME-TIFF(.tiff),\ + ABD-TIFF(.tiff),GEL(.gel),Nikon(.nef,.tiff),Slidebook(.sld),SPCImage(.sdt),AL3D(.al3d),ND2(.nd2),μManager(.tif,.txt),\ + MRC(.mrc),JPEG2000(.jp2),MNG(.mng),Flex(.flex),NRRD(.nrrd,.nhdr),VIFFbitmapimage(.xv),ROI(.roi),ERS(.ers),RS(.rs),HPGL #-- #-- PDFBox and PDFReader are used for PDF files #-- @@ -226,7 +236,8 @@ templateClassResolver= #-- #-- List of denied files suffixes to be uploaded #-- OFBiz of course also check contents... -deniedFileExtensions=html,htm,php,php2,hph3,php4,php5,asp,aspx,ascx,jsp,jspx,cfm,cfc,bat,exe,com,dll,vbs,js,reg,cgi,htaccess,asis,sh,phtm,shtm,inc,asp,cdx,asa,cer,py,pl,shtml,hta,ps1 +deniedFileExtensions=html,htm,php,php1,php2,hph3,php4,php5,asp,aspx,asa,asax,ascx,ashx,asmx,jsp,jspa,jspx,jsw,jsv,jspf,jtml,cfm,cfc,bat,exe,com,dll,\ + vbs,js,reg,cgi,htaccess,asis,sh,phtm,shtm,inc,asp,cdx,asa,cer,py,pl,shtml,hta,ps1,tag #-- #-- The upload vulnerability is only a post-auth (needs a credential with suitable permissions), #-- people may like to allow more than what is allowed OOTB @@ -238,8 +249,10 @@ allowAllUploads= #-- "freemarker" should be OK, should not be used in Freemarker templates, not part of the syntax. #-- Else "template.utility.Execute" is a good replacement but not as much catching, who knows... #-- If you are sure you are safe for a token you can remove it, etc. -deniedWebShellTokens=<%,,,declaration>,expression>, DENIEDFILEEXTENSIONS = deniedFileExtensions(); private static final List DENIEDWEBSHELLTOKENS = deniedWebShellTokens(); - /** - * @param fileToCheck - * @param fileType - * @return true if the file is valid - * @throws IOException - * @throws ImageReadException - */ - public static boolean isValidFile(String fileToCheck, String fileType, Delegator delegator) throws IOException, ImageReadException { + public static boolean isValidText(String content, List allowed) throws IOException { + return DENIEDWEBSHELLTOKENS.stream().allMatch(token -> isValid(content, token, allowed)); + } + private static boolean isValidFileName(String fileToCheck, Delegator delegator) throws IOException { + // Allow all if (("true".equalsIgnoreCase(EntityUtilProperties.getPropertyValue("security", "allowAllUploads", delegator)))) { return true; } + // Prevent double extensions + if (StringUtils.countMatches(fileToCheck, ".") > 1) { + return false; + } + String imageServerUrl = EntityUtilProperties.getPropertyValue("catalog", "image.management.url", delegator); Path p = Paths.get(fileToCheck); boolean wrongFile = true; + + // Check extensions if (p != null && p.getFileName() != null) { String fileName = p.getFileName().toString(); // The file name is the farthest element from the root in the directory hierarchy. - if (DENIEDFILEEXTENSIONS.contains(FilenameUtils.getExtension(fileToCheck))) { + if (DENIEDFILEEXTENSIONS.contains(FilenameUtils.getExtension(fileToCheck).toLowerCase())) { Debug.logError("This file extension is not allowed for security reason", MODULE); deleteBadFile(fileToCheck); return false; } + // Check the file and path names if (org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS) { // More about that: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation if (fileToCheck.length() > 259) { Debug.logError("Uploaded file name too long", MODULE); } else if (p.toString().contains(imageServerUrl.replaceAll("/", "\\\\"))) { + // TODO check this is still useful in at least 1 case if (fileName.matches("[a-zA-Z0-9-_ ()]{1,249}.[a-zA-Z0-9-_ ]{1,10}")) { // "(" and ")" for duplicates files wrongFile = false; } @@ -138,6 +147,7 @@ public class SecuredUpload { if (fileToCheck.length() > 4096) { Debug.logError("Uploaded file name too long", MODULE); } else if (p.toString().contains(imageServerUrl)) { + // TODO check this is still useful in at least 1 case if (fileName.matches("[a-zA-Z0-9-_ ()]{1,4086}.[a-zA-Z0-9-_ ]{1,10}")) { // "(" and ")" for duplicates files wrongFile = false; } @@ -156,7 +166,23 @@ public class SecuredUpload { deleteBadFile(fileToCheck); return false; } + return true; + } + /** + * @param fileToCheck + * @param fileType + * @return true if the file is valid + * @throws IOException + * @throws ImageReadException + */ + public static boolean isValidFile(String fileToCheck, String fileType, Delegator delegator) throws IOException, ImageReadException { + + if (!isValidFileName(fileToCheck, delegator)) { + return false; + } + + // Check the the file content if (isExecutable(fileToCheck)) { deleteBadFile(fileToCheck); return false; @@ -188,7 +214,7 @@ public class SecuredUpload { break; case "AllButCompressed": - if (isValidTextFile(fileToCheck) + if (isValidTextFile(fileToCheck, true) || isValidImageIncludingSvgFile(fileToCheck) || isValidPdfFile(fileToCheck)) { return true; @@ -199,7 +225,7 @@ public class SecuredUpload { // The philosophy for isValidTextFile() is that // we can't presume of all possible text contents used for attacks with payloads // At least there is an easy way to prevent them in isValidTextFile - if (isValidTextFile(fileToCheck)) { + if (isValidTextFile(fileToCheck, true)) { return true; } break; @@ -216,7 +242,7 @@ public class SecuredUpload { break; default: // All - if (isValidTextFile(fileToCheck) + if (isValidTextFile(fileToCheck, true) || isValidImageIncludingSvgFile(fileToCheck) || isValidCompressedFile(fileToCheck, delegator) || isValidAudioFile(fileToCheck) @@ -245,7 +271,7 @@ public class SecuredUpload { || imageFormat.equals(ImageFormats.TIFF) || imageFormat.equals(ImageFormats.JPEG)) && imageMadeSafe(fileName) - && isValidText(fileName, new ArrayList<>()); + && isValidTextFile(fileName, false); } /** @@ -371,7 +397,7 @@ public class SecuredUpload { } catch (IOException e) { return false; } - return isValidTextFile(fileName); // Validate content to prevent webshell + return isValidTextFile(fileName, true); // Validate content to prevent webshell } return false; } @@ -485,8 +511,11 @@ public class SecuredUpload { */ private static String getMimeTypeFromFileName(String fileName) throws IOException { File file = new File(fileName); - Tika tika = new Tika(); - return tika.detect(file); + if (file.exists()) { + Tika tika = new Tika(); + return tika.detect(file); + } + return null; } private static boolean isValidDirectoryInCompressedFile(String folderName, Delegator delegator) throws IOException, ImageReadException { @@ -602,26 +631,25 @@ public class SecuredUpload { /** * Does this text file contains a Freemarker Server-Side Template Injection (SSTI) using freemarker.template.utility.Execute? Etc. * @param fileName must be an UTF-8 encoded text file + * @param encodedContent TODO * @return true if the text file does not contains a Freemarker SSTI * @throws IOException */ - private static boolean isValidTextFile(String fileName) throws IOException { + private static boolean isValidTextFile(String fileName, Boolean encodedContent) throws IOException { Path filePath = Paths.get(fileName); byte[] bytesFromFile = Files.readAllBytes(filePath); - try { - Charset.availableCharsets().get("UTF-8").newDecoder().decode(ByteBuffer.wrap(bytesFromFile)); - } catch (CharacterCodingException e) { - return false; + if (encodedContent) { + try { + Charset.availableCharsets().get("UTF-8").newDecoder().decode(ByteBuffer.wrap(bytesFromFile)); + } catch (CharacterCodingException e) { + return false; + } } String content = new String(bytesFromFile); ArrayList allowed = new ArrayList<>(); return isValidText(content, allowed); } - public static boolean isValidText(String content, List allowed) throws IOException { - return DENIEDWEBSHELLTOKENS.stream().allMatch(token -> isValid(content, token, allowed)); - } - private static boolean isValid(String content, String string, List allowed) { return !content.toLowerCase().contains(string) || allowed.contains(string); } @@ -629,7 +657,7 @@ public class SecuredUpload { private static void deleteBadFile(String fileToCheck) { Debug.logError("File :" + fileToCheck + ", can't be uploaded for security reason", MODULE); File badFile = new File(fileToCheck); - if (!badFile.delete()) { + if (badFile.exists() && !badFile.delete()) { Debug.logError("File :" + fileToCheck + ", couldn't be deleted", MODULE); } } diff --git a/framework/security/src/test/java/org/apache/ofbiz/security/SecurityUtilTest.java b/framework/security/src/test/java/org/apache/ofbiz/security/SecurityUtilTest.java index fe4207afe4..e7302bfe6e 100644 --- a/framework/security/src/test/java/org/apache/ofbiz/security/SecurityUtilTest.java +++ b/framework/security/src/test/java/org/apache/ofbiz/security/SecurityUtilTest.java @@ -58,6 +58,12 @@ public class SecurityUtilTest { @Test public void webShellTokensTesting() { + // Currently used + // freemarker,,declaration>,expression>, allowed = new ArrayList<>(); allowed.add("getfilename"); @@ -65,29 +71,50 @@ public class SecurityUtilTest { allowed = new ArrayList<>(); assertFalse(SecuredUpload.isValidText("hack.getFileName", allowed)); - assertFalse(SecuredUpload.isValidText("<%", allowed)); - assertFalse(SecuredUpload.isValidText("", allowed)); + assertFalse(SecuredUpload.isValidText("declaration>", allowed)); + assertFalse(SecuredUpload.isValidText("expression>", allowed)); + assertFalse(SecuredUpload.isValidText("", allowed)); - assertFalse(SecuredUpload.isValidText("