CVE-2023-37269 (PHP, published 2023-07-07T22:15Z)
Description: value: 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.
Severity: nan (CVSS v3 base score: 4.8)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/wintercms/storm
Files changed:
src/Database/Attach/File.php
src/Filesystem/Definitions.php
Commit message: Add support for uploading SVGs


Vulnerable code:
        $destinationPath = $this->getStorageDirectory() . $this->getPartitionDirectory();
            return $this->copyLocalToStorage($sourcePath, $destinationPath . $destinationFileName);
        $destinationPath = $this->getLocalRootPath() . '/' . $destinationPath;
            !FileHelper::isDirectory($destinationPath) &&
            !FileHelper::makeDirectory($destinationPath, 0777, true, true)
        return FileHelper::copy($sourcePath, $destinationPath . $destinationFileName);
            'zip'
            'scss'
            'gif'
            'webm'
            'ogg'

Fixed code:
use Winter\Storm\Support\Svg;
        $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);
            return $this->copyLocalToStorage($sourcePath, $destinationPath);
        $destinationFolder = $this->getLocalRootPath() . '/' . $destinationFolder;
        $destinationPath = $destinationFolder . $destinationFileName;
            !FileHelper::isDirectory($destinationFolder) &&
            !FileHelper::makeDirectory($destinationFolder, 0777, true, true)
        return FileHelper::copy($sourcePath, $destinationPath);
            'svg',
            'zip',
            'svg',
            'scss',
            'gif',
            'svg',
            'webm',
            'ogg',