CVE-2019-11043: Vulnerability in PHP-FPM Could Lead to Remote Code Execution on nginx
Web servers using nginx and PHP-FPM are vulnerable to this flaw under certain conditions.
背景
On October 22, security researcher Omar Ganiev published a tweet regarding a “freshly patched” remote code execution vulnerability in PHP-FPM, the FastCGI Process Manager (FPM) for PHP. The tweet includes a link to a GitHub repository containing a proof of concept (PoC) for the vulnerability.
Freshly patched RCE in PHP-FPM:https://t.co/kaVsCStBJx
— BECHED (@ahack_ru) October 22, 2019
Exploit:https://t.co/VLmhxMWVxo
Many nginx+PHP configurations vulnerable, watch out!
分析
CVE-2019-11043 is an env_path_info underflow flaw in PHP-FPM’s fpm_main.c. The vulnerability was first reported to the PHP bug-tracker by security researcher Emil Lerner on September 26, 2019. Lerner also credits Andrew Danau, security researcher at Wallarm, who identified the “anomaly” during a Capture The Flag competition in September 2019, and Ganiev for helping to finalize the php.ini options for the PoC.
According to Lerner, under certain configurations where a web server is using nginx and PHP-FPM, the vulnerability can be exploited to gain remote code execution. These configurations require a certain set of preconditions in order for it to be exploitable. These preconditions include:
- The nginx location directive forwards requests to PHP-FPM
- The fastcgi_split_path_info directive is present and includes a regular expression beginning with a ‘^’ symbol and ending with a ‘$’ symbol
- The fastcgi_param directive is used to assign the PATH_INFO variable
- There are no checks in place to determine whether or not a file exists (e.g., using try_files or an if statement)
It appears such configurations and preconditions are not uncommon. According to a recent tweet, Nextcloud, the open-source file hosting software, originally recommended the vulnerable nginx configuration in their installation documentation. Nextcloud has since changed the documentation following the tweet that reported it.
NOTICE THIS TWEET : https://t.co/x68iNP6F7u
— Henry Chen (@chybeta) October 24, 2019
recommended configuration for nextcloud with nginx and php-fpm is vulnerable...#bugbounty #bugbountytip #bugbountytips pic.twitter.com/cAqptRR0Ez
The PoC script included in the GitHub repository can query a target web server to identify whether or not it is vulnerable by sending specially crafted requests. Once a vulnerable target has been identified, attackers can send specially crafted requests by appending “?a=
概念验证
The PoC script is available in the following GitHub repository.
解决方案
On October 24, PHP 7.3.11 (current stable) and PHP 7.2.24 (old stable) were released to address this vulnerability along with other scheduled bug fixes. Those using nginx with PHP-FPM are encouraged to upgrade to a patched version as soon as possible.
If patching is not feasible, the suggested workaround is to include checks to verify whether or not a file exists. This is achieved either by including the try_files directive or using an if statement, such as if (-f $uri).
识别受影响的系统
A list of Tenable plugins to identify this vulnerability will appear here as they’re released.
获取更多信息
- PHP Bug-Tracker Entry for CVE-2019-11043
- Wallarm Blog Post on Discovery of the PHP-FPM Flaw
- GitHub Repository with Proof-of-Concept for CVE-2019-11043
加入 Tenable Community 中的 Tenable 安全响应团队
了解有关 Tenable 这款首创 Cyber Exposure 平台的更多信息,全面管理现代攻击面。
Get a free 60-day trial of Tenable.io Vulnerability Management.
相关文章
- Vulnerability Management