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/export_cold_prefetch_pair.py

Python · 21,833 bytes
#!/usr/bin/env python3
"""Export a fail-closed, address-free four-row cold Paint route comparison.

The input is four ignored local guest-result directories. This script reads
no network source and publishes no raw process ID, pointer, path, or CDB dump.
"""

from __future__ import annotations

import argparse
import json
import re
from datetime import datetime
from pathlib import Path

from build_cold_attach_smoke import PACKAGE_SHA256
from build_cold_prefetch_profile import CASES
from generate_cdb import POINTS, ROOT, VERSION, executable_rva, sha256


LAB = ROOT / "lab"
DEBUGGER_SHA256 = "a43c016463188513c9a3d99a2aeee2e55b88d3feb525de8bd128a7675310cd50"
MARKER_RE = re.compile(r"(?m)^PAINT_TRACE_HIT=([a-z][a-z0-9_]+)\s*$")
NORMAL_PID_RE = re.compile(
    r"(?m)^PAINT_TRACE_HIT_PID=([a-z][a-z0-9_]+):(\d+)(?=\s|$)"
)
WARNING_PID_RE = re.compile(
    r"(?mi)^PAINT_TRACE_HIT_PID=([a-z][a-z0-9_]+):\*\*\* WARNING: "
    r"Unable to verify checksum for (?:mspaint\.exe|ImageProcessing\.dll|"
    r"ProvenanceHelper\.dll|[^\r\n]*\\PaintApp\\(?:ImageProcessing|ProvenanceHelper)\.dll)\r?\n"
    r"(\d+)(?=\s|$)"
)


def require(condition: bool, reason: str) -> None:
    if not condition:
        raise ValueError(reason)


def one(paths: list[Path], what: str) -> Path:
    require(len(paths) == 1, f"expected one {what}, found {len(paths)}")
    return paths[0]


def read_json(path: Path) -> dict:
    value = json.loads(path.read_text(encoding="utf-8-sig"))
    require(isinstance(value, dict), f"wrong JSON object: {path.name}")
    return value


def hit_rows(log: str) -> list[dict[str, int | str]]:
    rows: list[tuple[int, str, int]] = []
    for pattern in (NORMAL_PID_RE, WARNING_PID_RE):
        for match in pattern.finditer(log):
            rows.append((match.start(), match.group(1), int(match.group(2))))
    rows.sort()
    return [{"label": label, "pid": pid} for _, label, pid in rows]


def hit_blocks(log: str) -> dict[str, list[str]]:
    matches = list(MARKER_RE.finditer(log))
    blocks: dict[str, list[str]] = {}
    for index, match in enumerate(matches):
        end = matches[index + 1].start() if index + 1 < len(matches) else len(log)
        blocks.setdefault(match.group(1), []).append(log[match.end():end])
    return blocks


def scalar(blocks: dict[str, list[str]], label: str, register: str) -> int | None:
    selected = blocks.get(label, [])
    if len(selected) != 1:
        return None
    values = re.findall(rf"(?m)^{re.escape(register)}=([0-9a-f]+)(?=\s|$)",
                        selected[0], re.IGNORECASE)
    return int(values[0], 16) if len(values) == 1 else None


def task_slot_same_nonzero(blocks: dict[str, list[str]]) -> bool | None:
    values: list[int] = []
    for label in ("prefetch_state_producer_task_stored",
                  "prefetch_state_lookup_global_task"):
        selected = blocks.get(label, [])
        if len(selected) != 1:
            return None
        qwords = re.findall(
            r"(?m)^[0-9a-f]{8}`[0-9a-f]{8}\s+([0-9a-f]{8}`[0-9a-f]{8})\s*$",
            selected[0], re.IGNORECASE,
        )
        if len(qwords) != 1:
            return None
        values.append(int(qwords[0].replace("`", ""), 16))
    return values[0] != 0 and values[0] == values[1]


def interval_ms(earlier: str | None, later: str | None) -> int | None:
    if not earlier or not later:
        return None
    def parse_dotnet_utc(value: str) -> datetime:
        # PowerShell's round-trip format can have seven fractional digits;
        # Python datetime accepts six. The discarded digit is <1 microsecond.
        clipped = re.sub(r"(\.\d{6})\d+(?=(?:Z|[+-]\d\d:\d\d)$)",
                         r"\1", value)
        return datetime.fromisoformat(clipped.replace("Z", "+00:00"))

    return round((parse_dotnet_utc(later) - parse_dotnet_utc(earlier))
                 .total_seconds() * 1000)


def read_error_dismissal_verified(result: dict, expected_pid: int) -> bool:
    dismissal = result.get("error_dialog_dismissal") or {}
    return (dismissal.get("attempted") is True and
            dismissal.get("route_guard") is True and
            dismissal.get("ui_window_pid") == expected_pid and
            dismissal.get("ui_error_text_found") is True and
            dismissal.get("ui_ok_button_candidates") == 1 and
            dismissal.get("method") ==
                "unique_same_pid_uia_ok_for_read_error" and
            not dismissal.get("error"))


def classify(build_name: str, case: str, markers: list[str],
             decoder_entries: int, mode: int | None,
             path_compare: int | None, lookup_nonnull: bool | None,
             same_task_slot: bool | None) -> str:
    seen = set(markers)
    if build_name == "old":
        if case == "valid_png" and {"image_image_open", "image_decoder",
                                    "flow_handoff_success_route"} <= seen:
            return "old_direct_success_route"
        if case == "missing_idat" and {"image_image_open", "image_decoder",
                                        "flow_handoff_error_route"} <= seen:
            return "old_direct_error_route"
        return "observed_unclassified"
    base = {"cold_min_prefetch_offer", "prefetch_state_producer_task_stored",
            "cold_min_prefetch_worker", "cache_prefetch_decoder_call",
            "cache_prefetch_decoder_return", "image_image_open",
            "prefetch_state_consumer_mode", "cache_lookup_call",
            "prefetch_state_lookup_path_equal", "cache_lookup_result"}
    if (not base <= seen or mode != 0 or path_compare != 2 or
            lookup_nonnull is not True or same_task_slot is not True):
        return "observed_unclassified"
    no_fallback = "cache_fallback_decoder_call" not in seen
    if (case == "valid_png" and decoder_entries == 1 and no_fallback and
            "cache_cached_image_route" in seen and
            "flow_handoff_success_route" in seen):
        return "new_cached_image_success_route"
    if (case == "missing_idat" and decoder_entries == 1 and no_fallback and
            {"prefetch_state_prefetch_failure_set",
             "cache_cached_failure_route",
             "prefetch_state_consumer_failure_skip"} <= seen):
        return "new_cached_failure_no_retry_route"
    if "cache_fallback_decoder_call" in seen:
        return "new_fallback_decoder_route"
    return "observed_unclassified"


def load_trial(root: Path, build_name: str, case: str) -> dict:
    require(root.is_dir(), f"missing local trial directory for {build_name}/{case}")
    label = root.name
    stage = read_json(LAB / "isolation" / "generated" /
                      f"{label}.cold-prefetch-stage.json")
    require(stage.get("schema") == "paint-ab-cold-prefetch-stage-v1" and
            stage.get("build") == build_name and stage.get("case_id") == case and
            stage.get("trial_label") == label and
            stage.get("launch_mode") == "DirectExe", "wrong staged trial identity")
    wsb = LAB / "isolation" / "generated" / f"{label}.wsb"
    require(wsb.is_file() and sha256(wsb) == stage.get("wsb_sha256"),
            "staged guest configuration changed")

    script_path = root / "staged-profile.cdb.txt"
    manifest_path = root / "staged-profile.cdb.txt.json"
    manifest = read_json(manifest_path)
    script_digest = sha256(script_path)
    manifest_digest = sha256(manifest_path)
    source_package = (ROOT / "packages" / VERSION[build_name] /
                      f"Paint_{VERSION[build_name]}_x64.msix")
    source_fixture = LAB / "corpus" / "generated" / CASES[case][0]
    require(sha256(source_package) == PACKAGE_SHA256[build_name] and
            sha256(source_fixture) == CASES[case][1],
            "signed source package or frozen fixture changed")
    require(manifest.get("schema") == "paint-ab-cold-prefetch-profile-v1" and
            manifest.get("profile") == build_name and
            manifest.get("version") == VERSION[build_name] and
            manifest.get("case") == case and
            manifest.get("script") == f"{build_name}.{case}.cold-prefetch.cdb.txt" and
            manifest.get("script_sha256") == script_digest and
            manifest.get("fixture_file") == CASES[case][0] and
            manifest.get("fixture_sha256") == CASES[case][1] and
            manifest.get("package_sha256") == PACKAGE_SHA256[build_name] and
            manifest.get("repeat_decoder_entry") is True and
            stage.get("package_sha256") == PACKAGE_SHA256[build_name] and
            stage.get("fixture_sha256") == CASES[case][1] and
            stage.get("mspaint_sha256") == manifest["modules"]["mspaint.exe"] and
            stage.get("cdb_profile_sha256") == script_digest and
            stage.get("cdb_manifest_sha256") == manifest_digest,
            "staged profile or signed bytes differ from archived profile")
    expected = {(p.path, p.label, p.module, f"0x{p.rva:X}")
                for p in POINTS[build_name]}
    checkpoints = manifest.get("checkpoints") or []
    require(len(checkpoints) == (34 if build_name == "new" else 12) and
            len({(p["path"], p["label"], p["module"], p["rva"])
                 for p in checkpoints}) == len(checkpoints) and
            all((p["path"], p["label"], p["module"], p["rva"]) in expected
                for p in checkpoints), "archived checkpoint list is incomplete")
    for module, expected_digest in manifest["modules"].items():
        binary = (ROOT / "packages" / VERSION[build_name] / "x64" /
                  "PaintApp" / module)
        require(sha256(binary) == expected_digest, f"signed module changed: {module}")
    for point in checkpoints:
        binary = (ROOT / "packages" / VERSION[build_name] / "x64" /
                  "PaintApp" / point["module"])
        require(executable_rva(binary, int(point["rva"], 16)),
                "archived checkpoint outside signed executable code")
    breakpoint_lines = [line for line in script_path.read_text(encoding="ascii").splitlines()
                        if line.startswith("bu ")]
    require(len(breakpoint_lines) == len(checkpoints) and
            sum(line.startswith("bu ImageProcessing+0x1570 ")
                for line in breakpoint_lines) == 1 and
            sum(line.startswith("bu /1 ") for line in breakpoint_lines) ==
                len(checkpoints) - 1 and
            all(".shell" not in line and line.endswith('; g"')
                for line in breakpoint_lines),
            "archived breakpoint script does not match bounded profile")
    for filename, stage_key in (
        ("guest_cold_prefetch.ps1", "guest_runner_sha256"),
        ("guest_cold_prefetch_entry.ps1", "guest_entry_sha256"),
        ("cold_attach_argv.ps1", "argv_helper_sha256"),
    ):
        archived_script = root / f"staged-{filename}"
        require(stage.get(stage_key) == sha256(archived_script),
                f"staged guest script changed: {filename}")

    batch_path = one(list(root.glob(f"cold-prefetch-batch-{build_name}-{case}-*.json")),
                     "cold prefetch batch")
    batch = read_json(batch_path)
    require(batch.get("schema") == "paint-ab-cold-prefetch-batch-v1" and
            batch.get("build") == build_name and batch.get("case_id") == case and
            batch.get("launch_mode") == "DirectExe" and
            batch.get("status") == "route_recorded" and not batch.get("error") and
            not batch.get("failure_cleanup"), "batch did not pass route gates")
    boot = batch.get("bootstrap") or {}
    require(boot.get("stage") == "complete" and
            boot.get("installed_version") == VERSION[build_name] and
            boot.get("result_fresh") is True and
            boot.get("result_sha256") == sha256(root / "bootstrap-result.json") and
            not (boot.get("child") or {}).get("timed_out") and
            (boot.get("child") or {}).get("stderr_bytes") == 0,
            "signed guest bootstrap is incomplete")
    result_path = one(list((root / "cold-prefetch" / build_name / case).glob("*/result.json")),
                      "cold prefetch result")
    result = read_json(result_path)
    route = batch.get("route") or {}
    route_child = route.get("child") or {}
    require(route.get("result_sha256") == sha256(result_path) and
            route.get("status") == "route_recorded" and not route.get("error") and
            not route_child.get("timed_out") and route_child.get("exited") is True and
            route_child.get("exit_code") in (None, 0) and
            route_child.get("stderr_bytes") == 0,
            "guest route child is incomplete")
    require(result.get("schema") == "paint-ab-cold-prefetch-run-v1" and
            result.get("build") == build_name and result.get("case_id") == case and
            result.get("launch_mode") == "DirectExe" and
            result.get("status") == "route_recorded" and not result.get("error") and
            result.get("installed_version") == VERSION[build_name] and
            result.get("package_full_name") ==
                f"Microsoft.Paint_{VERSION[build_name]}_x64__8wekyb3d8bbwe" and
            result.get("installed_exe_path_matches") is True and
            result.get("installed_exe_sha256") == manifest["modules"]["mspaint.exe"] and
            result.get("fixture_sha256") == CASES[case][1] and
            result.get("profile_sha256") == script_digest and
            result.get("profile_manifest_sha256") == manifest_digest and
            result.get("debugger_sha256") == DEBUGGER_SHA256 and
            result.get("runner_sha256") == stage["guest_runner_sha256"] and
            result.get("entry_sha256") == stage["guest_entry_sha256"] and
            result.get("argv_helper_sha256") == stage["argv_helper_sha256"],
            "guest result identity or script bytes differ from stage")
    modules = {row.get("module"): row.get("sha256")
               for row in result.get("installed_module_checks", [])}
    require(modules == manifest["modules"], "installed module digest set differs")

    shutdown = one(list(root.glob(f"startup-shutdown-{build_name}-*.json")),
                   "guest shutdown receipt")
    require(read_json(shutdown).get("exit_code") == 0,
            "normal guest shutdown request is missing")
    teardown = read_json(root / "teardown-result.json")
    require(teardown.get("state") == "closed" and
            teardown.get("sandbox_process_count_after") == 0 and
            teardown.get("guest_host_exited") is True and
            teardown.get("shutdown_evidence_count", 0) >= 1,
            "guarded guest teardown is incomplete")
    pid = result.get("paint_pid")
    close = result.get("paint_close") or {}
    debugger_exit = result.get("debugger_exit") or {}
    require(isinstance(pid, int) and pid > 0 and
            result.get("cdb_initial_pid") == pid and
            result.get("startup_hit_pid") == pid and
            result.get("startup_hit_count") == 1 and
            result.get("readiness_observed_utc") and
            result.get("startup_hit_observed_utc") and
            result.get("startup_hit_before_title_observation") is True and
            result.get("ready_before_file_title") is True and
            result.get("cdb_profile_seen") is True and
            result.get("cdb_ready_seen") is True and
            result.get("access_violation_seen") is False and
            result.get("dump_count_before") == result.get("dump_count_after") and
            close.get("initial_pids") == [pid] and
            close.get("close_requested_pids") == [pid] and
            not close.get("forced_pids") and not close.get("remaining_pids") and
            debugger_exit.get("exited_without_force") is True and
            debugger_exit.get("exit_code") == 0,
            "process, early hit, dump, or normal-close gate failed")
    if case == "valid_png":
        require(result.get("file_title_observed") is True and
                result.get("file_title_observed_utc") and
                "00_valid_png" in (result.get("observed_window_title") or ""),
                "valid image title was not observed")
    else:
        title = result.get("observed_window_title") or ""
        require(result.get("route_error_observed") is True and
                read_error_dismissal_verified(result, pid) and
                "Paint" in title and "01_png_missing_idat" not in title,
                "decode-error route, bounded dismissal, or blank-document title was not observed")

    log_path = result_path.parent / "cdb.log"
    log = log_path.read_text(encoding="utf-8", errors="replace")
    markers = MARKER_RE.findall(log)
    rows = hit_rows(log)
    require(result.get("cdb_log_sha256") == sha256(log_path) and
            re.findall(r"(?m)^PAINT_TRACE_PROFILE=([a-z]+)\s*$", log) == [build_name] and
            re.findall(r"(?m)^PAINT_TRACE_READY=([a-z]+)\s*$", log) == [build_name] and
            re.findall(r"(?m)^PAINT_TRACE_INITIAL_PID=(\d+)\s*$", log) == [str(pid)] and
            markers == result.get("route_markers") and
            rows == result.get("route_pid_records") and
            len(markers) == len(rows) and
            all(row["pid"] == pid and row["label"] == marker
                for row, marker in zip(rows, markers)) and
            markers.count("cold_min_startup_entry") == 1 and
            markers.count("image_image_open") == 1 and
            markers.count("image_decoder") == result.get("decoder_hit_count"),
            "raw CDB marker/PID chain differs from guest result")
    blocks = hit_blocks(log)
    mode = scalar(blocks, "prefetch_state_consumer_mode", "esi")
    path_compare = scalar(blocks, "prefetch_state_lookup_path_equal", "eax")
    lookup_value = scalar(blocks, "cache_lookup_result", "rsi")
    lookup_nonnull = None if lookup_value is None else lookup_value != 0
    same_task = task_slot_same_nonzero(blocks)
    derived = classify(build_name, case, markers,
                       result["decoder_hit_count"], mode, path_compare,
                       lookup_nonnull, same_task)
    return {
        "build": build_name,
        "version": VERSION[build_name],
        "case": case,
        "fixture_sha256": CASES[case][1],
        "package_sha256": PACKAGE_SHA256[build_name],
        "profile_sha256": script_digest,
        "cdb_log_sha256": sha256(log_path),
        "result_sha256": sha256(result_path),
        "batch_sha256": sha256(batch_path),
        "teardown_sha256": sha256(root / "teardown-result.json"),
        "route_markers": markers,
        "decoder_entry_hits": result["decoder_hit_count"],
        "mode_zero_observed": mode == 0 if mode is not None else None,
        "canonical_path_equal_observed": path_compare == 2 if path_compare is not None else None,
        "lookup_nonnull_observed": lookup_nonnull,
        "same_nonzero_task_slot_observed": same_task,
        "ready_to_startup_observed_ms": interval_ms(
            result["readiness_observed_utc"], result["startup_hit_observed_utc"]),
        "startup_to_title_observed_ms": interval_ms(
            result["startup_hit_observed_utc"], result.get("file_title_observed_utc")),
        "normal_paint_and_debugger_close": True,
        "guest_teardown_zero_processes": True,
        "route_classification": derived,
    }


def main() -> None:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--valid-only", action="store_true",
                        help="Export the two valid-PNG rows while error controls are pending")
    for build_name in ("old", "new"):
        for case in ("valid_png", "missing_idat"):
            parser.add_argument(f"--{build_name}-{case.replace('_', '-')}-root",
                                type=Path)
    parser.add_argument("--output", type=Path, required=True)
    args = parser.parse_args()
    roots = {
        (build_name, case): getattr(args, f"{build_name}_{case}_root")
        for build_name in ("old", "new")
        for case in ("valid_png", "missing_idat")
    }
    selected_cases = ("valid_png",) if args.valid_only else ("valid_png", "missing_idat")
    selected = {(build_name, case): roots[(build_name, case)]
                for case in selected_cases for build_name in ("old", "new")}
    require(all(path is not None for path in selected.values()),
            "required guest roots are missing")
    if args.valid_only:
        require(roots[("old", "missing_idat")] is None and
                roots[("new", "missing_idat")] is None,
                "error roots must be omitted from a valid-only export")
    require(len({path.resolve() for path in selected.values()}) == len(selected),
            "guest roots must be distinct")
    rows = [load_trial(selected[(build_name, case)], build_name, case)
            for case in selected_cases
            for build_name in ("old", "new")]
    record = {
        "schema": ("paint-ab-cold-prefetch-valid-pair-v1" if args.valid_only
                   else "paint-ab-cold-prefetch-four-row-v1"),
        "status": ("two_valid_route_records_verified" if args.valid_only
                   else "four_route_records_verified"),
        "limits": [
            ("These are two instrumented DirectExe valid-PNG fresh-process trials; "
             "decode-error controls are pending." if args.valid_only else
             "These are four instrumented DirectExe fresh-process trials."),
            "A route classification requires a full branch/operand chain, not one marker.",
            "Timing is guest polling time under CDB, not native execution timing.",
            "No out-of-bounds read or CVE patch location is inferred.",
        ],
        "rows": rows,
    }
    args.output.parent.mkdir(parents=True, exist_ok=True)
    args.output.write_text(json.dumps(record, indent=2) + "\n", encoding="utf-8")
    print(f"Verified {len(rows)} address-free cold prefetch route records")


if __name__ == "__main__":
    main()