Apply temporary php.ini, PHP-FPM, and proxy settings to reduce PHP2Shell exposure while you prepare to patch, and understand their trade-offs.
Patching is the only complete fix for PHP2Shell (CVE-2026-109618 and CVE-2026-109619). Still, you may face maintenance windows, frozen deployment pipelines or end-of-life systems like brightline-invoicing on PHP 7.4 that you cannot upgrade today. In those situations, you can apply configuration changes and proxy limits to reduce exposure until you install the security update.
Previous lesson: Patch PHP: Apply the October 2026 PHP Security Update | Next lesson: Detect PHP2Shell Exploitation Attempts in Your Logs
According to the PHP advisory, specific configuration settings reduce your exposure to both vulnerabilities. They do not make an unpatched PHP installation safe, because the underlying flaws are still in the code. Think of these settings like a spare tire with a 50-mile speed limit: they get you to the repair shop, but you cannot keep driving on them.
Each CVE requires a different setting:
memory_limit = -1. This flaw occurs when PHP runs out of memory while setting up internal request data. Removing the per-request memory cap makes it much harder to trigger this condition on purpose. Rapid7 notes that a real memory allocation failure can still reach the vulnerable code, so this is not a complete fix.session.upload_progress.enabled = 0. This disables the session upload progress feature involved in the state corruption across requests.fatal_error_backtraces = 0.Pro Tip: Keep session.upload_progress.enabled off even after you patch, unless your application shows upload progress bars. The same feature was involved in a later session flaw, CVE-2026-115560, and PHP advised turning it off until that was fixed. Leaving it off removes attack surface at almost no cost.
Setting memory_limit = -1 removes PHP's safety net for runaway scripts. A single poorly written database query or large file operation can now consume all available system RAM (Random Access Memory) and trigger the Linux kernel out-of-memory killer.
If you apply this setting, watch your server memory metrics closely and keep your proxy request size limits tight.
Where you place these directives matters as much as the directives themselves. Both vulnerabilities can trigger during request startup, before PHP executes a single line of your application script.
Common Mistake: Calling ini_set('memory_limit', '-1') inside your index.php or wp-config.php, or placing the settings inside a per-directory .user.ini file, is too late. PHP parses multipart request data and session upload progress before running application code.
You must set these directives in php.ini, your PHP-FPM (FastCGI Process Manager) pool configuration, or your Apache virtual host configuration. Furthermore, you should use administrative directives (php_admin_value and php_admin_flag) so applications and plugins cannot override your settings back to a vulnerable value at runtime.
Take brightline-portal, which runs on PHP 8.3 with PHP-FPM. If the team cannot redeploy the container image for six hours, they can lock down the FPM pool file and restart the service.
Before:
iniCopy
After:
iniCopy
If the pool runs on PHP 8.5, add php_admin_flag[fatal_error_backtraces] = off at the bottom as well.
For brightline-www running on Ubuntu 22.04 with Apache and mod_php (an SAPI, or Server Application Programming Interface, that embeds PHP inside each Apache worker), place the administrative directives inside the VirtualHost block.
Before:
apacheCopy
After:
apacheCopy
For brightline-invoicing on RHEL (Red Hat Enterprise Linux) 8 with PHP 7.4, you can also edit /etc/php.ini directly if no application or pool config overrides memory_limit:
Before:
iniCopy
After:
iniCopy
Configuration files are only read when PHP starts. After editing any file, restart the service and confirm the live value.
bashCopy
Pro Tip: Even if you edit php.ini globally, verify that no framework, WordPress plugin, or Composer package calls ini_set('memory_limit', '256M') during request execution. Using php_admin_value in the FPM pool or Apache VirtualHost prevents ini_set() from changing the value.
Because CVE-2026-109618 is triggered through large or crafted multipart requests (such as file uploads and form posts), shrinking the maximum allowed request size reduces the room an attacker has to force memory exhaustion.
Rapid7 recommends lowering PHP's post_max_size to 8M for applications that only need small uploads, or 32M where larger uploads are required, and setting upload_max_filesize below that number.
iniCopy
Enforcing body limits at the reverse proxy or web server is even better, because the proxy rejects oversized requests before they ever reach a PHP worker.
On brightline-portal, nginx sits in front of PHP-FPM. You can cap the request body size with client_max_body_size, and you can block multipart/form-data requests entirely on endpoints that never accept file uploads.
Before:
nginxCopy
After:
nginxCopy
On brightline-www, use the LimitRequestBody directive (measured in bytes, where 8388608 equals 8 megabytes) inside the VirtualHost:
apacheCopy
After editing nginx or Apache configurations, test the syntax (sudo nginx -t or sudo apachectl configtest) and reload the web server.
When you run an unpatchable system like brightline-invoicing on PHP 7.4, configuration changes alone carry high risk.
CERT-EU (the Computer Emergency Response Team for the European Union institutions) recommends isolating affected internet-facing applications from public networks until a patch is applied and verified, wherever the business can accept it.
For brightline-invoicing, only the finance team needs access. Putting the server behind a corporate VPN (Virtual Private Network) or restricting port 443 in the firewall to internal office IP addresses immediately removes exposure to internet scanners.
Providers such as Cloudflare deployed WAF rules for PHP2Shell on 21 October 2026. While enabling your provider's managed ruleset helps, Cloudflare itself described these rules as a stopgap.
Keep two limitations in mind:
During an incident, teams often apply familiar settings that sound related to errors or memory, but actually make the situation worse or do nothing at all.
| Action or Setting | Why It Fails to Protect You |
|---|---|
Turning off display_errors, log_errors, error_reporting, or using the @ operator | These settings only control whether PHP prints or logs error messages. Fatal errors and out-of-memory conditions still happen inside the engine, so the vulnerable code paths still run. |
Setting ini_set() in PHP code or .user.ini | PHP parses multipart uploads and session upload progress before executing application code. By the time ini_set() runs, the vulnerable step has already occurred. |
Lowering RLIMIT_AS or RLIMIT_DATA at the OS level | According to Rapid7, restricting process address space or data segment limits at the Linux operating system level can cause memory allocations to fail earlier, which can actually trigger the vulnerable out-of-memory path. |
| Relying on Docker container or cgroup memory limits | Rapid7 notes that container and control group (cgroup) memory limits are an incomplete defense and do not prevent internal PHP state corruption. |
Quick Challenge: A colleague proposes setting memory_limit = 32M in php.ini so PHP kills large requests quickly. Based on how CVE-2026-109618 works, why is this dangerous?
Lowering memory_limit makes it easier for a smaller multipart request to exhaust PHP's per-request memory allocation during request initialization, which is the exact condition that triggers CVE-2026-109618.
Apply the temporary PHP-FPM mitigation to a test pool configuration and verify how to check the effective settings from the command line.
php.ini for your PHP-FPM binary before making changes (read-only). Note that php-fpm8.3 -i reads php.ini only and does not show values set in pool files:bashCopy
/etc/php/8.3/fpm/pool.d/www.conf) and add the two administrative directives at the bottom:iniCopy
bashCopy
bashCopy
-tt option prints the full parsed configuration, including php_admin_value lines from pool files (read-only):bashCopy
client_max_body_size or LimitRequestBody (read-only):bashCopy
In the next lesson, Detect PHP2Shell Exploitation Attempts in Your Logs, you will search your web server, PHP error and PHP-FPM logs for signs of exploitation dating back to 17 October 2026.
Was this lesson helpful?