PHP遠程代碼執行漏洞:CVE-2019-11043


漏洞詳情:
Nginx上fastcgi_split_path_info在處理帶有 %0a 的請求時,會因為遇到換行符 \n 導致PATH_INFO為空。而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;
...
}
}
php支持php-fpm,在編譯php源碼的時候會帶上 --enable-fpm
復現環境:
docker鏡像
docker pull php:7.2.3-fpm
docker pull nginx
然后啟動一個php
echo '<?php phpinfo();>' /var/www/html/index.php
docker run --name phpfpm -d -v /var/www/html:/app docker.io/php
然后配置然后是Nginx 的配置文件文件放在/root/nginx.conf
user root root;
worker_processes auto;
error_log /tmp/nginx_error.log crit;
pid /tmp/nginx.pid;
worker_rlimit_nofile 51200;

events
{
use epoll;
worker_connections 51200;
multi_accept on;
}

http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;

server
{
listen 80;
server_name www.test.cn;
index index.html index.htm index.php;
root /app;
location ~ [^/]\.php(/|$){
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param REDIRECT_STATUS 200;
fastcgi_param SCRIPT_FILENAME /app$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT /app;
fastcgi_pass phpfpm:9000;
}
access_log /tmp/access.log;
}
}
啟動Nginx
docker run --name nginx_server -d -p 8080:80 --link phpfpm:phpfpm -v /root/nginx.conf:/etc/nginx/nginx.conf --volumes-from phpfpm nginx

 

 


測試OK下載工具
https://github.com/neex/phuip-fpizdam

 

 

訪問http://your-ip:8080/index.php?a=id

 

 

解決方案:
修改nginx配置文件中fastcgi_split_path_info的正則表達式,不允許.php之后傳入不可顯字符
在不影響正常業務的情況下,刪除Nginx配置文件中的如下配置:
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM