Exploitable PHP functions

Exploitable PHP functions

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Exploitable PHP Functions: A Red-Flag Keyword List for Incident Response

When hunting for backdoors on a compromised server, efficiency is paramount. You are likely sifting through tens of thousands of files, trying to separate legitimate business logic from malicious payloads like c99 or r57. The goal isn't necessarily to maintain a strict blacklist of forbidden functions—that's an application-level concern—but rather to build a grep-able list of "red-flag" keywords that indicate arbitrary code execution capabilities.

To understand why these specific functions are dangerous, you have to look at what they actually do under the hood. They bridge the gap between user input and system resources. If an attacker can manipulate the arguments passed to these functions, they effectively gain root-level access to your server's filesystem or memory space.

Shell Execute Functions

The most obvious vector for code execution involves spawning shell processes. These functions allow you to run operating system commands directly from PHP. The list of suspects includes system(), exec(), popen(), the backtick operator, and pcntl_exec().

These are often the first things analysts look for because they provide immediate command-line access. A classic example of a vulnerable pattern involves passing user input directly to system:

<?php 
// Dangerous: Direct injection
$cmd = $_GET['command'];
system($cmd); 
?>

The backtick operator is often overlooked in automated scans because it looks like simple text, but functionally it behaves almost identically to exec(). It captures the output of a command and assigns it to a variable. When you see a variable containing user input being wrapped in backticks, that is an immediate red flag.

PHP Execute Functions

While shell execution gives you OS control, there are functions designed specifically to run PHP code within the current context. These can be even more potent because they bypass many web server restrictions that apply to external processes.

eval() is the poster child for this category. It parses and executes a string of PHP code. If an attacker can control the string passed to eval(), they can execute any valid PHP statement, including spawning shells or modifying files. The pattern is ubiquitous in old tutorials but remains dangerous:

<?php 
// Dangerous: Arbitrary PHP execution
$code = $_POST['payload'];
eval($code); 
?>

Another frequent culprit is preg_replace(). This function has a specific modifier, /e, which evaluates the replacement string as PHP code. While this feature was officially removed in PHP 5.5 to prevent exactly these kinds of vulnerabilities, legacy applications running older versions or misconfigured environments still pose a risk. If you are scanning a modern stack, you can largely ignore /e usage, but if you encounter it, treat it as critical.

Then there is create_function(). This function allows you to create an anonymous function from a string of code. Like eval(), it parses the input string as PHP syntax. It was deprecated in PHP 7 and removed entirely in PHP 8.2, but finding it in your codebase indicates outdated maintenance practices that could be exploited if not patched.

File Manipulation and Inclusion

Sometimes the attack vector isn't direct execution but rather loading external files. The include() and require() families (_once variants included) allow you to load PHP scripts. While they don't execute code directly in the current scope, they allow an attacker to load a web shell from the filesystem if path traversal vulnerabilities exist.

Additionally, functions capable of writing to the filesystem are critical for persistence. An attacker who can read input and execute file_put_contents() or fopen()/fwrite() combinations can drop new malicious scripts on your server, ensuring long-term access even after the initial entry point is patched.

The Strategy Behind the Scan

When you construct your search query, you are looking for the intersection of user-controlled data and these execution contexts. You aren't just searching for function names; you are searching for patterns where external input flows into these functions without sanitization or whitelisting.

If you find a file containing eval($_GET['...']), system($_POST['...']), or a preg_replace with an /e flag, that file is almost certainly compromised or contains a proof-of-concept payload. Narrowing your haystack to these specific signatures allows you to focus your forensic analysis on the files that truly matter, saving valuable time during an incident response.

Our network