fix: file validation bypass by targeting non file input types during customer file upload #40262
+53
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description (*)
Currently, we can upload files against any attribute types via the customer file upload controllers.
This is not ideal as, we can target non file based types (Select/Hidden/Text) to bypass the expected validation logic that would take place for a Image/File type.
And as far as I am aware, there is no valid reason to be uploading a file, to non file input types (e.g select / text).
This specific functionality is actively being exploited as part of the Session Reaper (CVE-2025-54236) chain to achieve RCE.
https://slcyber.io/assetnote-security-research-center/why-nested-deserialization-is-still-harmful-magento-rce-cve-2025-54236/
This PR restricts the file uploads to only input types that are expected to have file uploads. Whilst leaving the input types configurable to merchants/extension developers via di.xml
Manual testing scenarios (*)
Checkout 2.4-develop
Post an arbitrary file to the
customer/address_file/uploadendpoint, targeting a select attribute (country_id)Note a success message, and the file is present in the
pub/media/customer_addressdirectoryPost an arbitrary file to the
customer/address_file/uploadendpoint, targeting a text attribute (city)Note a error message, referencing text based validation error trying to validate a file as a string
Checkout this PR
Repeat Steps 2 & 3, note a friendly error message stating file uploads are unexpected.
Create a image/file based attribute, update the curl command to target that. Upload should succeed.
Contribution checklist (*)