Last verified ·
PHP2Shell step-by-step response
Commands are examples for the stated environment. Match the branch, service and paths to your site; prepare a backup and a maintenance window before changing production.
Find the Web runtime
WordPress: Tools > Site Health > Info > Server. In a panel, select the domain and its assigned handler. With SSH, map the vhost/socket to its FPM service or container. php -v and php --ini describe CLI only. Never publish phpinfo().
CLI / systemdphp -v php --ini ps -eo pid,lstart,args | grep -E '[p]hp-fpm|[a]pache2|[h]ttpd' systemctl list-units --type=service --all | grep -E 'php.*fpm|apache2|httpd'Reduce exposure before PHP
If you cannot patch, restrict the origin at the reverse proxy/firewall or serve a static maintenance page without forwarding to PHP. An application maintenance plugin may run too late. WAF rules are additional controls, not complete fixes.
Apply settings in the Web configuration
Set session.upload_progress.enabled=0 in the active Web php.ini or an administrative FPM pool setting, before request parsing. Only for PHP 8.5, also set fatal_error_backtraces=0. Editing application code or CLI php.ini is insufficient. Back up the file first.
FPM · Debian/Ubuntu · /etc/php/8.3/fpm/pool.d/www.confphp_admin_value[session.upload_progress.enabled] = 0FPM · PHP 8.5php_admin_value[fatal_error_backtraces] = 0Replace the processes serving requests
Validate the configuration, then restart the actual FPM service or Apache for mod_php during maintenance. Replace container replicas and restart long-running workers. A configuration saved on disk does not prove old processes have stopped.
PHP 8.3 FPM · Debian / Ubuntusudo php-fpm8.3 -t && sudo systemctl restart php8.3-fpm systemctl is-active php8.3-fpm systemctl show php8.3-fpm -p ActiveEnterTimestamp ps -eo pid,lstart,args | grep '[p]hp-fpm'Check the effective settings
Use a protected, authenticated administrator diagnostic for the Web SAPI to read loaded INI files and effective values. Expect upload progress Off/0, and fatal backtraces Off/0 on PHP 8.5. Check each pool and replica. Re-test normal uploads; remove temporary diagnostics.
Avoid misleading workarounds
These settings do not patch both CVEs. display_errors=Off, disable_functions and worker recycling do not establish protection. memory_limit=-1 is incomplete and needs independent resource containment; never substitute RLIMIT_AS or RLIMIT_DATA. Do not apply it blindly on shared hosting.
Temporary measures are incomplete
Only a complete patch addresses all covered variants. Configuration changes can reduce specific paths while you prepare an update, but may affect uploads, performance or availability. Apply them administratively before request parsing and restart every worker. Read both PHP advisories together. A CDN or WAF can reduce exposure but must not be treated as proof that the interpreter is fixed.
Memory settings require care
PHP recommends administratively enforcing memory_limit=-1 only as an incomplete temporary measure against controllable PHP-limit OOM. Underlying allocation failure can still reach the vulnerable path. Independent container or cgroup containment is needed to manage availability risk. Do not substitute RLIMIT_AS or RLIMIT_DATA. Keep decoded request size, multipart headers, nesting and part counts bounded; a low post_max_size alone is not complete protection.
Upload progress and backtraces
Set session.upload_progress.enabled=0 before request parsing and restart workers to block the confirmed session lifecycle paths. In PHP 8.5, fatal_error_backtraces=0 removes the confirmed backtrace producer only. Remove invalid or deprecated per-request settings that emit early diagnostics. Hiding output with display_errors, error_reporting or @ does not stop the stale-state vulnerability. These settings do not cover every variant.
Temporary controls by execution path
Patch first. Until then, enforce session.upload_progress.enabled=0 administratively before request parsing and restart workers. For PHP 8.5, fatal_error_backtraces=0 reduces one additional consumer path. Apply decoded request-size, multipart part/header and input-depth limits at the earliest layer able to enforce them. Test real uploads and integrations. Disabling display_errors or logging alone does not stop the vulnerable diagnostics path.
PHP2Shell tools →Memory controls and recycling have limits
An administratively enforced memory_limit=-1 can remove one PHP-managed OOM route, but is incomplete and needs independent cgroup/container resource containment. Prevent applications from restoring a finite limit and restart all workers. Never substitute RLIMIT_AS or RLIMIT_DATA: allocator failures can enter the vulnerable path. pm.max_requests=1 can reduce some cross-request state reuse at substantial cost; none of these settings replaces the complete patch for both CVEs.
PHP2Shell tools →Command example / PHP INI
; Temporary measures only. Follow both PHP advisories.
; Apply administratively BEFORE request parsing, then restart workers.
session.upload_progress.enabled = 0
; PHP 8.5 only:
fatal_error_backtraces = 0
; memory_limit = -1 is NOT a complete fix.
; It needs independent OS/container resource containment.
; Never substitute RLIMIT_AS or RLIMIT_DATA.