3-minute read Oct 24 2019
Web servers using nginx and PHP-FPM are vulnerable to this flaw under certain conditions.
Background
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!
Analysis
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.
— Henry Chen (@chybeta) October 24, 2019
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=
Proof of concept
The PoC script is available in the following GitHub repository.
Solution
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).
Identifying affected systems
A list of Tenable plugins to identify this vulnerability will appear here as they’re released.
Get more information
- 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
Join Tenable's Security Response Team on the Tenable Community.
Learn more about Tenable, the first Cyber Exposure platform for holistic management of your modern attack surface.
Get a free 60-day trial of Tenable.io Vulnerability Management.
Learn more
- Vulnerability Management
Try for free
Buy now
100
Try for free
Buy now
Try for free
Buy now
Try for free
Buy now
With Advanced Support for Nessus Pro, your teams will have access to phone, Community, and chat support 24 hours a day, 365 days a year. This advanced level of technical support helps to ensure faster response times and resolution to your questions and issues.
Advanced Support Plan Features
Phone Support
Phone support 24 hours a day, 365 days a year, available for up to ten (10) named support contacts.
Chat Support
Chat support available to named support contacts, accessible via the Tenable Community is available 24 hours a day, 365 days a year.
Tenable Community Support Portal
All named support contacts can open support cases within the Tenable Community. Users can also access the Knowledge Base, documentation, license information, technical support numbers, etc.; utilize live chat, ask questions to the Community, and learn about tips and tricks from other Community members.
Initial Response Time
P1-Critical: < 2 hr
P2-High: < 4 hr
P3-Medium: < 12 hr
P4-Informational:
< 24 hr
Support Contacts
Support contacts must be reasonably proficient in the use of information technology, the software they have purchased from Tenable, and familiar with the customer resources that are monitored by means of the software. Support contacts must speak English and conduct support requests in English. Support contacts must provide information reasonably requested by Tenable for the purpose of reproducing any Error or otherwise resolving a support request.