在PHP中使用FastCGI解析漏洞及修复方案_PHP
漏洞描述:
Nginx默认是以CGI的方式支持PHP解析的,普遍的做法是在Nginx配置文件中通过正则匹配设置SCRIPT_FILENAME。当访问http://192.168.1.102/phpinfo.jpg/1.php这个URL时,$fastcgi_script_name会被设置为“phpinfo.jpg/1.php”,然后构造成SCRIPT_FILENAME传递给PHP CGI。如果PHP中开启了fix_pathinfo这个选项,PHP会认为SCRIPT_FILENAME是phpinfo.jpg,而1.php是PATH_INFO,所以就会将phpinfo.jpg作为PHP文件来解析了。
漏洞危害:
WebServer Fastcgi配置不当,会造成其他文件(例如css,js,jpg等静态文件)被当成php脚本解析执行。当用户将恶意脚本webshell改为静态文件上传到webserver传递给后端php解析执行后,会让攻击者获得服务器的操作权限。
修复方案:
(Nginx用户可以选择方案一或方案二,IIS用户请使用方案一)
方案一,修改php.ini文件,将cgi.fix_pathinfo的值设置为0。完成后请重启PHP和NGINX(IIS)。
方案二,在Nginx配置文件中添加以下代码:
代码如下:
if ( $fastcgi_script_name ~ \..*\/.*php ) {
return 403;
}
这行代码的意思是当匹配到类似test.jpg/a.php的URL时,将返回403错误代码。修改完成后请重启Nginx。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Is the F5 key not working properly on your Windows 11/10 PC? The F5 key is typically used to refresh the desktop or explorer or reload a web page. However, some of our readers have reported that the F5 key is refreshing their computers and not working properly. How to enable F5 refresh in Windows 11? To refresh your Windows PC, just press the F5 key. On some laptops or desktops, you may need to press the Fn+F5 key combination to complete the refresh operation. Why doesn't F5 refresh work? If pressing the F5 key fails to refresh your computer or you are experiencing issues on Windows 11/10, it may be due to the function keys being locked. Other potential causes include the keyboard or F5 key

In less than a minute and no more than 20 steps, you can bypass security restrictions and successfully jailbreak a large model! And there is no need to know the internal details of the model - only two black box models need to interact, and the AI can fully automatically defeat the AI and speak dangerous content. I heard that the once-popular "Grandma Loophole" has been fixed: Now, facing the "Detective Loophole", "Adventurer Loophole" and "Writer Loophole", what response strategy should artificial intelligence adopt? After a wave of onslaught, GPT-4 couldn't stand it anymore, and directly said that it would poison the water supply system as long as... this or that. The key point is that this is just a small wave of vulnerabilities exposed by the University of Pennsylvania research team, and using their newly developed algorithm, AI can automatically generate various attack prompts. Researchers say this method is better than existing

Buffer overflow vulnerabilities in Java and their harm Buffer overflow means that when we write more data to a buffer than its capacity, it will cause data to overflow to other memory areas. This overflow behavior is often exploited by hackers, which can lead to serious consequences such as abnormal code execution and system crash. This article will introduce buffer overflow vulnerabilities and their harm in Java, and give code examples to help readers better understand. The buffer classes widely used in Java include ByteBuffer, CharBuffer, and ShortB

In the development of web applications, the file upload function has become a basic requirement. This feature allows users to upload their own files to the server and then store or process them on the server. However, this feature also makes developers need to pay more attention to a security vulnerability: the file upload vulnerability. Attackers can attack the server by uploading malicious files, causing the server to suffer varying degrees of damage. PHP language is one of the languages widely used in web development, and file upload vulnerabilities are also one of the common security issues. This article will introduce

According to news on February 2, Shane Jones, manager of Microsoft’s software engineering department, recently discovered a vulnerability in OpenAI’s DALL-E3 model, which is said to be able to generate a series of inappropriate content. Shane Jones reported the vulnerability to the company, but was asked to keep it confidential. However, he eventually decided to disclose the vulnerability to the outside world. ▲Image source: Report disclosed by ShaneJones. This site noticed that ShaneJones discovered through independent research in December last year that there was a vulnerability in the DALL-E3 model of OpenAI text-generated images. This vulnerability can bypass the AI Guardrail (AIGuardrail), resulting in the generation of a series of NSFW inappropriate content. This discovery attracted widespread attention

Overview of Comma Operator Vulnerabilities and Defense Measures in Java: In Java programming, we often use the comma operator to perform multiple operations at the same time. However, sometimes we may overlook some potential vulnerabilities of the comma operator that may lead to unexpected results. This article will introduce the vulnerabilities of the comma operator in Java and provide corresponding protective measures. Usage of comma operator: The syntax of comma operator in Java is expr1, expr2, which can be said to be a sequence operator. Its function is to first calculate ex

fastcgi: fastcgi is developed and improved from cgi. The main disadvantage of the traditional cgi interface method is poor performance, because every time the http server encounters a dynamic program, the script parser needs to be restarted to perform parsing, and then the results are returned to the http server. This is almost unavailable when dealing with high concurrent access. In addition, the traditional cgi interface method has poor security and is rarely used now. The fastcgi interface mode adopts the c/s structure, which can separate the http server and the script parsing server, and start one or more script parsing daemons on the script parsing server. Every time the http server encounters a dynamic program, it can be delivered directly to fastcg

In Windows 7, the computer repair and recovery functions have been strengthened and improved. When our computer fails or needs to restore a backup, we can activate Windows' "Advanced Startup Options" by pressing the F8 key at startup, and then restore the system. Let’s see how to do it. 1. First click the Windows Start icon, type "cmd" in the "Search Programs and Files" input box, right-click "cmd.exe" in the search results, and click "Manage" in the pop-up list Run as member". 2. Then, type "reagentc/info" in the open command line environment and press the "Enter" key. WindowsRE related information will then appear. like
