The Autoptimize plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the 'ao_post_preload' meta value in all versions up to, and including, 3.1.14. This is due to insufficient input sanitization in the `ao_metabox_save()` function and missing output escaping when the value is rendered into a `<link>` tag in `autoptimizeImages.php`. This makes it possible for authenticated attackers, with Contributor-level access and above, to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page, granted the "Image optimization" or "Lazy-load images" setting is enabled in the plugin configuration.
Autoptimize WordPress plugin versions up to 3.1.14 contain a Stored XSS vulnerability allowing authenticated contributors to inject malicious scripts via the 'ao_post_preload' meta value. The vulnerability requires image optimization or lazy-load features to be enabled and affects any WordPress site using this popular performance plugin. While currently unpatched, the attack requires contributor-level access, limiting immediate risk but posing significant threat to multi-user WordPress installations common in Saudi organizations.
IMMEDIATE ACTIONS:
1. Audit all WordPress installations using Autoptimize plugin and identify current version
2. Review contributor and author user accounts for suspicious activity or recent additions
3. Check WordPress post/page metadata for suspicious 'ao_post_preload' values using database queries
4. Disable 'Image optimization' and 'Lazy-load images' settings in Autoptimize configuration as temporary mitigation
5. Review access logs for unauthorized post/page modifications
PATCHING GUIDANCE:
1. Monitor Autoptimize GitHub repository and official WordPress plugin page for security updates
2. When patch becomes available, immediately update to patched version
3. Test updates in staging environment before production deployment
4. Implement automated plugin update notifications
COMPENSATING CONTROLS (until patch available):
1. Restrict contributor role to trusted users only; audit existing contributors
2. Implement Web Application Firewall (WAF) rules to detect/block XSS patterns in POST requests
3. Enable WordPress security plugins (Wordfence, Sucuri) with XSS detection capabilities
4. Implement Content Security Policy (CSP) headers to restrict script execution
5. Use WordPress user role management to limit who can edit posts/pages
6. Enable WordPress audit logging to track post modifications
DETECTION RULES:
1. Monitor database for 'ao_post_preload' meta values containing script tags or event handlers
2. Alert on any post_meta updates to 'ao_post_preload' field
3. Monitor HTTP requests containing 'script', 'onerror', 'onload' in POST parameters
4. Track changes to Autoptimize plugin settings, especially image optimization toggles
5. Review WordPress error logs for XSS-related warnings
الإجراءات الفورية:
1. تدقيق جميع تثبيتات WordPress التي تستخدم مكون Autoptimize وتحديد الإصدار الحالي
2. مراجعة حسابات المستخدمين من نوع المساهم والمؤلف للبحث عن نشاط مريب أو إضافات حديثة
3. التحقق من بيانات وصفية لصفحات WordPress بحثاً عن قيم 'ao_post_preload' مريبة باستخدام استعلامات قاعدة البيانات
4. تعطيل إعدادات 'تحسين الصور' و'تحميل الصور بطريقة كسولة' في تكوين Autoptimize كتخفيف مؤقت
5. مراجعة سجلات الوصول للتعديلات غير المصرح بها على الصفحات
إرشادات التصحيح:
1. مراقبة مستودع Autoptimize على GitHub وصفحة المكون الرسمية في WordPress للتحديثات الأمنية
2. عند توفر التصحيح، قم بالتحديث الفوري إلى الإصدار المصحح
3. اختبر التحديثات في بيئة التطوير قبل نشرها في الإنتاج
4. تنفيذ إشعارات تحديث المكون الآلية
الضوابط البديلة (حتى توفر التصحيح):
1. تقييد دور المساهم للمستخدمين الموثوقين فقط؛ تدقيق المساهمين الحاليين
2. تنفيذ قواعد جدار حماية تطبيقات الويب (WAF) للكشف عن أنماط XSS وحجبها
3. تفعيل مكونات أمان WordPress (Wordfence, Sucuri) مع قدرات الكشف عن XSS
4. تنفيذ رؤوس سياسة أمان المحتوى (CSP) لتقييد تنفيذ البرامج النصية
5. استخدام إدارة أدوار مستخدمي WordPress لتحديد من يمكنه تحرير الصفحات
6. تفعيل تسجيل تدقيق WordPress لتتبع تعديلات الصفحات
قواعد الكشف:
1. مراقبة قاعدة البيانات للبحث عن قيم 'ao_post_preload' التي تحتوي على علامات نصية برمجية أو معالجات أحداث
2. تنبيه عند أي تحديثات لحقل 'ao_post_preload' في post_meta
3. مراقبة طلبات HTTP التي تحتوي على 'script' أو 'onerror' أو 'onload' في معاملات POST
4. تتبع التغييرات على إعدادات مكون Autoptimize، خاصة تبديلات تحسين الصور
5. مراجعة سجلات أخطاء WordPress للتحذيرات المتعلقة بـ XSS