exec, system, shell_exec and passthru to disable_functions in php.ini, run php -i | grep disable_functions on the server, and the list looks right. Then the webshell you found earlier still answers with directory listings and id output. A common cause is that the PHP you tested on the command line and the PHP that serves the website are different processes. They read different configuration, and they pick up changes at different times.
This comes up often at the support desk, because the CLI check feels like proof. It only proves what the CLI sees. To know what the web-facing PHP enforces, you need to understand how PHP-FPM loads its settings and then ask FPM itself.
How PHP-FPM actually gets its configuration
php binary is the CLI SAPI. PHP-FPM (FastCGI Process Manager) is a separate SAPI and a separate binary. The web server hands requests to it over the FastCGI protocol, through either a UNIX socket or a TCP port.
When the FPM service starts, the master process does the configuration work once:
- It locates its php.ini. The path is compiled into the binary or passed with
-c, and many distributions build the CLI and FPM with different paths on purpose. Debian and Ubuntu, for example, keep separate trees under/etc/php/<version>/cli/and/etc/php/<version>/fpm/. - It reads every extra
.inifile from its scan directory (theconf.dfolder for that SAPI), in alphabetical order. A later file can override an earlier one. - It parses
php-fpm.confand every pool file. A pool is a group of workers with its own user, socket, and optional PHP overrides set withphp_valueandphp_admin_value. - It initializes the PHP engine. At this point every function named in
disable_functionsis removed from the function table. - It forks worker processes, which inherit that already-initialized state.
systemctl reload php8.2-fpm, depending on your service name) makes the master re-read its configuration and replace the workers.
The CLI behaves differently. Each php command is a new process that reads its own php.ini fresh, which is why the CLI check reflects your edit immediately and FPM does not.
Once a function is disabled, PHP 8 treats it as if it does not exist. Calling it throws an Error for an undefined function, and function_exists() returns false. Older PHP versions printed a warning saying the function was disabled for security reasons. Either message is a useful sign that you are looking at a worker that has the setting.
Why the web-facing PHP ignores your edit
conf.d file loaded later for the FPM SAPI can still set its own disable_functions line and win.
You edited the wrong PHP version. Servers running several PHP versions have one FPM service per version. Your change may have gone into the 8.1 config while the site is served by the 8.3 pool.
A pool overrides it. php_admin_value[disable_functions] in a pool file applies only to that pool. As commonly documented, FPM adds the pool's list on top of the php.ini list rather than replacing it, so a pool cannot re-enable a function php.ini disabled. A pool can still be the place where the real restrictions live, and a site on a different pool will not have them.
A control panel regenerated the files. Panels often build pool files from their own templates. A manual edit can be overwritten at the next rebuild, and the setting you need might only stick when set through the panel's own PHP settings screen.
Nobody reloaded FPM. The file is correct, but the workers still hold the old function table.
Per-directory files do not explain the problem. disable_functions is a system-level directive, so a .user.ini in the webroot or a php_value line cannot switch it off. If an attacker gets commands to run despite a correct, loaded setting, look at the bypass section below.
Tracing which FPM serves the site
BASH
# FPM services present and running
systemctl list-units --type=service | grep -i fpm
# Master and worker processes; the master shows its config file, workers show the pool name
ps -eo pid,user,cmd | grep '[p]hp-fpm'
# Where Nginx or Apache sends PHP requests (socket path or host:port)
grep -Rn 'fastcgi_pass' /etc/nginx/ 2>/dev/null
grep -RnE 'proxy:(unix|fcgi)' /etc/apache2/ /etc/httpd/ 2>/dev/null
# Compare what the CLI loads with what a given FPM binary loads
# (binary name varies: php-fpm, php-fpm8.2, php8.2-fpm, panel-specific paths)
php --ini
php-fpm8.2 -i | grep -E 'Loaded Configuration File|Scan this dir|disable_functions'fastcgi_pass or the Apache handler to the listen line in a pool file. That tells you which FPM version and which pool handle the site. The php-fpm -i output shows the php.ini and scan directory that binary uses. It does not include pool-level overrides, so check those separately in the pool file for that site:
INI
; Debian/Ubuntu layout: /etc/php/8.2/fpm/pool.d/example.conf
; Applies only to this pool, in addition to php.ini
php_admin_value[disable_functions] = exec,passthru,shell_exec,system,proc_open,popen-t validates the configuration before you reload, which is worth doing so a typo does not take every site on that version offline. -tt also dumps the parsed configuration, which helps when you are not sure which pool file won.
Confirming the result through FPM itself
PHP
<?php
// Temporary check. Delete immediately after use.
header('Content-Type: text/plain');
echo 'SAPI: ', php_sapi_name(), PHP_EOL;
echo 'Loaded ini: ', php_ini_loaded_file(), PHP_EOL;
echo 'Scanned ini: ', php_ini_scanned_files(), PHP_EOL;
echo 'disable_functions: ', ini_get('disable_functions'), PHP_EOL;
foreach (['exec', 'system', 'shell_exec', 'passthru', 'proc_open', 'popen', 'pcntl_exec', 'putenv', 'mail'] as $f) {
echo f, ': ', function_exists(f) ? 'AVAILABLE' : 'disabled', PHP_EOL;
}fpm-fcgi. If it shows something else, the request did not go through FPM and the result tells you nothing about the pool. The function lines are more reliable than reading the ini string, because they reflect the actual function table, pool additions included.
This script is safer than a full phpinfo() page. phpinfo() exposes paths, environment variables and module details to anyone who finds the URL, and on a compromised server you should assume someone is looking. If you do use phpinfo(), restrict it to your IP address and remove it the same way.
When the config is right and commands still run
disable_functions. The setting blocks the specific functions you name, and the usual gaps are the ones left off the list.
proc_open, popen and pcntl_exec spawn processes just like exec does, and blocklists often leave them out. A known technique, described in 0xdf's write-up on Chankro, combines putenv with a function that starts a child process, such as mail(). The attacker sets LD_PRELOAD so the child loads a malicious shared library. No disabled function is ever called.
Another route skips the web server entirely. If the webshell can open the FPM socket or connect to 127.0.0.1:9000, it can speak FastCGI directly. In that request it can pass ini overrides through the PHP_VALUE and PHP_ADMIN_VALUE parameters and run code under different settings. The HackTricks page on disable_functions bypasses collects this and related methods. How well this works depends on socket permissions and which pool the socket belongs to. Per-site pools with their own users and tightly owned sockets limit the damage. The trade-offs are covered in open_basedir vs separate PHP-FPM pools.
At this stage, also remember what disable_functions is for. It narrows what a webshell can do. It does not remove the webshell or any other access the attacker set up. If commands already ran, treat the server as compromised and decide whether to clean it or rebuild it.
The practical order is short. Find the socket the site uses, follow it to the FPM version and pool, and edit the php.ini or pool file that master loads. Run the config test, reload, and confirm with a throwaway script that reports fpm-fcgi and shows the functions as disabled. Do not trust a CLI check for web-facing behavior. When the list is confirmed and commands still get through, look at what the list leaves out and who else can talk to the FPM socket.