Fixed: CVE-2021-37608 vulnerability bypass
Fixed the Additional image uploading issue which got somehow missed in service addAdditionalViewForProduct.
@@ -1077,10 +1077,13 @@ public class ProductServices {
String fileToCheck = imageServerPath + "/" + fileLocation + "." + extension.getString("fileExtensionId");
File file = new File(fileToCheck);
try {
- if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(fileToCheck, "Image", delegator)) {
+ Path tempFile = Files.createTempFile(null, null);
+ Files.write(tempFile, imageData.array(), StandardOpenOption.APPEND);
+ if (!org.apache.ofbiz.security.SecuredUpload.isValidFile(tempFile.toString(), "Image", delegator)) {
String errorMessage = UtilProperties.getMessage("SecurityUiLabels", "SupportedImageFormats", locale);
return ServiceUtil.returnError(errorMessage);
}
+ Files.delete(tempFile);
RandomAccessFile out = new RandomAccessFile(fileToCheck, "rw");
out.write(imageData.array());
out.close();
