MongoDB mongo-express Remote Code Execution Vulnerability — mongo-express before 0.54.0 is vulnerable to Remote Code Execution via endpoints that uses the `toBSON` method.
CVE-2019-10758 is a critical Remote Code Execution (RCE) vulnerability in mongo-express, a web-based MongoDB admin interface, affecting versions prior to 0.54.0. The flaw exists in endpoints utilizing the `toBSON` method, which can be exploited by attackers to execute arbitrary code on the underlying server without authentication in many default deployments. With a CVSS score of 9.0 and a publicly available exploit, this vulnerability poses an immediate and severe threat to any organization exposing mongo-express to internal or external networks. Organizations using MongoDB with mongo-express as an administrative interface must treat this as an urgent remediation priority.
IMMEDIATE ACTIONS:
1. Identify all instances of mongo-express deployed across your environment using asset inventory tools.
2. Immediately restrict network access to mongo-express interfaces using firewall rules — block all external access and limit internal access to authorized IP ranges only.
3. Take mongo-express instances offline if they are internet-facing until patched.
4. Review access logs for signs of exploitation — look for unusual POST requests to BSON-related endpoints.
PATCHING GUIDANCE:
1. Upgrade mongo-express to version 0.54.0 or later immediately.
2. Use package managers: npm install mongo-express@latest or update Docker images if containerized.
3. Verify the upgrade by checking the installed version: npm list mongo-express.
COMPENSATING CONTROLS (if patching is delayed):
1. Place mongo-express behind a VPN or bastion host — never expose directly to the internet.
2. Implement HTTP Basic Authentication or SSO in front of mongo-express.
3. Deploy a Web Application Firewall (WAF) with rules to block BSON injection patterns.
4. Enable application-level logging and forward to SIEM for anomaly detection.
DETECTION RULES:
1. SIEM: Alert on HTTP POST requests containing 'toBSON' or BSON-related payloads in request bodies.
2. IDS/IPS: Create signatures for known exploit payloads targeting CVE-2019-10758.
3. Monitor for unexpected child processes spawned by the Node.js mongo-express process.
4. Check for outbound connections from MongoDB servers to unknown external IPs.
الإجراءات الفورية:
1. تحديد جميع نسخ mongo-express المنتشرة في بيئتك باستخدام أدوات جرد الأصول.
2. تقييد الوصول الشبكي فوراً لواجهات mongo-express عبر قواعد جدار الحماية — حظر الوصول الخارجي وتقييد الوصول الداخلي لنطاقات IP المصرح بها فقط.
3. إيقاف نسخ mongo-express المكشوفة على الإنترنت فوراً حتى يتم تطبيق التحديث.
4. مراجعة سجلات الوصول للكشف عن علامات الاستغلال — البحث عن طلبات POST غير معتادة لنقاط النهاية المرتبطة بـ BSON.
إرشادات التحديث:
1. ترقية mongo-express إلى الإصدار 0.54.0 أو أحدث فوراً.
2. استخدام مديري الحزم: npm install mongo-express@latest أو تحديث صور Docker إذا كانت في حاويات.
3. التحقق من الترقية بفحص الإصدار المثبت: npm list mongo-express.
ضوابط التعويض (في حال تأخر التحديث):
1. وضع mongo-express خلف VPN أو خادم وسيط — عدم الكشف المباشر على الإنترنت.
2. تطبيق المصادقة الأساسية HTTP أو SSO أمام mongo-express.
3. نشر جدار حماية تطبيقات الويب (WAF) مع قواعد لحظر أنماط حقن BSON.
4. تفعيل تسجيل الأحداث على مستوى التطبيق وإرسالها إلى SIEM للكشف عن الشذوذات.
قواعد الكشف:
1. SIEM: تنبيه على طلبات HTTP POST التي تحتوي على 'toBSON' أو حمولات BSON في أجسام الطلبات.
2. IDS/IPS: إنشاء توقيعات لحمولات الاستغلال المعروفة المستهدفة لـ CVE-2019-10758.
3. مراقبة العمليات الفرعية غير المتوقعة التي تنشئها عملية Node.js الخاصة بـ mongo-express.
4. فحص الاتصالات الصادرة من خوادم MongoDB إلى عناوين IP خارجية غير معروفة.