OpenMRS Core is an open source electronic medical record system platform. In versions 2.7.8 and earlier and versions 2.8.0 through 2.8.5, the module upload endpoint at POST `/openmrs/ws/rest/v1/module` is vulnerable to a Zip Slip path traversal attack. During automatic extraction of uploaded .omod archives in `WebModuleUtil.startModule()`, ZIP entries under web/module/ are checked only to see whether the full entry path starts with `..,` and the remaining path is then concatenated into the destination path without normalization or a boundary check. A crafted archive can therefore include entries such as `web/module/../../../../malicious.jsp` and cause files to be written outside the intended module directory.
An authenticated attacker with module upload access can write arbitrary files to locations such as the web application root and achieve remote code execution by uploading a JSP file and then requesting it. The issue is compounded by the fact that the module.allow_web_admin runtime property is enforced in the legacy UI controller but not in the REST API upload path, so deployments relying on that property to block web-based module administration remain exposed through the REST endpoint. This issue has been fixed in versions after 2.7.8 in the 2.7.x line and in version 2.8.6 and later.
OpenMRS Core versions 2.7.8 and earlier, and 2.8.0-2.8.5 contain a critical Zip Slip path traversal vulnerability in the module upload REST endpoint that allows authenticated attackers to write arbitrary files outside the intended directory and achieve remote code execution. The vulnerability bypasses the module.allow_web_admin security property in the REST API, creating a significant risk for healthcare organizations using affected versions. Exploitation requires module upload access but can lead to complete system compromise through JSP file injection.
IMMEDIATE ACTIONS:
1. Identify all OpenMRS deployments running versions 2.7.8 or earlier, and 2.8.0-2.8.5
2. Restrict access to the POST /openmrs/ws/rest/v1/module endpoint to trusted administrators only
3. Implement network-level access controls to limit module upload API access
4. Review audit logs for unauthorized module upload attempts
5. Verify module.allow_web_admin property is enforced (note: REST API bypasses this)
PATCHING GUIDANCE:
1. Upgrade to OpenMRS 2.7.9 or later (2.7.x line) or 2.8.6 or later (2.8.x line)
2. Test patches in non-production environment before deployment
3. Backup all data and configurations before upgrading
COMPENSATING CONTROLS (if immediate patching not possible):
1. Disable the REST module upload endpoint at the reverse proxy/WAF level
2. Implement strict input validation on uploaded .omod files
3. Use Web Application Firewall (WAF) rules to block path traversal patterns (../, ..\ sequences)
4. Implement file integrity monitoring on web application root directory
5. Restrict file write permissions on the application server
DETECTION RULES:
1. Monitor POST requests to /openmrs/ws/rest/v1/module for suspicious patterns
2. Alert on any .omod uploads containing path traversal sequences (../, ..\)
3. Monitor for JSP file creation in unexpected directories
4. Track failed and successful module uploads with source IP and user
5. Monitor web application root directory for unauthorized file modifications
الإجراءات الفورية:
1. تحديد جميع نشرات OpenMRS التي تعمل بالإصدارات 2.7.8 أو الإصدارات السابقة، و 2.8.0-2.8.5
2. تقييد الوصول إلى نقطة نهاية POST /openmrs/ws/rest/v1/module للمسؤولين الموثوقين فقط
3. تنفيذ عناصر تحكم الوصول على مستوى الشبكة لتحديد وصول واجهة برمجة التطبيقات لتحميل الوحدات
4. مراجعة سجلات التدقيق لمحاولات تحميل الوحدات غير المصرح بها
5. التحقق من فرض خاصية module.allow_web_admin (ملاحظة: واجهة برمجة التطبيقات REST تتجاوز هذا)
إرشادات التصحيح:
1. الترقية إلى OpenMRS 2.7.9 أو إصدار أحدث (سطر 2.7.x) أو 2.8.6 أو إصدار أحدث (سطر 2.8.x)
2. اختبار التصحيحات في بيئة غير الإنتاج قبل النشر
3. النسخ الاحتياطي لجميع البيانات والتكوينات قبل الترقية
عناصر التحكم التعويضية (إذا لم يكن الترقية الفورية ممكنة):
1. تعطيل نقطة نهاية تحميل وحدة REST على مستوى الوكيل العكسي/WAF
2. تنفيذ التحقق من صحة الإدخال الصارم على ملفات .omod المرفوعة
3. استخدام قواعد جدار حماية تطبيقات الويب (WAF) لحظر أنماط اجتياز المسار (../, ..\)
4. تنفيذ مراقبة سلامة الملفات في دليل جذر تطبيق الويب
5. تقييد أذونات كتابة الملفات على خادم التطبيق
قواعد الكشف:
1. مراقبة طلبات POST إلى /openmrs/ws/rest/v1/module للأنماط المريبة
2. التنبيه على أي تحميلات .omod تحتوي على أنماط اجتياز المسار (../, ..\)
3. مراقبة إنشاء ملفات JSP في الدلائل غير المتوقعة
4. تتبع عمليات تحميل الوحدات الفاشلة والناجحة مع عنوان IP والمستخدم
5. مراقبة دليل جذر تطبيق الويب للتعديلات غير المصرح بها على الملفات