The vulnerability described is a Denial of Service caused by unrestricted file upload size in Cuba's File Storage. The provided commit 42b6c00fd0572b8e52ae31afd1babc827a3161a1 addresses this issue.
-
The file modules/core/src/com/haulmont/cuba/core/app/filestorage/FileStorage.java contains the saveStream method. This method is modified to incorporate a file size check. Previously, it used IOUtils.copyLarge(inputStream, os) without a size limit. The patch changes this to IOUtils.copyLarge(inputStream, os, 0, maxAllowedSize) and adds subsequent checks to ensure the file does not exceed maxAllowedSize. This directly indicates that the saveStream method, in its pre-patch version, was the point where the vulnerability existed, as it processed and saved the input stream without validating its size.
-
The file modules/core/src/com/haulmont/cuba/core/app/ServerConfig.java was modified to add a new configuration property cuba.fileStorageMaxFileSize and a getter getFileStorageMaxFileSize(). This provides the mechanism for defining the maximum allowed file size, which is then used by FileStorage.saveStream.
-
The file modules/global/src/com/haulmont/cuba/core/config/type/DataSizeTypeFactory.java was added to parse the string representation of the file size (e.g., "100MB") into a usable DataSize object.
The function com.haulmont.cuba.core.app.filestorage.FileStorage.saveStream is identified as vulnerable because it was the function directly responsible for writing the file stream to disk. Before the patch, it did not enforce any size limits, allowing an attacker to upload arbitrarily large files, thereby consuming all available disk space and causing a denial of service. The patch mitigates this by introducing size checks within this function, using the newly added configuration for the maximum file size.