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

Python · 11,401 bytes
#!/usr/bin/env python3
"""Build a pinned, focused CDB profile for the legacy Paint CBOR reader.

The profile is only debugger input. A breakpoint or a malformed CBOR item is
not itself evidence of an out-of-bounds read; the guest must supply the
faulting instruction and the actual containing allocation extent.
"""

from __future__ import annotations

import argparse
import json
from dataclasses import asdict
from pathlib import Path

import pefile

from generate_cdb import Checkpoint, POINTS, ROOT, VERSION, executable_rva, render, sha256


HASHES = {
    "old": {
        "mspaint.exe": "d94d89377a2a78a73b95cff70fc7706df9ae2ae53175bd6d26abb8301e36ecd9",
        "ProvenanceHelper.dll": "39d54d518204658bd858a18d747d7b39a009771bc1f68847409114014dff0cca",
        "provenancesdk.dll": "339d8f47ea7bcc08b0c1f122a1e94d5d31860f1ad1ccf7faea1625ffd6de3904",
    },
    "new": {
        "mspaint.exe": "1b35e6c1161dcc057079841fd47c9af93a2c31e002d70cfc159cea6db1134ed4",
        "ProvenanceHelper.dll": "00c6165c9ddb5575948e4b13a2af8545e9b424946b7ef97da9274b2b1856389c",
        "PaintProvenanceNet.dll": "c59f9aa9edec638b7c75ae063654913fa1435624517c2520d60d56d3c4af5288",
    },
}
EXT_HASH = "42e8ccd67d74f0d1a23fc0c7a0977d4027d5fc37e130431d218d67e990244a03"
EXTS_HASH = "9b2741e158c708484c0e81a2cfe483c2ece9ea52af155c61a15c129664686685"


EXTRA = {
    "old": [
        Checkpoint("cbor", "array_payload_entry", "provenancesdk.dll", 0x166A50,
                   "CBOR array/map payload entry; inspect declared element vector",
                   "dq @rcx+0x10 L2; dq @rdx L1; dq @r8 L1; kv 8"),
        Checkpoint("cbor", "array_loop", "provenancesdk.dll", 0x166AD0,
                   "First selected element-loop iteration; cursor and remaining locals",
                   "dq @rbp-0x79 L1; dq @rbp-0x71 L1"),
        Checkpoint("cbor", "item_entry", "provenancesdk.dll", 0x164B20,
                   "CBORDataItem::CreateFromBuffer entry; cursor and remaining pointers",
                   "dq @rdx L1; dq @r8 L1"),
        Checkpoint("cbor", "cursor_commit", "provenancesdk.dll", 0x165124,
                   "Pre-store item cursor; RAX is the advanced value",
                   "r rax; r rcx; dq @rcx L1"),
        Checkpoint("cbor", "remaining_commit", "provenancesdk.dll", 0x16512B,
                   "Pre-store remaining value in R13; RAX points to caller slot",
                   "r r13; r rax; dq @rax L1"),
    ],
    "new": [
        Checkpoint("cbor", "read_bridge", "ProvenanceHelper.dll", 0xF63D,
                   "New backend read call"),
        Checkpoint("cbor", "read_status", "ProvenanceHelper.dll", 0xF659,
                   "New backend return status", "r eax"),
        Checkpoint("cbor", "backend_entry", "PaintProvenanceNet.dll", 0x2BDE0,
                   "Replacement reader entry"),
    ],
}


def points_for(profile: str) -> list[Checkpoint]:
    shared_labels = {
        "image_image_open", "flow_decoder_return", "flow_provenance_call",
        "flow_after_provenance", "provenance_manifest_entry",
    }
    points = [point for point in POINTS[profile]
              if f"{point.path}_{point.label}" in shared_labels]
    if profile == "old":
        points += [point for point in POINTS[profile]
                   if point.path == "provenance" and point.label in {
                       "sdk_validation", "box_header", "deserializer"}]
    else:
        points += [point for point in POINTS[profile]
                   if point.path == "provenance" and point.label == "paint_net_read"]
    return points + EXTRA[profile]


def verify_pin(binary: Path, rva: int, expected: bytes) -> None:
    pe = pefile.PE(str(binary), fast_load=True)
    try:
        if pe.get_data(rva, len(expected)) != expected:
            raise ValueError(f"Opcode pin differs at {binary.name}+0x{rva:X}")
    finally:
        pe.close()


def build(profile: str, output: Path) -> dict[str, object]:
    points = points_for(profile)
    modules: dict[str, dict[str, str]] = {}
    for point in points:
        binary = ROOT / "packages" / VERSION[profile] / "x64" / "PaintApp" / point.module
        if not binary.is_file() or not executable_rva(binary, point.rva):
            raise ValueError(f"Missing or non-executable checkpoint: {point.module}+0x{point.rva:X}")
        digest = sha256(binary)
        if digest != HASHES[profile][point.module]:
            raise ValueError(f"Signed {profile} module digest differs: {point.module}")
        modules[point.module] = {"sha256": digest}
    if profile == "old":
        ext = ROOT / "lab/isolation/dependencies/debugger/winext/ext.dll"
        exts = ROOT / "lab/isolation/dependencies/debugger/winxp/exts.dll"
        if (not ext.is_file() or sha256(ext) != EXT_HASH or
                not exts.is_file() or sha256(exts) != EXTS_HASH):
            raise ValueError("Pinned heap debugger extension differs")
        binary = ROOT / "packages" / VERSION[profile] / "x64" / "PaintApp" / "provenancesdk.dll"
        for rva, opcode in {
            0x164B20: bytes.fromhex("48895c2420"),
            0x164B52: bytes.fromhex("4d8be8"),
            0x16501A: bytes.fromhex("4d8b6d00"),
            0x16511C: bytes.fromhex("4a8d0423"),
            0x165120: bytes.fromhex("488b4de7"),
            0x165124: bytes.fromhex("488901"),
            0x165127: bytes.fromhex("488b45ef"),
            0x16512B: bytes.fromhex("4c8928"),
            0x166A50: bytes.fromhex("48895c2420"),
            0x166AA6: bytes.fromhex("488b4118"),
            0x166AAA: bytes.fromhex("482b4110"),
            0x166AAE: bytes.fromhex("48c1f804"),
            0x166AD0: bytes.fromhex("0f57c9"),
        }.items():
            verify_pin(binary, rva, opcode)

    # The old CBOR checkpoints must follow the declared 0x8000-element array.
    # One-shot breakpoints at function entry could be consumed by unrelated
    # manifest items before that array is parsed. Keep the shared route
    # markers one-shot and add target-gated breakpoints below.
    rendered_points = [point for point in points if profile != "old" or point.path != "cbor"]
    script = render(profile, rendered_points, auto_continue=True,
                    ignore_winui_rpc=True, skip_breakpoint_listing=True)
    if profile == "old":
        # A first-chance AV remains stopped. The private log captures the read
        # address, call stack, and candidate heap contexts for later review.
        av = ('sxe -c ".echo CBOR_FIRST_CHANCE_AV; .exr -1; '
              '!vprot @rcx; !vprot @$t0; '
              '.ecxr; r; kv 20; r $t0; r $t1; r $t2; '
              '.echo CBOR_OPTIONAL_HEAP_QUERY; !heap -x @$t0" av')
        if script.count("sxe av\n") != 1:
            raise ValueError("Cannot pin first-chance AV context action")
        script = script.replace("sxe av\n", av + "\n", 1)
        initialize = (r".load C:\PaintLab\Input\debugger\winext\ext.dll" + "\n"
                      + r".load C:\PaintLab\Input\debugger\winxp\exts.dll" + "\n"
                      ".expr /s masm\nr $t0 = 0\nr $t1 = 0\nr $t2 = 0\nr $t3 = 0\n")
        if script.count("sxd 8001010e\n") != 1 or not script.endswith("g\n"):
            raise ValueError("Cannot place target-gated CBOR breakpoints")
        script = script.replace("sxd 8001010e\n", "sxd 8001010e\n" + initialize, 1)

        def quoted(command: str) -> str:
            return '"' + command.replace('"', '\\"') + '"'

        def event(label: str, capture: str) -> str:
            return (f".echo PAINT_TRACE_HIT=cbor_{label}; "
                    f'.printf "PAINT_TRACE_HIT_PID=cbor_{label}:%u\\n", @$tpid; '
                    f"{capture}")

        # `bu /w` cannot bind MASM `poi` in the debugger data-model evaluator.
        # Break on container entries, then take an ordinary MASM `.if` action
        # only for the two pinned count spans. Nonmatches emit no evidence.
        thread_gate = "(@$t3 == 1) & (@$tid == @$t2)"
        # Signed instructions +0x166AA6..AE calculate exactly this vector
        # byte span and shift by four to derive the declared element count.
        array_gate = ("((poi(@rcx+0x18)-poi(@rcx+0x10)) == 0x40000) | "
                      "((poi(@rcx+0x18)-poi(@rcx+0x10)) == 0x80000)")

        def guarded(number: int, rva: int, gate: str, label: str,
                    capture: str) -> str:
            action = f".if ({gate}) {{ bd {number}; {event(label, capture)} }}; g"
            return f"bu{number} provenancesdk+0x{rva:X} {quoted(action)}"

        extra = [
            guarded(310, 0x166A50, array_gate, "array_payload_entry",
                "r $t0 = poi(@rdx); r $t1 = poi(@r8); "
                "r $t2 = @$tid; r $t3 = 1; "
                '.printf "PAINT_CBOR_INITIAL_CURSOR=%p\\n", @$t0; '
                '.printf "PAINT_CBOR_INITIAL_REMAINING=%u\\n", @$t1; '
                '.printf "PAINT_CBOR_DECLARED_COUNT=%u\\n", '
                '(poi(@rcx+0x18)-poi(@rcx+0x10))/0x10; '
                "dq @rcx+0x10 L2; ? @$t0; !vprot @$t0; kv 8"),
            guarded(311, 0x166AD0, thread_gate, "array_loop",
                    "dq @rbp-0x79 L1; dq @rbp-0x71 L1; r $t0; r $t1"),
            guarded(312, 0x164B20, thread_gate, "item_entry",
                    "dq @rdx L1; dq @r8 L1"),
            guarded(313, 0x165124, thread_gate, "cursor_commit",
                    "r rax; r rcx; dq @rcx L1; r $t0; r $t1"),
            guarded(314, 0x16512B, thread_gate, "remaining_commit",
                    "r r13; r rax; dq @rax L1; r $t0; r $t1"),
        ]
        script = script[:-2] + "\n".join(extra) + "\ng\n"
    output.parent.mkdir(parents=True, exist_ok=True)
    output.write_text(script, encoding="ascii")
    manifest: dict[str, object] = {
        "schema": "paint-cbor-focused-trace-v1",
        "profile": profile,
        "version": VERSION[profile],
        "script": output.name,
        "auto_continue": True,
        "first_chance_av_stops": True,
        "pageheap_extension_sha256": EXT_HASH if profile == "old" else None,
        "heap_fallback_extension_sha256": EXTS_HASH if profile == "old" else None,
        "target_declared_counts": [0x4000, 0x8000] if profile == "old" else [],
        "array_vector_element_bytes": 16 if profile == "old" else None,
        "modules": modules,
        "checkpoints": [asdict(p) | {"rva": f"0x{p.rva:X}"} for p in points],
        "limits": [
            "All instruction pins and RVAs apply only to the stated signed x64 build.",
            "Old CBOR breakpoints log only a 0x4000- or 0x8000-element vector and its thread.",
            "Old target breakpoints disable after the first hit; no per-element trace is emitted.",
            "A fault is not an OOB finding until its read address is compared with the actual allocation.",
            "Private CDB logs and addresses remain in ignored lab/results.",
        ],
    }
    output.with_suffix(output.suffix + ".json").write_text(
        json.dumps(manifest, indent=2) + "\n", encoding="utf-8"
    )
    return manifest


def main() -> None:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--profile", choices=("old", "new"), required=True)
    parser.add_argument("--output", type=Path, required=True)
    args = parser.parse_args()
    manifest = build(args.profile, args.output)
    print(f"Prepared {len(manifest['checkpoints'])} signed checkpoints; no guest launched")


if __name__ == "__main__":
    main()