The vulnerability is an arbitrary file upload issue in MoonShine, specifically allowing the upload of crafted SVG files which can lead to code execution. The root cause is improper validation of uploaded files. The provided patch addresses this by enforcing stricter validation rules on the uploaded files.
My analysis of the commit 7102fb113627870fb1cb7176e1d0d95bb47a7fd4 reveals changes in two key files:
src/Laravel/src/Http/Requests/ProfileFormRequest.php
src/Laravel/src/Resources/MoonShineUserResource.php
In both files, the rules() method was updated to include 'mimes:jpeg,jpg,png,gif' for the 'avatar' field. This change restricts the allowed file types for user avatars, preventing the upload of SVG files and thus mitigating the vulnerability. The vulnerable functions are the rules methods within these two classes, as they were the ones that failed to properly validate the file type of the uploaded avatar, which is the entry point for the vulnerability. An attacker could exploit this by uploading a malicious SVG file disguised as an avatar, which would then be stored on the server and could potentially be executed.