A Magento 2 module designed to address a potential security concern related to custom options. It ensures that custom option values are correctly validated before processing, preventing unauthorized 'file' type injections.
This module introduces a before plugin for Magento\Catalog\Model\CustomOptions\CustomOption::getOptionValue().
The plugin performs the following checks:
- Option Existence: Verifies that the
option_idassociated with the request exists in the database. If the option does not exist, aLocalizedExceptionis thrown. - Type Validation: If the provided
option_valueis set to'file', it confirms that the actual custom option type in Magento is indeed'file'. If there is a mismatch (e.g., trying to pass'file'to atextordrop_downoption), aLocalizedExceptionis thrown.
This prevents potential exploitation where an attacker might try to force Magento to process a file upload for an option that was not intended to handle files.
composer require taurus-media/module-polyshell-fix- Copy the module files to
app/code/Taurus/PolyshellFix. - Run the following Magento commands:
bin/magento module:enable Taurus_PolyshellFix
bin/magento setup:upgrade
bin/magento cache:flush- Security Hardening: Adds a layer of validation to product custom options.
- Strict Type Checking: Ensures data integrity for file-based custom options.
- Easy Integration: Hooks into existing Magento logic via plugins without modifying core files.