Knowledgebase

Php disable_functions Print

  • 1

PHP disable_functions

PHP functions that can pose security risks, especially when used by malicious users to damage the server or access sensitive data, should be disabled. Disabling these functions is an important way to enhance server security. Below is a list of these functions along with explanations of why each can pose a security risk:

 
disable_functions = "exec, passthru, shell_exec, system, proc_open, popen, curl_exec, curl_multi_exec, parse_ini_file, show_source, phpinfo, mail, ini_set, ini_alter, openlog, syslog, readfile, symlink, dl, leak, proc_get_status, proc_terminate, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, escapeshellarg, escapeshellcmd, base64_decode"

Annotated List

  1. exec: Used to execute commands in the system. An attacker can execute commands on the server, causing serious damage.
  2. passthru: Executes a system command and outputs the result directly. Attackers can use this function to run malicious commands directly on the server.
  3. shell_exec: Similar to exec but returns all output as a string. Allows execution of shell commands, posing a security risk.
  4. system: Executes a system command and outputs the result to the screen. Malicious users can run unauthorized commands on the system through this function.
  5. proc_open: Starts a system process and manages its input/output streams. Attackers can use this function to start malicious processes.
  6. popen: Similar to proc_open, it executes a command and manages the command's input/output streams. It poses a security risk.
  7. curl_exec / curl_multi_exec: Allows sending HTTP requests externally. In a poorly configured system, attackers can send requests to exfiltrate sensitive data or retrieve malicious content.
  8. parse_ini_file: Parses an INI file and reads data from these files. It can expose sensitive configuration files.
  9. show_source: Displays the source code of a PHP file. Malicious users can access the source code of critical files through this function.
  10. phpinfo: Displays PHP configuration information. Provides attackers with information about your server's security vulnerabilities (e.g., installed modules, directory structure).
  11. mail: Used to send emails from the server. Without proper security measures, it can lead to spam attacks.
  12. ini_set / ini_alter: Allows dynamic modification of PHP configuration settings. Attackers can use these functions to change how PHP operates.
  13. openlog / syslog: Logging functions. Attackers can manipulate logs or use them to gather information about the system.
  14. readfile: Reads the contents of a file and outputs it. Can lead to the exposure of sensitive file contents.
  15. symlink: Creates symbolic links. Attackers can use this function to gain unauthorized access to files.
  16. dl: Loads a PHP extension at runtime. This function can be used to load extensions that introduce security vulnerabilities.
  17. leak: Used to test memory leaks. This function can cause attackers to deplete system resources.
  18. proc_get_status / proc_terminate: Provides information about a running process or terminates a process. Allows attackers to manipulate running processes.
  19. posix_kill / posix_mkfifo / posix_setpgid / posix_setsid / posix_setuid: These functions are related to POSIX processes and provide permissions to manage a process. This allows attackers to harm the system.
  20. escapeshellarg / escapeshellcmd: Used to secure shell arguments, but if misused, attackers can bypass these mechanisms.
  21. base64_decode: Decodes a Base64-encoded string. Can be used to hide malicious code.

Recommendations:

  • Disable PHP Functions: If these functions are not needed, it is recommended to disable them in the server configuration file (php.ini) using the disable_functions directive for security purposes.
  • Comprehensive Testing: Before disabling functions, test whether your application requires these functions. Some applications may rely on these functions.

By minimizing these security risks, you can enhance the overall security of your server. However, remember that application security is holistic; it should be supported by secure software development, regular updates, and other security measures.


Was this answer helpful?
Back