
PHP-FPM ثغرة تنفيذ الأوامر عن بُعد (CVE-2019-11043) POC بلغة Python
1.وصف الثغرة عند معالجة الطلبات التي تحتوي على %0a، يؤدي fastcgi split path info في Nginx إلى أن تصبح PATH INFO فارغة بسبب مواجهة حرف السطر الجديد \n. وفي حالة معالجة php-fpm لـ PATH INFO الفارغة، يوجد عيب منطقي. من خلال الإنشاء والاستغلال الدقيق، يمكن للمهاجم أن يؤدي إلى تنفيذ كود عن بُعد.
نطاق التأثير خوادم Nginx + php-fpm التي تستخدم التكوين التالي قد تكون عرضة لثغرة تنفيذ كود عن بُعد. location ~ [^ /小.php(/|$) { fastcgi split path info ^(.+ ?.php)(.*)$; fastcgi param PATH INFO $fastcgi path info;fastcgi pass php:9000; }
2.كشف الثغرة الخيار الأول: الكشف باستخدام سكربت phuip-fpizdam
0x01 تثبيت phuip-fpizdam على Mac go get github.com/neex/phuip-fpizdam go install github.com/neex/phuip-fpizdam ➜ ~ cd ./go ➜ go go get github.com/neex/phuip-fpizdam ➜ go go install github.com/neex/phuip-fpizdam ➜ go ls bin src ➜ go cd bin ➜ bin ls phuip-fpizdam ➜ bin file phuip-fpizdam phuip-fpizdam: Mach-O 64-bit executable x86_64
➜ bin ls -lah phuip-fpizdam -rwxr-xr-x 1 alewong staff 9.3M 10 24 10:54 phuip-fpizdam
bin ./phuip-fpizdam
Error: accepts 1 arg(s), received 0 Usage: phuip-fpizdam [url] [flags]
Flags:
--cookie string send this cookie
-h, --help help for phuip-fpizdam --kill-count int how many times to send the worker killing payload (default 50) --kill-workers just kill php-fpm workers (requires only QSL) --method string detect method (see detect_methods.go) (default "session.auto_start") --only-qsl stop after QSL detection, use this if you just want to check if the server is vulnerable --pisos int pisos hint --qsl int qsl hint --reset-retries int how many retries to do for --reset-setting, -1 means a lot (default 50) --reset-setting try to reset setting (requires attack params) --setting string specify custom php.ini setting for --reset-setting --skip-attack skip attack phase --skip-detect skip detection phase 2019/10/24 10:56:18 accepts 1 arg(s), received 0
0x03 التحقق من عنوان URL الهدف
يمكن رؤية أن نتيجة الإرجاع هي 202، نجاح
0x04 عرض حالة صفحة الويب


الخيار الثاني: الكشف باستخدام سكربت Python

فكرة السكربت: عندما تصل قيمة العتبة Q إلى قيمة معينة مثل 1800، فإنها تُرجع 502، مما يثبت وجود الثغرة.
نتيجة التشغيل:

متسقة مع نتائج Burp Suite
