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 Arbitrary file delete vulnerability (GHSL-2024-186) #1087

Closed texpert closed 3 months ago

texpert commented 3 months ago

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

Arbitrary file delete in MediaController#delete_file (GHSL-2024-186) vulnerability reported:

"The actions method, defined inside of the MediaController class, doesn't check whether a given path is inside a certain path (e.g. inside the media folder). If an attacker performed an account takeover of an administrator account (See: GHSL-2024-184) they could delete arbitrary files or folders on the server hosting Camaleon CMS".

The report, though, isn't accurate, because the @current_site.upload_directory folder is prefixing the folder or file name to delete in the delete_folder and delete_file methods. What's missing, is a traversal check.

This PR fixes the vulnerability by introducing a check for path traversal check into the delete_folder and delete_file methods of the CamaleonCmsLocalUploader.