owen2345 / camaleon-cms

Camaleon CMS is a dynamic and advanced content management system based on Ruby on Rails
https://camaleon.website
MIT License
1.22k stars 287 forks source link

Mitigate stored XSS through user file upload (GHSL-2024-184) #1085

Closed texpert closed 3 months ago

texpert commented 3 months ago

Thanks GHSL team member @p- for disovering and reporting this!

Stored XSS through user file upload (GHSL-2024-184) vulnerability reported:

A stored cross-site scripting has been found in the image upload functionality that can be used by normal registered users: It is possible to upload a SVG image containing JavaScript and it's also possible to upload a HTML document when the format parameter is manually changed to documents or a string of an unsupported format. If an authenticated user or administrator visits that uploaded image or document malicious JavaScript can be executed on their behalf (e.g. changing or deleting content inside of the CMS.)

This PR fixes the vulnerability by introducing the file_content_unsafe? method, which is scanning the file content for unsafe expressions and patterns in the upload_file method of the CamaleonCms::UploaderHelper.