ThinkPHP Remote Code Execution Vulnerability — ThinkPHP contains an unspecified vulnerability that allows for remote code execution via public//?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]= followed by the command.
CVE-2019-9082 is a critical remote code execution vulnerability in the ThinkPHP PHP framework, actively exploited in the wild since 2019. Attackers can execute arbitrary system commands by crafting a malicious URL targeting the framework's routing mechanism without any authentication. The vulnerability has a public exploit and has been weaponized in numerous campaigns targeting web applications globally. Given the widespread use of ThinkPHP in Chinese-developed web applications and enterprise portals, Saudi organizations running such applications face immediate risk of full server compromise.
IMMEDIATE ACTIONS (0-24 hours):
1. Identify all internet-facing applications using ThinkPHP framework across your environment using asset inventory and web application scanning tools.
2. Block or restrict public access to vulnerable URL patterns containing '?s=index/\think\app/invokefunction' at the WAF or perimeter firewall immediately.
3. Review web server access logs for exploitation attempts using patterns: 'invokefunction', 'call_user_func_array', 'think\app', 'vars[0]=system'.
PATCHING GUIDANCE:
1. Upgrade ThinkPHP to version 5.0.24 or 5.1.31 or later, which contain fixes for this RCE vulnerability.
2. If immediate patching is not possible, disable or restrict the affected routing mechanism in the framework configuration.
3. Validate all third-party vendor applications for ThinkPHP usage and enforce patching SLAs.
COMPENSATING CONTROLS:
1. Deploy WAF rules to block requests matching the exploit pattern: block URIs containing 'invokefunction' and 'call_user_func_array'.
2. Implement application-level input validation and disable dangerous PHP functions (system, exec, passthru, shell_exec) in php.ini where feasible.
3. Run web applications under least-privilege OS accounts to limit post-exploitation impact.
4. Enable PHP disable_functions directive to restrict system-level calls.
5. Segment web application servers from internal networks using strict firewall rules.
DETECTION RULES:
1. SIEM alert: HTTP requests containing 'invokefunction' AND 'call_user_func_array' in URI.
2. IDS/IPS signature: Match GET/POST requests with pattern '/\think\app/invokefunction'.
3. Monitor for unusual child processes spawned by web server processes (e.g., apache/nginx spawning bash/sh/cmd).
4. Alert on outbound connections from web server processes to unknown external IPs.
الإجراءات الفورية (خلال 0-24 ساعة):
1. تحديد جميع التطبيقات المواجهة للإنترنت التي تستخدم إطار ThinkPHP عبر جرد الأصول وأدوات فحص تطبيقات الويب.
2. حجب أو تقييد الوصول العام لأنماط URL الضعيفة التي تحتوي على '?s=index/\think\app/invokefunction' فوراً على مستوى جدار حماية تطبيقات الويب أو جدار الحماية المحيطي.
3. مراجعة سجلات الوصول لخوادم الويب بحثاً عن محاولات الاستغلال باستخدام الأنماط: 'invokefunction'، 'call_user_func_array'، 'think\app'، 'vars[0]=system'.
إرشادات التصحيح:
1. الترقية إلى ThinkPHP الإصدار 5.0.24 أو 5.1.31 أو أحدث.
2. في حال تعذّر التصحيح الفوري، تعطيل آلية التوجيه المتأثرة في إعدادات الإطار.
3. التحقق من جميع تطبيقات الموردين الخارجيين لاستخدام ThinkPHP وفرض مواعيد نهائية للتصحيح.
ضوابط التعويض:
1. نشر قواعد WAF لحجب الطلبات المطابقة لنمط الاستغلال.
2. تطبيق التحقق من صحة المدخلات على مستوى التطبيق وتعطيل وظائف PHP الخطرة.
3. تشغيل تطبيقات الويب تحت حسابات نظام التشغيل ذات الصلاحيات المحدودة.
4. تفعيل توجيه disable_functions في PHP لتقييد استدعاءات مستوى النظام.
5. عزل خوادم تطبيقات الويب عن الشبكات الداخلية بقواعد جدار حماية صارمة.
قواعد الكشف:
1. تنبيه SIEM: طلبات HTTP تحتوي على 'invokefunction' و'call_user_func_array' في URI.
2. توقيع IDS/IPS: مطابقة طلبات GET/POST بنمط '/\think\app/invokefunction'.
3. مراقبة العمليات الفرعية غير المعتادة التي تنشئها عمليات خادم الويب.
4. التنبيه على الاتصالات الصادرة من عمليات خادم الويب إلى عناوين IP خارجية مجهولة.