Magento Long Term Support (LTS) is an unofficial, community-driven project provides an alternative to the Magento Community Edition e-commerce platform with a high level of backward compatibility. Prior to version 20.17.0, the product custom option file upload in OpenMage LTS uses an incomplete blocklist (`forbidden_extensions = php,exe`) to prevent dangerous file uploads. This blocklist can be trivially bypassed by using alternative PHP-executable extensions such as `.phtml`, `.phar`, `.php3`, `.php4`, `.php5`, `.php7`, and `.pht`. Files are stored in the publicly accessible `media/custom_options/quote/` directory, which lacks server-side execution restrictions for some configurations, enabling Remote Code Execution if this directory is not explicitly denied script execution. Version 20.17.0 patches the issue.
OpenMage LTS versions prior to 20.17.0 contain a critical file upload vulnerability in custom option handling that allows Remote Code Execution through bypassing an incomplete PHP extension blocklist. Attackers can upload malicious PHP files using alternative extensions (.phtml, .phar, .php3-7, .pht) to publicly accessible directories, leading to complete system compromise. This vulnerability is particularly severe for Saudi e-commerce platforms as it enables unauthenticated code execution with high exploitability.
IMMEDIATE ACTIONS:
1. Identify all OpenMage LTS installations in your environment and document versions
2. Disable file uploads in custom options immediately if not critical to operations
3. Implement strict web server configuration to prevent script execution in media/custom_options/quote/ directory
WEB SERVER HARDENING (Apache):
Add to .htaccess in media/custom_options/quote/:
<FilesMatch "\.ph(p[3-7]?|ar|tml|t)$">
Deny from all
</FilesMatch>
<FilesMatch ".*">
php_flag engine off
</FilesMatch>
Nginx configuration:
add_type text/plain .php .phtml .phar .php3 .php4 .php5 .php7 .pht;
location ~ \.ph(p[3-7]?|ar|tml|t)$ { deny all; }
PATCHING:
1. Upgrade to OpenMage LTS 20.17.0 or later immediately
2. If upgrade not possible, apply vendor security patches when available
3. Test patches in staging environment before production deployment
COMPENSATING CONTROLS:
1. Implement Web Application Firewall (WAF) rules to block uploads with suspicious extensions
2. Enable file integrity monitoring on media/custom_options/ directory
3. Restrict file upload functionality to authenticated users only
4. Implement strict input validation: whitelist only safe extensions (.jpg, .png, .pdf)
5. Store uploaded files outside web root if possible
6. Disable PHP execution in all upload directories via server configuration
DETECTION:
1. Monitor for POST requests to custom option upload endpoints with suspicious file extensions
2. Alert on creation of .phtml, .phar, .php3-7, .pht files in media/custom_options/ directory
3. Monitor for HTTP 200 responses followed by execution attempts on uploaded files
4. Log Analysis: Search for patterns like "custom_options/quote/.*\.(phtml|phar|php[3-7]|pht)"
5. File system monitoring: Alert on executable file creation in media/custom_options/quote/
الإجراءات الفورية:
1. حدد جميع تثبيتات OpenMage LTS في بيئتك وتوثيق الإصدارات
2. عطّل تحميل الملفات في الخيارات المخصصة فوراً إذا لم تكن حرجة
3. طبّق تكوين خادم ويب صارم لمنع تنفيذ البرامج النصية في مجلد media/custom_options/quote/
تقسية خادم الويب (Apache):
أضف إلى .htaccess في media/custom_options/quote/:
<FilesMatch "\.ph(p[3-7]?|ar|tml|t)$">
Deny from all
</FilesMatch>
تكوين Nginx:
أضف قواعد لحظر امتدادات PHP البديلة وتعطيل تنفيذ PHP
التصحيح:
1. قم بالترقية إلى OpenMage LTS 20.17.0 أو أحدث فوراً
2. إذا لم يكن الترقية ممكنة، طبّق تصحيحات الأمان من المورد
3. اختبر التصحيحات في بيئة التطوير قبل الإنتاج
الضوابط البديلة:
1. طبّق قواعد جدار حماية تطبيقات الويب (WAF) لحظر التحميلات بامتدادات مريبة
2. فعّل مراقبة سلامة الملفات على مجلد media/custom_options/
3. قيّد وظيفة تحميل الملفات للمستخدمين المصرح لهم فقط
4. طبّق التحقق الصارم من المدخلات: قائمة بيضاء بامتدادات آمنة فقط
5. خزّن الملفات المحملة خارج جذر الويب إن أمكن
6. عطّل تنفيذ PHP في جميع مجلدات التحميل
الكشف:
1. راقب طلبات POST إلى نقاط نهاية تحميل الخيارات المخصصة بامتدادات مريبة
2. نبّه عند إنشاء ملفات .phtml و .phar و .php3-7 و .pht في مجلد media/custom_options/
3. راقب محاولات التنفيذ على الملفات المحملة
4. تحليل السجلات: ابحث عن أنماط الملفات المريبة
5. مراقبة نظام الملفات: نبّه عند إنشاء ملفات قابلة للتنفيذ