Exploit database

GH-945bd5267b0d1b94c3f74faf5cda7e5a

blkph0x/cve-2026-83844_poc

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-83844

5 sources

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

Repository files579
blkph0x/cve-2026-83844_pocRevision 193ed44859da
Next files →

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

lab/trace/verify_provenance_new_heap_sample.py

Python · 18,853 bytes
#!/usr/bin/env python3
"""Fail-closed review of a signed new-reader second-description heap sample.

This reports derived margins only. Raw guest logs and all effective process
addresses remain in ignored local results. The UUID row is a copy request;
the toggle/label rows are pre-instruction one-byte source addresses.
"""

from __future__ import annotations

from collections import Counter
import argparse
import hashlib
import json
from pathlib import Path
import re
import sys
from typing import Any

from build_provenance_new_heap_sample import POINTS
from build_provenance_nested_later_read import EXTENSIONS, FIXTURES, MODULES, REPEATED
from compare_focus import validate_bootstrap
from export_provenance_deep_evidence import (
    MARKER_RE, PID_NORMAL_RE, PID_WARNING_RE, ROOT, SHA_RE, TRIAL_RE,
    load_json, qwords, register, require,
)
from export_provenance_late_heap_bounds import heap_chunk
from generate_cdb import POINTS as BASE_POINTS, VERSION, sha256
from verify_provenance_nested_later_read import CASES, FILES, MAX_LOG_BYTES


TID_RE = re.compile(r"(?:^|\s)PAINT_NEW_HEAP_TID=([a-z0-9_]+):(\d+)(?=\s|$)")
CAP_RE = re.compile(r"(?m)^PAINT_NEW_HEAP_CAP=([a-z0-9_]+)\s*$")
BASE_CAP_RE = re.compile(r"(?m)^PAINT_NESTED_LATER_CAP=([a-z0-9_]+)\s*$")
MODULE_RE = re.compile(r"(?mi)^([0-9a-f`]+)\s+[0-9a-f`]+\s+c2pa_c\s")
TEMP_RE = re.compile(r"(?:^|\s)\$?t18=([0-9a-f]{1,16})(?=\s|$)", re.I)
SAMPLE_LABELS = tuple(f"newheap_{point.label}" for point in POINTS)
ORDER = (
    "uuid_cap_compare", "uuid_cap_branch", "uuid_copy_request",
    "toggle_extent_compare", "toggle_extent_branch", "toggle_preload",
    "label_declared_compare", "label_declared_branch",
    "label_first_preload", "label_last_guard", "label_last_postload",
)


def label_blocks(log: str, pid: int) -> tuple[list[tuple[str, str]], set[str]]:
    markers = list(MARKER_RE.finditer(log))
    pids = sorted(
        [(m.start(), m.group(1), int(m.group(2))) for m in PID_NORMAL_RE.finditer(log)]
        + [(m.start(), m.group(1), int(m.group(2))) for m in PID_WARNING_RE.finditer(log)]
    )
    labels = [m.group(1) for m in markers]
    require(labels == [row[1] for row in pids] and all(row[2] == pid for row in pids),
            "CDB marker/PID link differs")
    valid = {f"{p.path}_{p.label}" for p in BASE_POINTS["new"]
             if p.path in {"image", "flow", "provenance"}}
    valid.update({"nestedlater_reader_ffi_return", "nestedlater_reader_null",
                  "nestedlater_raw_mode"})
    valid.update(f"nestedlater_{p.label}" for p in REPEATED["new"])
    valid.update(SAMPLE_LABELS)
    require(set(labels) <= valid, "Unknown signed heap-sample marker")
    blocks = [
        (m.group(1), log[m.end():markers[i + 1].start() if i + 1 < len(markers) else len(log)])
        for i, m in enumerate(markers)
    ]
    caps = CAP_RE.findall(log)
    require(len(caps) == len(set(caps)) and set(caps) <= set(SAMPLE_LABELS),
            "Unknown or repeated heap-sample cap")
    require(set(BASE_CAP_RE.findall(log)) <=
            {f"nestedlater_{point.label}" for point in REPEATED["new"]},
            "Unknown base description cap")
    return blocks, set(caps)


def temp_address(block: str) -> int | None:
    values = TEMP_RE.findall(block)
    return int(values[-1], 16) if values else None


def branch_not_taken(block: str, kind: str) -> bool:
    efl = register(block, "efl", 32)
    require(efl is not None, "Signed guard flags absent")
    cf = bool(efl & 1)
    zf = bool(efl & 0x40)
    if kind == "jbe":
        return not (cf or zf)
    if kind == "jb":
        return not cf
    raise ValueError("Unsupported signed branch")


def signed_hit(block: str, point_label: str) -> None:
    point = next(point for point in POINTS if point.label == point_label)
    modules = MODULE_RE.findall(block)
    rip = register(block, "rip")
    require(len(modules) == 1 and rip is not None and
            rip == int(modules[0].replace("`", ""), 16) + point.rva,
            f"Signed loaded-module RVA differs: {point_label}")
    if point.read_width is not None:
        instruction = re.findall(
            rf"(?mi)^([0-9a-f`]+)\s+{point.opcode}\s+\S+",
            block,
        )
        require(len(instruction) == 1 and
                int(instruction[0].replace("`", ""), 16) == rip,
                f"Signed pre-read/copy instruction differs: {point_label}")


def sample_span(block: str, point_label: str) -> dict[str, Any]:
    """Return an address-free span measurement after strict pointer checks."""
    point = next(point for point in POINTS if point.label == point_label)
    require(point.read_width is not None, "Selected point is not a source sample")
    signed_hit(block, point_label)
    heap = heap_chunk(block)
    if point_label == "uuid_copy_request":
        effective = register(block, "rdx")
        width = register(block, "r8")
        require(width == 16, "UUID requested copy count differs")
        stage = "pre_call_copy_request"
    elif point_label == "label_last_guard":
        effective = temp_address(block)
        base_words = qwords(block)
        cursor = register(block, "r12")
        require(len(base_words) == 1 and cursor is not None and
                effective == base_words[0] + cursor,
                "Final-label prospective source does not match saved base plus cursor")
        width = 1
        stage = "pre_guard_prospective_source"
        require(branch_not_taken(block, "jbe"),
                "Final-label physical guard would reject before the read")
    else:
        effective = temp_address(block)
        base = register(block, "rax")
        cursor = register(block, "r12")
        require(base is not None and cursor is not None and
                effective == base + cursor,
                f"{point_label} effective address differs from base plus cursor")
        width = 1
        stage = "pre_instruction_effective_address"
    require(effective is not None and heap["address"] == effective,
            f"Heap query does not name {point_label} effective source")
    available = heap["to_reported_usable_end"]
    return {
        "sample": point_label,
        "stage": stage,
        "read_or_requested_width_bytes": width,
        "reported_usable_bytes_from_source": available,
        "span_within_reported_backend_heap_user_end": width <= available,
        "margin_bytes": available - width,
    }


def review_case(blocks: list[tuple[str, str]], case: str,
                caps: set[str]) -> dict[str, Any]:
    second = [(i, body) for i, (label, body) in enumerate(blocks)
              if label == "nestedlater_jumd_size_branch" and
              "PAINT_NESTED_LATER_ORDINAL=nestedlater_jumd_size_branch:2" in body]
    require(len(second) == 1, "Second description size branch absent or repeated")
    index, body = second[0]
    tid_match = re.findall(
        r"PAINT_NESTED_LATER_TID=nestedlater_jumd_size_branch:(\d+)", body
    )
    require(len(tid_match) == 1 and
            register(body, "r14") == (83 if case == CASES[0] else 91),
            "Second description thread or declared LBox differs")
    tid = int(tid_match[0])
    selected = []
    for label, body in blocks[index + 1:]:
        if not label.startswith("newheap_"):
            continue
        hit_tid = TID_RE.findall(body)
        require(len(hit_tid) == 1 and hit_tid[0][0] == label and
                int(hit_tid[0][1]) == tid,
                "Heap sample does not match second-description thread")
        selected.append((label.removeprefix("newheap_"), body))
    require([label for label, _ in selected] == list(ORDER),
            "UUID/toggle/first-and-last-label marker chronology differs")
    observed = {label: body for label, body in selected}
    for label, body in selected:
        signed_hit(body, label)
    uuid_available = register(observed["uuid_cap_compare"], "rcx")
    toggle_end = register(observed["toggle_extent_compare"], "r15")
    toggle_cursor = register(observed["toggle_extent_compare"], "r12")
    label_remaining = register(observed["label_declared_compare"], "rcx")
    require(all(value is not None for value in
                (uuid_available, toggle_end, toggle_cursor, label_remaining)) and
            uuid_available >= 16 and
            register(observed["uuid_copy_request"], "r8") == 16 and
            toggle_end > toggle_cursor and
            branch_not_taken(observed["toggle_extent_branch"], "jbe") and
            label_remaining >= 9 and
            branch_not_taken(observed["label_declared_branch"], "jb"),
            "Physical or declared source guards differ")
    last = observed["label_last_guard"]
    expected_cursor = 0x80 if case == CASES[0] else 0x88
    expected_remaining = 9 if case == CASES[0] else 17
    require(register(last, "r12") == expected_cursor and
            register(last, "rcx") == expected_remaining and
            register(observed["label_last_postload"], "r12") == expected_cursor and
            register(observed["label_last_postload"], "r15") == 0,
            "Final label cursor or post-load NUL differs")
    first_cursor = register(observed["label_first_preload"], "r12")
    require(first_cursor == (0x47 if case == CASES[0] else 0x4F) and
            first_cursor < expected_cursor,
            "First label cursor differs")
    required_caps = {
        "newheap_label_declared_compare", "newheap_label_declared_branch",
        "newheap_label_first_preload",
    }
    require(caps <= required_caps and
            not (set(SAMPLE_LABELS) - required_caps) & caps,
            "Heap-source sample unexpectedly capped")
    samples = [sample_span(observed[label], label) for label in
               ("uuid_copy_request", "toggle_preload",
                "label_first_preload", "label_last_guard")]
    return {
        "second_description_lbox": 83 if case == CASES[0] else 91,
        "selected_same_thread_marker_order": list(ORDER),
        "bounded_label_checkpoint_caps": sorted(caps),
        "samples": samples,
        "all_selected_spans_within_reported_backend_heap_user_end":
            all(sample["span_within_reported_backend_heap_user_end"] for sample in samples),
        "read_coverage": "UUID copy request, toggle pre-load, first label pre-load, last label guard before load",
    }


def verify_trial(trial: str) -> dict[str, Any]:
    require(TRIAL_RE.fullmatch(trial) is not None, "Unsafe trial label")
    root = ROOT / "lab/results" / trial
    stage = load_json(ROOT / "lab/isolation/generated" /
                      f"{trial}.provenance-deep-stage.json")
    require(stage.get("schema") == "paint-nested-xlbox-later-stage-v1" and
            stage.get("diagnostic_mode") == "new-nested-xlbox-heap-sample" and
            stage.get("build") == "new" and stage.get("trial_label") == trial and
            stage.get("selected_cases") == list(CASES) and
            all(SHA_RE.fullmatch(str(stage.get(key, ""))) for key in
                ("profile_sha256", "profile_manifest_sha256")),
            "Heap-sample stage identity/order differs")
    profile = ROOT / "lab/output/nested-xlbox-later/new-heap.auto.cdb.txt"
    require(sha256(profile) == stage["profile_sha256"] and
            sha256(profile.with_suffix(profile.suffix + ".json")) ==
            stage["profile_manifest_sha256"], "Offline heap profile differs")
    manifest = load_json(profile.with_suffix(profile.suffix + ".json"))
    require(manifest.get("schema") == "paint-new-nested-heap-sample-profile-v1" and
            manifest.get("heap_extension_sha256") == EXTENSIONS and
            manifest.get("heap_sample", {}).get("per_point_cap") == 1 and
            len(manifest.get("heap_sample", {}).get("points") or []) == len(POINTS),
            "Pinned heap profile manifest differs")
    batches = list(root.glob("focus-batch-new-*.json"))
    require(len(batches) == 1, "Expected one focused batch")
    batch = load_json(batches[0])
    require(batch.get("schema") == "paint-ab-focus-batch-v1" and
            batch.get("build") == "new" and batch.get("status") == "complete" and
            batch.get("selected_cases") == list(CASES),
            "Focused batch did not complete exact pair")
    validate_bootstrap(root, batch, "new")
    teardown = load_json(root / "teardown-result.json")
    require(teardown.get("state") == "closed" and
            teardown.get("guest_host_exited") is True and
            teardown.get("sandbox_process_count_after") == 0,
            "Guarded guest teardown did not reach zero processes")
    rows = []
    for case in CASES:
        paths = list((root / "focus/new" / case).glob("*/result.json"))
        require(len(paths) == 1, f"Expected one result for {case}")
        path = paths[0]
        result = load_json(path)
        batch_row = [row for row in batch["cases"] if row.get("case_id") == case]
        require(len(batch_row) == 1 and batch_row[0].get("status") == "complete" and
                batch_row[0].get("result_sha256") == sha256(path) and
                batch_row[0].get("timed_out") is False and
                batch_row[0].get("child_exited_verified") is True and
                batch_row[0].get("process_exit_code") in (None, 0),
                f"Batch/result completion differs: {case}")
        require(result.get("schema") == "paint-ab-focused-cdb-v1" and
                result.get("build") == "new" and result.get("case_id") == case and
                result.get("status") == "complete" and
                result.get("installed_package", {}).get("version") == VERSION["new"] and
                result.get("installed_exe_sha256") == MODULES["new"]["mspaint.exe"] and
                result.get("fixture_source") == FILES[case][0] and
                result.get("fixture", {}).get("file") == FILES[case][1] and
                result.get("fixture", {}).get("sha256") == FIXTURES[case] and
                result.get("fixture_manifest_sha256") == (
                    sha256(ROOT / "lab/corpus/generated/manifest.json") if case == CASES[0]
                    else stage.get("fixture_manifest_sha256")) and
                result.get("trace_script_sha256") == stage["profile_sha256"] and
                result.get("trace_manifest_sha256") == stage["profile_manifest_sha256"],
                f"Signed guest, fixture or CDB profile differs: {case}")
        installed = {row.get("module"): row.get("sha256") for row in
                     result.get("installed_module_checks", [])}
        loaded = {row.get("module"): row for row in result.get("loaded_module_checks", [])}
        require(all(installed.get(name) == digest and
                    loaded.get(name, {}).get("matches_signed_package") is True and
                    loaded.get(name, {}).get("sha256") == digest
                    for name, digest in MODULES["new"].items()) and
                not result.get("loaded_module_error"),
                f"Installed or loaded signed module differs: {case}")
        pid = result.get("blank_pid")
        cleanup = result.get("cleanup") or {}
        health = result.get("post_close_health") or {}
        require(isinstance(pid, int) and pid > 0 and
                result.get("cdb_initial_pid") == pid and
                result.get("file_open_launch_pid") == pid and
                result.get("debugger_ready") is True and
                result.get("file_open_entry_method") == "win32_file_name_control_1148" and
                result.get("file_open_filename_value_verified") is True and
                pid in (cleanup.get("close_requested_pids") or []) and
                not cleanup.get("forced_pids") and not cleanup.get("remaining_pids") and
                not health.get("remaining_pids") and not health.get("wer_events") and
                health.get("new_dump_count") == 0 and not health.get("error"),
                f"Same-PID file route or clean Paint close differs: {case}")
        log_path = path.with_name("cdb.log")
        require(log_path.is_file() and log_path.stat().st_size <= MAX_LOG_BYTES,
                f"Missing or oversize private debugger log: {case}")
        raw = log_path.read_bytes()
        blocks, caps = label_blocks(raw.decode("utf-8-sig", errors="replace"), pid)
        recorded = (result.get("markers_before_open") or []) + (result.get("markers_after_open") or [])
        require([label for label, _ in blocks] == recorded,
                f"Guest marker order differs from debugger transcript: {case}")
        after = blocks[len(result.get("markers_before_open") or []):]
        require({"image_image_open", "image_decoder", "flow_decoder_return",
                 "flow_provenance_call", "provenance_manifest_entry",
                 "flow_handoff_success_route"} <= {label for label, _ in after},
                f"Expected image/provenance route missing: {case}")
        branch = review_case(after, case, caps)
        bridge = [body for label, body in after if label == "provenance_bridge_result"]
        require(len(bridge) == 1 and register(bridge[0], "rax", 32) ==
                (0 if case == CASES[0] else 0x80004005) and
                any(label == "nestedlater_reader_null" for label, _ in after) is
                (case == CASES[1]) and
                any(label == "nestedlater_raw_mode" for label, _ in after) is
                (case == CASES[0]),
                f"Reader/bridge outcome differs: {case}")
        rows.append({
            "case": case,
            "fixture_sha256": FIXTURES[case],
            "private_result_sha256": sha256(path),
            "private_cdb_sha256": hashlib.sha256(raw).hexdigest(),
            "exact_signed_input_same_pid_clean_close_zero_wer_dumps_teardown": True,
            "bridge_status": 0 if case == CASES[0] else -2147467259,
            **branch,
        })
    return {
        "schema": "paint-new-nested-xlbox-heap-sample-redacted-review-v1",
        "trial": trial,
        "profile_sha256": stage["profile_sha256"],
        "profile_manifest_sha256": stage["profile_manifest_sha256"],
        "rows": rows,
        "claim_limit": (
            "Selected UUID copy-request, toggle pre-load, first-label pre-load, and "
            "last-label prospective source spans were checked against reported backend-heap "
            "user ends. These samples do not establish whole-loop safety, the actual "
            "UUID callee instruction width, an OOB, or a CVE patch location."
        ),
    }


def main() -> None:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--trial", required=True)
    args = parser.parse_args()
    print(json.dumps(verify_trial(args.trial), indent=2))


if __name__ == "__main__":
    try:
        main()
    except (ValueError, OSError, KeyError, StopIteration, json.JSONDecodeError) as exc:
        print(f"New nested heap review failed: {exc}", file=sys.stderr)
        raise SystemExit(1) from None