Rails Ruby on Rails Path Traversal Vulnerability — Rails Ruby on Rails contains a path traversal vulnerability in Action View. Specially crafted accept headers in combination with calls to `render file:` can cause arbitrary files on the target server to be rendered, disclosing the file contents.
CVE-2019-5418 is a critical path traversal vulnerability in Ruby on Rails' Action View component that allows unauthenticated remote attackers to read arbitrary files from the target server by sending specially crafted HTTP Accept headers combined with render file: calls. With a CVSS score of 9.0 and a publicly available exploit, this vulnerability poses an immediate and severe risk to any organization running unpatched Rails applications. Sensitive files such as /etc/passwd, database configuration files, secret keys, and credentials can be exfiltrated without authentication. This vulnerability is actively exploited in the wild and has been included in CISA's Known Exploited Vulnerabilities catalog.
IMMEDIATE ACTIONS:
1. Identify all Ruby on Rails applications in your environment using asset inventory tools.
2. Check Rails version: run 'bundle exec rails --version' on all app servers.
3. Audit all controllers for use of 'render file:' pattern immediately.
PATCHING GUIDANCE:
4. Upgrade to Rails 6.0.0.beta3, 5.2.2.1, 5.1.6.2, 5.0.7.2, or 4.2.11.1 — all contain the fix.
5. Run 'bundle update rails' and redeploy all affected applications.
6. Verify patch by checking Rails version post-update.
COMPENSATING CONTROLS (if patching is delayed):
7. Deploy WAF rules to block requests with Accept headers containing '../' or null bytes or path traversal patterns.
8. Restrict or remove all 'render file:' calls in application code as an emergency code change.
9. Implement strict input validation on Accept headers at the reverse proxy (Nginx/Apache) level.
10. Apply file system permissions to restrict web application user access to sensitive files.
DETECTION RULES:
11. Monitor web access logs for Accept headers containing '../', '%2e%2e', or '/etc/' patterns.
12. Create SIEM alerts for HTTP 200 responses to requests with anomalous Accept headers.
13. Deploy Snort/Suricata rule: alert http any any -> any any (msg:'CVE-2019-5418 Rails Path Traversal'; content:'../'; http_header; sid:9005418;)
14. Review application logs for unexpected file render operations.
الإجراءات الفورية:
1. حدد جميع تطبيقات Ruby on Rails في بيئتك باستخدام أدوات جرد الأصول.
2. تحقق من إصدار Rails: شغّل 'bundle exec rails --version' على جميع خوادم التطبيقات.
3. راجع جميع المتحكمات (controllers) بحثاً عن استخدام نمط 'render file:' فوراً.
إرشادات التصحيح:
4. قم بالترقية إلى Rails 6.0.0.beta3 أو 5.2.2.1 أو 5.1.6.2 أو 5.0.7.2 أو 4.2.11.1 — جميعها تحتوي على الإصلاح.
5. شغّل 'bundle update rails' وأعد نشر جميع التطبيقات المتأثرة.
6. تحقق من التصحيح بفحص إصدار Rails بعد التحديث.
ضوابط التعويض (إذا تأخر التصحيح):
7. انشر قواعد WAF لحجب الطلبات التي تحتوي ترويسات Accept على '../' أو بايتات فارغة أو أنماط اجتياز المسار.
8. أزل أو قيّد جميع استدعاءات 'render file:' في كود التطبيق كتغيير طارئ.
9. طبّق التحقق الصارم من المدخلات على ترويسات Accept على مستوى الوكيل العكسي (Nginx/Apache).
10. طبّق أذونات نظام الملفات لتقييد وصول مستخدم تطبيق الويب إلى الملفات الحساسة.
قواعد الكشف:
11. راقب سجلات الوصول للويب بحثاً عن ترويسات Accept تحتوي على '../' أو '%2e%2e' أو '/etc/'.
12. أنشئ تنبيهات SIEM لاستجابات HTTP 200 للطلبات ذات ترويسات Accept غير طبيعية.
13. انشر قاعدة Snort/Suricata للكشف عن محاولات الاستغلال.
14. راجع سجلات التطبيق بحثاً عن عمليات عرض ملفات غير متوقعة.