ImageMagick Arbitrary File Deletion Vulnerability — ImageMagick contains an unspecified vulnerability that could allow users to delete files by using ImageMagick's 'ephemeral' pseudo protocol, which deletes files after reading.
CVE-2016-3715 is a critical vulnerability in ImageMagick that allows attackers to delete arbitrary files on the server by exploiting the 'ephemeral' pseudo protocol. This vulnerability is part of the infamous 'ImageTragick' series of flaws that were widely exploited in the wild in 2016. With a CVSS score of 9.0 and active exploits available, any system processing user-uploaded images through ImageMagick is at severe risk. Organizations must patch immediately or implement compensating controls to prevent exploitation.
Immediate Actions:
1. Update ImageMagick to the latest patched version (6.9.3-10 or later, 7.0.1-1 or later)
2. Implement a policy.xml file to disable vulnerable coders and pseudo protocols:
- Add: <policy domain="coder" rights="none" pattern="EPHEMERAL" />
- Add: <policy domain="coder" rights="none" pattern="URL" />
- Add: <policy domain="coder" rights="none" pattern="MVG" />
- Add: <policy domain="coder" rights="none" pattern="MSL" />
- Add: <policy domain="coder" rights="none" pattern="HTTPS" />
- Add: <policy domain="coder" rights="none" pattern="HTTP" />
3. Validate all uploaded image files using magic bytes verification before passing to ImageMagick
4. Run ImageMagick in a sandboxed environment with minimal file system permissions
5. Consider switching to alternative image processing libraries (e.g., libvips, Pillow) where possible
Detection Rules:
- Monitor for 'ephemeral:' strings in uploaded files and image processing logs
- Alert on unexpected file deletions in web application directories
- Implement WAF rules to block requests containing ImageMagick pseudo protocol references
الإجراءات الفورية:
1. تحديث ImageMagick إلى أحدث إصدار مصحح (6.9.3-10 أو أحدث، 7.0.1-1 أو أحدث)
2. تطبيق ملف policy.xml لتعطيل البروتوكولات الزائفة الضعيفة:
- إضافة: <policy domain="coder" rights="none" pattern="EPHEMERAL" />
- إضافة: <policy domain="coder" rights="none" pattern="URL" />
- إضافة: <policy domain="coder" rights="none" pattern="MVG" />
- إضافة: <policy domain="coder" rights="none" pattern="MSL" />
- إضافة: <policy domain="coder" rights="none" pattern="HTTPS" />
- إضافة: <policy domain="coder" rights="none" pattern="HTTP" />
3. التحقق من جميع ملفات الصور المرفوعة باستخدام فحص البايتات السحرية قبل تمريرها إلى ImageMagick
4. تشغيل ImageMagick في بيئة معزولة مع أقل صلاحيات ممكنة لنظام الملفات
5. النظر في التحول إلى مكتبات بديلة لمعالجة الصور (مثل libvips أو Pillow) حيثما أمكن
قواعد الكشف:
- مراقبة سلاسل 'ephemeral:' في الملفات المرفوعة وسجلات معالجة الصور
- التنبيه عند حذف ملفات غير متوقعة في مجلدات تطبيقات الويب
- تطبيق قواعد جدار حماية تطبيقات الويب لحظر الطلبات المحتوية على مراجع بروتوكولات ImageMagick الزائفة