ImageMagick Server-Side Request Forgery (SSRF) Vulnerability — ImageMagick contains an unspecified vulnerability that allows attackers to perform server-side request forgery (SSRF) via a crafted image.
CVE-2016-3718 is a critical Server-Side Request Forgery (SSRF) vulnerability in ImageMagick, part of the infamous 'ImageTragick' series of vulnerabilities. It allows attackers to craft malicious image files that, when processed by ImageMagick, force the server to make arbitrary HTTP/FTP requests to internal or external resources. With a CVSS score of 9.0 and publicly available exploits, this vulnerability poses an immediate threat to any system processing user-uploaded images. Despite being from 2016, unpatched ImageMagick installations remain common in legacy web applications and content management systems.
Immediate Actions:
1. Identify all systems running ImageMagick using asset inventory and vulnerability scanning
2. Update ImageMagick to version 6.9.3-10 or later (7.x series recommended)
3. Implement a restrictive policy.xml file to disable vulnerable coders:
- Disable MVG, MSL, EPHEMERAL, URL, HTTPS, HTTP, FTP coders
- Add: <policy domain="coder" rights="none" pattern="EPHEMERAL" />
- Add: <policy domain="coder" rights="none" pattern="URL" />
- Add: <policy domain="coder" rights="none" pattern="HTTPS" />
- Add: <policy domain="coder" rights="none" pattern="HTTP" />
- Add: <policy domain="coder" rights="none" pattern="FTP" />
- Add: <policy domain="coder" rights="none" pattern="MVG" />
- Add: <policy domain="coder" rights="none" pattern="MSL" />
4. Validate uploaded file types using magic bytes, not just file extensions
5. Process images in sandboxed/containerized environments with no network access
Detection Rules:
- Monitor for outbound HTTP/FTP connections originating from image processing services
- Deploy WAF rules to inspect uploaded files for MVG/SVG payloads containing URL references
- Create SIEM alerts for unusual outbound connections from web application servers
- Monitor for requests to cloud metadata endpoints (169.254.169.254) from application servers
الإجراءات الفورية:
1. تحديد جميع الأنظمة التي تشغل ImageMagick باستخدام جرد الأصول وفحص الثغرات
2. تحديث ImageMagick إلى الإصدار 6.9.3-10 أو أحدث (يُوصى بسلسلة 7.x)
3. تطبيق ملف policy.xml مقيد لتعطيل المشفرات الضعيفة:
- تعطيل مشفرات MVG و MSL و EPHEMERAL و URL و HTTPS و HTTP و FTP
- إضافة: <policy domain="coder" rights="none" pattern="EPHEMERAL" />
- إضافة: <policy domain="coder" rights="none" pattern="URL" />
- إضافة: <policy domain="coder" rights="none" pattern="HTTPS" />
- إضافة: <policy domain="coder" rights="none" pattern="HTTP" />
- إضافة: <policy domain="coder" rights="none" pattern="FTP" />
- إضافة: <policy domain="coder" rights="none" pattern="MVG" />
- إضافة: <policy domain="coder" rights="none" pattern="MSL" />
4. التحقق من أنواع الملفات المرفوعة باستخدام البايتات السحرية وليس امتدادات الملفات فقط
5. معالجة الصور في بيئات معزولة/حاويات بدون وصول للشبكة
قواعد الكشف:
- مراقبة الاتصالات الصادرة HTTP/FTP من خدمات معالجة الصور
- نشر قواعد WAF لفحص الملفات المرفوعة بحثاً عن حمولات MVG/SVG التي تحتوي على مراجع URL
- إنشاء تنبيهات SIEM للاتصالات الصادرة غير المعتادة من خوادم التطبيقات
- مراقبة الطلبات إلى نقاط نهاية البيانات الوصفية السحابية (169.254.169.254)