LiteLLM is a proxy server (AI Gateway) to call LLM APIs in OpenAI (or native) format. From version 1.74.2 to before version 1.83.7, two endpoints used to preview an MCP server before saving it — POST /mcp-rest/test/connection and POST /mcp-rest/test/tools/list — accepted a full server configuration in the request body, including the command, args, and env fields used by the stdio transport. When called with a stdio configuration, the endpoints attempted to connect, which spawned the supplied command as a subprocess on the proxy host with the privileges of the proxy process. The endpoints were gated only by a valid proxy API key, with no role check. Any authenticated user — including holders of low-privilege internal-user keys — could therefore run arbitrary commands on the host. This issue has been patched in version 1.83.7.
LiteLLM versions 1.74.2 to 1.83.6 contain a critical command injection vulnerability in MCP server preview endpoints that allows authenticated users with low-privilege API keys to execute arbitrary commands on the proxy host. The vulnerability affects two endpoints (/mcp-rest/test/connection and /mcp-rest/test/tools/list) that lack proper role-based access controls and validation of server configuration parameters. This poses an immediate risk to organizations using LiteLLM as an AI Gateway, potentially enabling lateral movement and system compromise.
IMMEDIATE ACTIONS:
1. Identify all LiteLLM deployments in your environment and document their versions
2. Restrict network access to LiteLLM proxy endpoints to trusted internal networks only
3. Revoke or rotate all low-privilege API keys immediately
4. Enable comprehensive audit logging for all /mcp-rest/* endpoint calls
5. Monitor process execution logs for suspicious subprocess spawning
PATCHING GUIDANCE:
1. Upgrade LiteLLM to version 1.83.7 or later immediately
2. Test patches in non-production environments first
3. Implement staged rollout with monitoring for production systems
4. Verify patch application by checking version output
COMPENSATING CONTROLS (if immediate patching not possible):
1. Disable MCP server preview endpoints entirely if not required
2. Implement network-level access controls restricting /mcp-rest/test/* endpoints to administrative users only
3. Deploy Web Application Firewall (WAF) rules to block requests to vulnerable endpoints
4. Implement API gateway authentication requiring multi-factor authentication for MCP operations
5. Use container/VM isolation to limit blast radius of command execution
DETECTION RULES:
1. Alert on POST requests to /mcp-rest/test/connection or /mcp-rest/test/tools/list endpoints
2. Monitor for subprocess spawning from LiteLLM process with unusual parent-child relationships
3. Detect API calls with stdio transport configurations in request bodies
4. Flag authentication events using low-privilege internal-user keys accessing MCP endpoints
5. Monitor for command execution patterns in LiteLLM process logs (bash, sh, cmd.exe, powershell)
الإجراءات الفورية:
1. حدد جميع نشرات LiteLLM في بيئتك وتوثيق إصداراتها
2. قيّد الوصول إلى شبكة نقاط نهاية وكيل LiteLLM للشبكات الداخلية الموثوقة فقط
3. أبطل أو أعد تعيين جميع مفاتيح API منخفضة الامتيازات فوراً
4. فعّل تسجيل التدقيق الشامل لجميع استدعاءات نقطة النهاية /mcp-rest/*
5. راقب سجلات تنفيذ العملية للبحث عن عمليات فرعية مريبة
إرشادات التصحيح:
1. ارقِ LiteLLM إلى الإصدار 1.83.7 أو أحدث فوراً
2. اختبر التصحيحات في بيئات غير الإنتاج أولاً
3. طبّق الطرح المرحلي مع المراقبة لأنظمة الإنتاج
4. تحقق من تطبيق التصحيح بفحص إخراج الإصدار
عناصر التحكم التعويضية (إذا لم يكن التصحيح الفوري ممكناً):
1. عطّل نقاط نهاية معاينة خادم MCP بالكامل إذا لم تكن مطلوبة
2. طبّق عناصر تحكم الوصول على مستوى الشبكة تقيد نقاط النهاية /mcp-rest/test/* للمستخدمين الإداريين فقط
3. نشّر قواعد جدار حماية تطبيقات الويب (WAF) لحظر الطلبات إلى نقاط النهاية الضعيفة
4. طبّق مصادقة بوابة API تتطلب المصادقة متعددة العوامل لعمليات MCP
5. استخدم عزل الحاوية/الآلة الافتراضية لتحديد نطاق تأثير تنفيذ الأوامر
قواعد الكشف:
1. تنبيهات على طلبات POST إلى نقاط النهاية /mcp-rest/test/connection أو /mcp-rest/test/tools/list
2. راقب عمليات فرعية تنفيذ من عملية LiteLLM بعلاقات أب-طفل غير عادية
3. كشف استدعاءات API بتكوينات نقل stdio في أجسام الطلب
4. علّم أحداث المصادقة باستخدام مفاتيح المستخدم الداخلي منخفضة الامتيازات للوصول إلى نقاط نهاية MCP
5. راقب أنماط تنفيذ الأوامر في سجلات عملية LiteLLM (bash, sh, cmd.exe, powershell)