Skip to content

Latest commit

 

History

History
77 lines (46 loc) · 5.98 KB

php2shell.md

File metadata and controls

77 lines (46 loc) · 5.98 KB

php2shell (CVE-2026-109618 / CVE-2026-109619) — What it is and how Qbix proxy stops it

The vulnerabilities

On October 21 2026, two critical remote code execution vulnerabilities were disclosed in PHP core:

CVE-2026-109618 — heap use-after-free in PHP's session.upload_progress handler. When session.upload_progress.enabled is on (the default), PHP updates session data while parsing the multipart body. A crafted multipart boundary sequence causes a use-after-free in the C-level session handler, giving the attacker control over freed heap memory.

CVE-2026-109619 — heap use-after-free in PHP's multipart form-data parser (multipart/form-data). The parser uses a streaming state machine that tracks boundary positions across read chunks. A crafted sequence of boundaries triggers a use-after-free in the boundary tracking structure.

Both are rated CVSS 9.2+, require no authentication, and are exploitable with a single HTTP POST request. They affect every PHP version from 5.4 onward. Only PHP 8.2+ received official patches; PHP 5.x, 7.x, 8.0, and 8.1 are end-of-life and will not be patched.

The attack path: crafted HTTP request → PHP multipart parser → heap corruption → arbitrary code execution → shell. Researchers named the pair "php2shell" because that path is reliable and reproducible.

Discussion: Sansec research writeup · Hacker News thread · Forbes coverage · Phoenix Security analysis

Why patching alone is not enough

PHP versions 5.x through 8.1 will never receive patches. Many production servers run these versions because upgrading PHP requires application-level testing and often code changes. Even on 8.2+, the patch addresses the specific use-after-free but does not change the fundamental architecture: PHP's multipart parser still processes raw attacker-controlled bytes in complex, stateful C code — the conditions for future parser vulnerabilities remain.

CVE-2024-2756, CVE-2024-3096, CVE-2024-11236, and CVE-2026-6722 (SOAP use-after-free, CVSS 9.5) all follow the same pattern. php2shell is not an isolated incident; it is the latest in a recurring class.

What Qbix proxy does about it

Traditional WAFs use signature matching — they look for known attack patterns in the request. This approach requires a known signature, which does not exist until after a vulnerability is discovered and analyzed. It also fails against exploits that evade signatures by varying the encoding, the boundary format, or the parser-differential gap between WAF and PHP.

Qbix proxy takes a different approach: structural re-serialization. It never forwards the client's bytes to PHP. Instead:

  1. The proxy's own multipart parser reads the request body.
  2. The parsed fields are validated against configurable limits (file count, file size, extensions, MIME types).
  3. The request is re-serialized from the parsed representation with a new random boundary generated by the proxy.
  4. PHP receives only the re-serialized bytes — bytes the proxy generated, never bytes the client sent.

Because PHP's parser processes the proxy's output rather than the attacker's input, the crafted boundary sequences that trigger CVE-2026-109618 and CVE-2026-109619 never reach PHP's C code. The same mechanism eliminates all future multipart parser vulnerabilities in PHP by the same logic: the attacker cannot control the byte-level representation that PHP parses.

The pipeline stages that cover php2shell

Stage 3 (multipart re-serialization) is the core protection. Stages 1 and 2 fail the request earlier if the Content-Type or method is not on the allowed list. Stage 5 extends the same re-serialization principle to application/x-www-form-urlencoded bodies.

Stage What it does Why it matters for php2shell
1. Content-Type validation Rejects unknown or malformed types Blocks requests with no legitimate business before parsing
2. Method validation Configurable per-backend allowed methods Prevents unexpected verbs that PHP handles differently
3. Multipart re-serialization Full parse → validate → re-serialize with new boundary Removes attacker's bytes from the multipart body entirely
5. URL-encoded re-serialization Full parse → re-serialize key-value pairs Extends the same invariant to form submissions

What "re-serialized with a new boundary" means in practice

The original request might have a boundary like:

Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryXYZ

After stage 3, PHP receives a request with a boundary like:

Content-Type: multipart/form-data; boundary=4a7f2c9e1b3d6082a5f8c4e7b2d9f1a3

The boundary is generated from /dev/urandom for each request. The field names, values, and file contents are identical — only the wire format differs. PHP parses the proxy's re-serialized output and never executes a code path that the attacker's crafted boundary was designed to trigger.

Deployment

Install Qbix proxy between your reverse proxy (nginx, Apache, Caddy) and PHP-FPM:

Internet → nginx (TLS) :443 → qbixproxy :8080 → php-fpm.sock

See the automated setup in the README for a one-command install, or the manual setup for step-by-step instructions.

No configuration is needed to activate the php2shell protection — multipart re-serialization runs for every request to a FastCGI backend, unconditionally.

Already protected: Qbix PHP Webserver

The Qbix PHP Webserver has the sanitization pipeline compiled directly into its request-handling path. If you are running the Qbix webserver, you are already protected without a separate proxy process.