Headline
CVE-2023-37269: Add support for uploading SVGs · wintercms/storm@186d85d
Winter is a free, open-source content management system (CMS) based on the Laravel PHP framework. Users with the backend.manage_branding
permission can upload SVGs as the application logo. Prior to version 1.2.3, SVG uploads were not sanitized, which could have allowed a stored cross-site scripting (XSS) attack. To exploit the vulnerability, an attacker would already need to have developer or super user level permissions in Winter CMS. This means they would already have extensive access and control within the system. Additionally, to execute the XSS, the attacker would need to convince the victim to directly visit the URL of the maliciously uploaded SVG, and the application would have to be using local storage where uploaded files are served under the same domain as the application itself instead of a CDN. This is because all SVGs in Winter CMS are rendered through an img
tag, which prevents any payloads from being executed directly. These two factors significantly limit the potential harm of this vulnerability. This issue has been patched in v1.2.3 through the inclusion of full support for SVG uploads and automatic sanitization of uploaded SVG files. As a workaround, one may apply the patches manually.
Expand Up
@@ -11,6 +11,7 @@
use Winter\Storm\Exception\ApplicationException;
use Winter\Storm\Network\Http;
use Winter\Storm\Support\Facades\File as FileHelper;
use Winter\Storm\Support\Svg;
/**
* File attachment model
Expand Down Expand Up
@@ -834,31 +835,40 @@ protected function putFile($sourcePath, $destinationFileName = null)
$destinationFileName = $this->disk_name;
}
$destinationPath = $this->getStorageDirectory() . $this->getPartitionDirectory();
$destinationFolder = $this->getStorageDirectory() . $this->getPartitionDirectory();
$destinationPath = $destinationFolder . $destinationFileName;
// Filter SVG files
if (pathinfo($destinationPath, PATHINFO_EXTENSION) === ‘svg’) {
file_put_contents($sourcePath, Svg::extract($sourcePath));
}
pathinfo($destinationPath, PATHINFO_EXTENSION);
if (!$this->isLocalStorage()) {
return $this->copyLocalToStorage($sourcePath, $destinationPath . $destinationFileName);
return $this->copyLocalToStorage($sourcePath, $destinationPath);
}
/*
* Using local storage, tack on the root path and work locally
* this will ensure the correct permissions are used.
*/
$destinationPath = $this->getLocalRootPath() . ‘/’ . $destinationPath;
$destinationFolder = $this->getLocalRootPath() . ‘/’ . $destinationFolder;
$destinationPath = $destinationFolder . $destinationFileName;
/*
* Verify the directory exists, if not try to create it. If creation fails
* because the directory was created by a concurrent process then proceed,
* otherwise trigger the error.
*/
if (
!FileHelper::isDirectory($destinationPath) &&
!FileHelper::makeDirectory($destinationPath, 0777, true, true)
!FileHelper::isDirectory($destinationFolder) &&
!FileHelper::makeDirectory($destinationFolder, 0777, true, true)
) {
trigger_error(error_get_last()[‘message’], E_USER_WARNING);
}
return FileHelper::copy($sourcePath, $destinationPath . $destinationFileName);
return FileHelper::copy($sourcePath, $destinationPath);
}
/**
Expand Down
Related news
WinterCMS versions prior to 1.2.3 suffer from a persistent cross site scripting vulnerability.
### Impact Users with the `backend.manage_branding` permission can upload SVGs as the application logo. Previously, SVG uploads were not sanitized, which could have allowed a stored XSS attack. Although this was a security issue, it's important to note that its severity is low. To exploit the vulnerability, an attacker would already need to have developer or super user level permissions in Winter CMS. This means they would already have extensive access and control within the system. Additionally, to execute the XSS, the attacker would need to convince the victim to directly visit the URL of the maliciously uploaded SVG, and the application would have to be using local storage where uploaded files are served under the same domain as the application itself instead of a CDN. This is because all SVGs in Winter CMS are rendered through an `img` tag, which prevents any payloads from being executed directly. These two factors significantly limit the potential harm of this vulnerability. Th...