🛡️
Security

Disabling Dangerous PHP Functions with disable_functions

24.11.2026
← All articles

PHP is powerful: besides building pages it can run operating system commands, launch other programs and open network connections. A typical website needs almost none of that, but if an attacker plants a malicious script, those functions are exactly what lets them take over the server. The disable_functions directive switches specific PHP functions off entirely and adds an important layer of defence: even if malicious code lands on the server, it loses its most dangerous tools.

What disable_functions does

It is a php.ini setting containing a comma-separated list of functions that are disabled when PHP starts. Since PHP 8, a disabled function behaves as if it does not exist: function_exists() returns false and calling it throws "Call to undefined function". The directive can only be set at system level; it cannot be changed with ini_set() or php_value in .htaccess, which is the point, since a malicious script must not be able to lift the restriction.

Functions commonly disabled

disable_functions = exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec,show_source

exec, system, passthru and shell_exec run shell commands; proc_open and popen open external processes; pcntl_exec replaces the current process; show_source can leak source code. Note that eval is a language construct, not a function, so it cannot be disabled this way; patterns like eval(base64_decode(...)) must be fought with file scanning and updates.

Example: a news site in Fergana

A local news portal in Fergana runs an outdated gallery plugin. An attacker uploads a web shell through it and tries to download and start a miner with wget. Because exec, shell_exec and proc_open are disabled, nothing runs, and "Call to undefined function" entries in the error log alert the admin early. The shell could still read and modify files with ordinary PHP functions, though, so the restriction limits damage but does not replace updating the plugin and cleaning up.

Checking the current setting

CLI PHP and the PHP-FPM serving your site often use different php.ini files, so checking through the site is more reliable:

php -i | grep disable_functions
php --ini

# temporary check.php on the site
<?php
echo ini_get('disable_functions');

Delete check.php as soon as you have read the result, because details about your server configuration are just as useful to an attacker as they are to you.

Configuring it on a VPS

Find the php.ini used by the PHP-FPM version that serves your site, edit the directive and restart the service:

sudo nano /etc/php/8.3/fpm/php.ini
sudo systemctl restart php8.3-fpm

Replace 8.3 with your version, then test every key feature of the site. Some tools genuinely need these functions: image optimisers may call external binaries, and Composer and WP-CLI use proc_open. Since those usually run from the command line, a practical approach is to restrict the FPM php.ini and leave the CLI one alone. Keep an eye on the error log for a few days after the change: "Call to undefined function" lines show you which code relied on a disabled function.

On shared hosting

The server administrator manages php.ini, and dangerous functions are often already restricted. If your software seems to need one, check whether it has a mode that works without external programs. Questions about PHP settings on sayt.uz hosting can be sent to support through the cabinet. Remember that disable_functions is one layer: combine it with timely CMS and plugin updates, correct file permissions, no PHP execution in upload folders, open_basedir, and regular backups.

Related articles

🏴‍☠️ Nulled themes and plugins: why free premium software costs more 🛡️ Securing a Joomla site: updates, extensions and server settings 🔑 How to Disable SSH Password Login and Switch to Keys 🗂️ Exposed .git directory: how your code and passwords leak
🌐 Language
🇺🇿 O⁠'zbek 🇺🇿 Özbek (yangi) 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓