Validate frontend input type for file uploads#40583
Validate frontend input type for file uploads#40583SkyMulley wants to merge 1 commit intomagento:2.4-developfrom
Conversation
Added validation for frontend input type to ensure only file or image uploads are allowed.
|
Hi @SkyMulley. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
Description (*)
The customer address file upload endpoint (
Customer/Controller/Address/File/Upload.php) did not validate whether the requested attribute'sfrontend_inputtype wasfileorimagebefore proceeding with the upload.This allowed an attacker to supply any custom address attribute code (e.g. a
texttype attribute) as the upload target. Since non-file attributes have nofile_extensionsvalidation rules configured,getAllowedExtensions()returns an empty array, causing the framework uploader to permit all file types — including executable files such as.php.The fix adds a check immediately after fetching the attribute metadata, throwing a
LocalizedExceptionif thefrontend_inputis notfileorimage.Manual testing scenarios (*)
frontend_inputtype oftext(e.g.my_text_attribute)POSTrequest to/customer/address/file/uploadwithcustom_attributes[my_text_attribute]as the file field, uploading a.phpfilepub/media/customer_address/tmp/Attribute "my_text_attribute" does not support file uploads.— and no file is written to diskfileorimagetype attribute still works as expectedQuestions or comments
This vulnerability requires an authenticated customer session to exploit. However, customer registration is typically open on Magento storefronts, making the attack surface effectively unauthenticated. The exploitability of the resulting upload also depends on whether PHP execution is blocked in the media directory, but defence in depth requires rejecting the upload regardless.