Artifex Ghostscript Type Confusion Vulnerability — Artifex Ghostscript allows -dSAFER bypass and remote command execution via .rsdparams type confusion with a "/OutputFile.
CVE-2017-8291 is a critical type confusion vulnerability in Artifex Ghostscript that allows attackers to bypass the -dSAFER sandbox and achieve remote command execution via crafted PostScript files using .rsdparams type confusion with /OutputFile. This vulnerability has a CVSS score of 9.0 and known exploits are actively available in the wild, making it extremely dangerous. It has been weaponized in real-world attacks, including through malicious document files processed by applications that rely on Ghostscript for rendering. Organizations using any software that processes PostScript, PDF, or EPS files through Ghostscript are at immediate risk.
Immediate Actions:
1. Identify all systems running Ghostscript by scanning for gs, ghostscript binaries and libgs across all servers and workstations
2. Update Ghostscript to version 9.22 or later immediately, which contains the fix for this vulnerability
3. If immediate patching is not possible, disable Ghostscript processing entirely or restrict it to trusted inputs only
Compensating Controls:
1. Remove or disable Ghostscript from web-facing servers and application servers that process untrusted input
2. Implement application-level filtering to block PostScript and EPS file uploads
3. Use AppArmor or SELinux profiles to restrict Ghostscript's ability to execute commands or write to arbitrary files
4. Deploy network segmentation to isolate document processing systems
Detection Rules:
1. Monitor for Ghostscript processes spawning unexpected child processes (shell commands)
2. Create YARA rules to detect PostScript files containing .rsdparams and /OutputFile patterns
3. Implement IDS/IPS signatures for known exploit payloads targeting CVE-2017-8291
4. Monitor file system activity for unexpected file writes by Ghostscript processes
Long-term:
1. Consider replacing Ghostscript with alternative PDF processing libraries where possible
2. Implement regular vulnerability scanning for all document processing components
الإجراءات الفورية:
1. تحديد جميع الأنظمة التي تشغل Ghostscript عن طريق فحص ملفات gs و ghostscript و libgs عبر جميع الخوادم ومحطات العمل
2. تحديث Ghostscript إلى الإصدار 9.22 أو أحدث فوراً والذي يحتوي على إصلاح هذه الثغرة
3. إذا لم يكن التحديث الفوري ممكناً، قم بتعطيل معالجة Ghostscript بالكامل أو تقييدها للمدخلات الموثوقة فقط
الضوابط التعويضية:
1. إزالة أو تعطيل Ghostscript من الخوادم المواجهة للإنترنت وخوادم التطبيقات التي تعالج مدخلات غير موثوقة
2. تطبيق تصفية على مستوى التطبيق لحظر تحميل ملفات PostScript و EPS
3. استخدام ملفات تعريف AppArmor أو SELinux لتقييد قدرة Ghostscript على تنفيذ الأوامر أو الكتابة في ملفات عشوائية
4. نشر تجزئة الشبكة لعزل أنظمة معالجة المستندات
قواعد الكشف:
1. مراقبة عمليات Ghostscript التي تنشئ عمليات فرعية غير متوقعة (أوامر shell)
2. إنشاء قواعد YARA للكشف عن ملفات PostScript التي تحتوي على أنماط .rsdparams و /OutputFile
3. تطبيق توقيعات IDS/IPS للحمولات المعروفة التي تستهدف CVE-2017-8291
4. مراقبة نشاط نظام الملفات للكتابات غير المتوقعة بواسطة عمليات Ghostscript
على المدى الطويل:
1. النظر في استبدال Ghostscript بمكتبات بديلة لمعالجة PDF حيثما أمكن
2. تطبيق فحص منتظم للثغرات لجميع مكونات معالجة المستندات