Junrar is an open source java RAR archive library. Prior to version 7.5.8, a backslash path traversal vulnerability in `LocalFolderExtractor` allows an attacker to write arbitrary files with attacker-controlled content anywhere on the filesystem when a crafted RAR archive is extracted on Linux/Unix. This can often lead to remote code execution (e.g., overwriting shell profiles, source code, cron jobs, etc). Version 7.5.8 has a fix for the issue.
Junrar versions prior to 7.5.8 contain a path traversal vulnerability (CWE-22) that allows attackers to write arbitrary files to the filesystem when extracting crafted RAR archives on Linux/Unix systems. This vulnerability can lead to remote code execution through overwriting critical files such as shell profiles, source code, or cron jobs. With an available exploit and patch, immediate remediation is required for all organizations using vulnerable Junrar versions in production environments.
Immediate Actions:
1. Identify all applications and services using Junrar library across your infrastructure
2. Audit logs for any RAR file extraction activities, particularly from untrusted sources
3. Implement network-level controls to restrict RAR file uploads from external sources
Patching Guidance:
1. Upgrade Junrar to version 7.5.8 or later immediately
2. Update all dependent applications and services that embed Junrar
3. Test patches in non-production environments before deployment
4. Prioritize patching for systems processing user-supplied RAR files
Compensating Controls (if immediate patching not possible):
1. Disable RAR extraction functionality if not critical to operations
2. Implement strict file upload validation - reject RAR files from untrusted sources
3. Run RAR extraction processes in isolated containers/sandboxes with minimal filesystem permissions
4. Use AppArmor or SELinux profiles to restrict file write operations from Java processes
5. Monitor extraction operations with strict file integrity checking
Detection Rules:
1. Monitor for unexpected file writes outside designated extraction directories
2. Alert on modifications to shell profiles (.bashrc, .bash_profile, .zshrc)
3. Track changes to cron job files (/etc/cron.d/, /var/spool/cron/)
4. Monitor Java process file descriptor activity for suspicious path patterns containing backslashes on Unix systems
5. Implement YARA rules to detect malicious RAR archive structures
الإجراءات الفورية:
1. تحديد جميع التطبيقات والخدمات التي تستخدم مكتبة Junrar عبر البنية التحتية الخاصة بك
2. مراجعة السجلات لأي أنشطة استخراج ملفات RAR، خاصة من مصادر غير موثوقة
3. تطبيق عناصر تحكم على مستوى الشبكة لتقييد تحميلات ملفات RAR من مصادر خارجية
إرشادات التصحيح:
1. ترقية Junrar إلى الإصدار 7.5.8 أو أحدث فوراً
2. تحديث جميع التطبيقات والخدمات التابعة التي تتضمن Junrar
3. اختبار التصحيحات في بيئات غير الإنتاج قبل النشر
4. إعطاء الأولوية لتصحيح الأنظمة التي تعالج ملفات RAR المزودة من قبل المستخدم
عناصر التحكم البديلة (إذا لم يكن التصحيح الفوري ممكناً):
1. تعطيل وظيفة استخراج RAR إذا لم تكن حرجة للعمليات
2. تطبيق التحقق الصارم من تحميل الملفات - رفض ملفات RAR من مصادر غير موثوقة
3. تشغيل عمليات استخراج RAR في حاويات/بيئات معزولة بأذونات نظام ملفات محدودة
4. استخدام ملفات تعريف AppArmor أو SELinux لتقييد عمليات كتابة الملفات من عمليات Java
5. مراقبة عمليات الاستخراج مع فحص سلامة الملفات الصارم
قواعد الكشف:
1. مراقبة عمليات كتابة الملفات غير المتوقعة خارج أدلة الاستخراج المخصصة
2. التنبيه على التعديلات على ملفات تعريف الأوامر (.bashrc, .bash_profile, .zshrc)
3. تتبع التغييرات على ملفات مهام cron (/etc/cron.d/, /var/spool/cron/)
4. مراقبة نشاط وصف الملف لعملية Java للأنماط المريبة التي تحتوي على شرطات مائلة عكسية على أنظمة Unix
5. تطبيق قواعد YARA للكشف عن هياكل أرشيف RAR الضارة