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

Python · 14,264 bytes
"""Offline-only refusal gates for the pending two-file APP11 post-seek trace."""

from __future__ import annotations

import os
import shutil
import subprocess
import sys
import tempfile
import unittest
from pathlib import Path
from unittest.mock import patch

sys.path.insert(0, str(Path(__file__).resolve().parent))
import build_provenance_app11_postseek_trace as probe  # noqa: E402
import verify_provenance_app11_postseek_private as private  # noqa: E402


class App11PostseekProfileTests(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        if not all((probe.CORPUS / values[0]).is_file()
                   for values in probe.PAIR.values()):
            raise unittest.SkipTest("Frozen private APP11 pair unavailable")
        if not all((probe.ROOT / "packages" / probe.VERSION[build] /
                    "x64/PaintApp" / name).is_file()
                   for build in ("old", "new")
                   for name in probe.MODULES[build]):
            raise unittest.SkipTest("Signed Paint packages unavailable")

    def setUp(self) -> None:
        self.temp = tempfile.TemporaryDirectory()
        self.addCleanup(self.temp.cleanup)
        self.root = Path(self.temp.name)

    def test_old_profile_selects_wrapped_seek_and_bounded_later_reads(self) -> None:
        output = self.root / "old.cdb.txt"
        manifest = probe.build("old", output)
        script = output.read_text(encoding="ascii")
        self.assertEqual(manifest["status"], "pending_guest_measurement")
        self.assertIs(manifest["auto_continue"], True)
        self.assertIs(manifest["continue_process_exit"], True)
        self.assertIs(manifest["repeat_for_sequence"], False)
        self.assertIs(manifest["copy_paste_between_opens"], False)
        self.assertEqual(manifest["second_open_handoff_timeout_seconds"], 15)
        self.assertEqual(manifest["fixture_pair"]["case_ids"], list(probe.PAIR))
        self.assertIn('bu200 provenancesdk+0xC96B9', script)
        self.assertIn('bu201 provenancesdk+0xC96BF', script)
        self.assertEqual(script.count('bu200 provenancesdk+0xC96B9'), 1)
        self.assertEqual(script.count('bu201 provenancesdk+0xC96BF'), 1)
        self.assertIn('bu202 /w "@$t1 == 1" provenancesdk+0xC948E', script)
        self.assertIn('bu203 /w "@$t2 == 1" provenancesdk+0xC9497', script)
        self.assertIn('bu204 /w "@$t1 == 1" provenancesdk+0xC94CB', script)
        self.assertIn('bu205 /w "@$t3 == 1" provenancesdk+0xC94D7', script)
        self.assertNotIn('bu208', script)
        self.assertNotIn('bu209', script)
        self.assertIn(".if (@$t1 == 0) { .if (@rdx == 0xffff)", script)
        self.assertIn("(@$t4 == 0) & (@$tid == @$t7)", script)
        self.assertIn(".if ((@$t0 == 1) & (@$tid == @$t7)", script)
        self.assertIn("(@$t4 == 1) & (@$tid == @$t7)", script)
        self.assertIn("r $t4 = 2; bc 200; bc 201", script)
        self.assertIn('bu210 /w "@$t1 == 1" provenancesdk+0x5C8B0', script)
        self.assertIn('bu211 /w "@$t1 == 1" provenancesdk+0x5C90D', script)
        self.assertIn('bu212 /w "@$t1 == 1" provenancesdk+0x5CB3A', script)
        self.assertIn('r $t7 = @$tid; r $t8 = @rcx; r $t9 = @rbx', script)
        self.assertIn('(@$tid == @$t7) & (@rcx == @$t8)', script)
        self.assertIn('(@$tid == @$t7) & (@rdi == @$t8)', script)
        self.assertNotIn('&&', script)
        self.assertIn("!exts.heap -x @rdx", script)
        self.assertIn("!exts.heap -x poi(@rdi+8)", script)
        self.assertIn("PAINT_HEAP_VECTOR_QUERY", script)
        self.assertIn("PAINT_HEAP_SOURCE_QUERY", script)
        self.assertIn("dq @rdi+8 L2", script)
        self.assertIn("PAINT_POSTSEEK_CAP=reader_copy", script)
        self.assertEqual(script.count("PAINT_TRACE_HIT=postseek_"), 13)
        self.assertEqual(script.count("PAINT_TRACE_HIT=postseek_wrap_seek_call;"), 1)
        self.assertEqual(len(manifest["checkpoints"]), 21)

    def test_new_profile_keeps_reject_unlocated(self) -> None:
        output = self.root / "new.cdb.txt"
        manifest = probe.build("new", output)
        script = output.read_text(encoding="ascii")
        self.assertIs(manifest["auto_continue"], True)
        self.assertIn("bu /1 c2pa_c+0x43A60B", script)
        self.assertIn("bu /1 c2pa_c+0x43A96F", script)
        self.assertIn("bu /1 c2pa_c+0x4C90CC", script)
        self.assertIn("bu /1 c2pa_c+0x4C90D2", script)
        self.assertIn("bu /1 c2pa_c+0x4C90E6", script)
        self.assertIn("bu /1 PaintProvenanceNet+0x8EBF", script)
        self.assertIn("exact new C-reader reject instruction remains unlocated",
                      " ".join(manifest["limits"]))
        self.assertEqual(script.count("PAINT_TRACE_HIT=postseek_"), 11)
        self.assertEqual(len(manifest["checkpoints"]), 14)

    def test_fixture_change_fails_closed(self) -> None:
        wrong = dict(probe.PAIR)
        name, size, _digest = wrong["split_before_uuid_end"]
        wrong["split_before_uuid_end"] = (name, size, "0" * 64)
        with patch.object(probe, "PAIR", wrong):
            with self.assertRaisesRegex(ValueError, "Frozen APP11 pair changed"):
                probe.build("old", self.root / "invalid.cdb.txt")

    def test_signed_instruction_change_fails_closed(self) -> None:
        wrong = {build: dict(values) for build, values in probe.OPCODES.items()}
        wrong["old"][("provenancesdk.dll", 0xC948E)] = "00000000"
        with patch.object(probe, "OPCODES", wrong):
            with self.assertRaisesRegex(ValueError, "Signed opcode changed"):
                probe.build("old", self.root / "invalid.cdb.txt")

    def test_rejects_unsupported_build(self) -> None:
        with self.assertRaisesRegex(ValueError, "Choose old or new"):
            probe.build("other", self.root / "invalid.cdb.txt")


class App11PrivateReviewTests(unittest.TestCase):
    @unittest.skipUnless(sys.platform == "win32", "Host CDB smoke is Windows-only")
    def test_host_cdb_accepts_command_body_masm_identity_predicate(self) -> None:
        debugger = Path(r"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe")
        command = Path(os.environ.get("WINDIR", r"C:\Windows")) / "System32/cmd.exe"
        if not debugger.is_file() or not command.is_file():
            self.skipTest("Host x64 CDB or command process unavailable")
        expression = (
            "r $t7 = @$tid; r $t8 = @rcx; "
            ".if ((@$tid == @$t7) & (@rcx == @$t8)) { "
            ".if (1 == 1) { .echo PRED_OK } }; q"
        )
        run = subprocess.run(
            [str(debugger), "-c", expression, str(command), "/c", "exit", "0"],
            capture_output=True, text=True, timeout=20, check=False,
        )
        combined = run.stdout + run.stderr
        self.assertTrue(run.returncode == 0 and "PRED_OK" in combined and
                        "Syntax error" not in combined and
                        "Error evaluating" not in combined,
                        "Host CDB command-body MASM predicate parse failed")

    @unittest.skipUnless(sys.platform == "win32", "Host CDB smoke is Windows-only")
    def test_exact_stateful_seek_breakpoints_emit_both_phases(self) -> None:
        debugger = Path(r"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe")
        compiler = shutil.which("gcc")
        if not debugger.is_file() or compiler is None:
            self.skipTest("Host x64 CDB or GCC unavailable")
        source = (
            "__declspec(dllexport) __attribute__((noinline)) void marker(void* p, "
            "unsigned long long n) { volatile int x=0; x++; }\n"
            "__declspec(dllexport) __attribute__((noinline)) void seek_return(void) "
            "{ volatile int x=0; x++; }\n"
            "int main(void) { marker((void*)0x12345000,0xffff); seek_return(); "
            "marker((void*)0x12345000,47); seek_return(); return 0; }\n"
        )
        with tempfile.TemporaryDirectory() as folder:
            temp = Path(folder)
            c_file = temp / "smoke.c"
            executable = temp / "smoke.exe"
            c_file.write_text(source, encoding="ascii")
            built = subprocess.run(
                [compiler, str(c_file), "-O0", "-o", str(executable)],
                capture_output=True, text=True, timeout=20, check=False,
            )
            self.assertTrue(built.returncode == 0, "Local CDB smoke build failed")
            profile = temp / "old.auto.cdb.txt"
            probe.build("old", profile)
            lines = profile.read_text(encoding="ascii").splitlines()
            call = next(line for line in lines if line.startswith("bu200 "))
            returned = next(line for line in lines if line.startswith("bu201 "))
            call = call.replace("provenancesdk+0xC96B9", "smoke!marker") \
                       .replace("lmv m provenancesdk", "lmv m smoke")
            returned = returned.replace("provenancesdk+0xC96BF", "smoke!seek_return") \
                               .replace("lmv m provenancesdk", "lmv m smoke") \
                               .replace('".if (', '"r eax = 0; .if (', 1)
            smoke_script = temp / "smoke.cdb.txt"
            smoke_script.write_text("\n".join([
                "r $t0 = 0", "r $t1 = 0", "r $t4 = 0", "r $t7 = 0",
                "r $t8 = 0", "r $t9 = 0", call, returned, "g", "",
            ]), encoding="ascii")
            run = subprocess.run(
                [str(debugger), "-cf", str(smoke_script), str(executable)],
                capture_output=True, text=True, timeout=30, check=False,
            )
            combined = run.stdout + run.stderr
            observed = [line.strip().removeprefix("PAINT_TRACE_HIT=postseek_")
                        for line in combined.splitlines()
                        if line.strip().startswith("PAINT_TRACE_HIT=postseek_")]
            self.assertEqual(observed, ["wrap_seek_call", "wrap_seek_return",
                                        "next_skip", "next_skip_return"])
            self.assertTrue("Syntax error" not in combined and
                            "Error evaluating" not in combined and
                            "redefined" not in combined,
                            "Host CDB rejected the stateful single-breakpoint transition")

    def test_debugger_expression_error_fails_closed(self) -> None:
        log = "PAINT_TRACE_HIT=postseek_reader_copy\n" \
              "PAINT_TRACE_HIT_PID=postseek_reader_copy:123\n" \
              "Syntax error in breakpoint condition\n"
        with self.assertRaisesRegex(ValueError, "Debugger expression"):
            private.blocks_and_caps(log, 123)

    def test_missing_pid_link_fails_closed(self) -> None:
        log = "PAINT_TRACE_HIT=postseek_reader_copy\n"
        with self.assertRaisesRegex(ValueError, "marker/PID"):
            private.blocks_and_caps(log, 123)

    def test_selected_source_span_requires_vector_and_same_heap_chunk(self) -> None:
        begin = 0x100000000
        source = begin + 0x1003F
        end = begin + 140309
        header = begin - 0x10

        def heap_query(address: int, header_address: int) -> str:
            return ("Usage:                  Heap\n"
                    "The address was found in backend heap.\n"
                    "Allocation status        : Variable size allocated chunk.\n"
                    f"Search was performed for the following Address: 0x{address:x}\n"
                    f"Chunk header address     : {header_address:x}\n"
                    "Chunk size (bytes)       : 140352\n"
                    "Chunk unused bytes       : 0\n")

        body = (f"rdi=0000000200000000 rdx={source:016x} r8=0000000000000002\n"
                f"0000000200000008  {begin:016x} {end:016x}\n"
                "0000000200000020  000000000001003f\n"
                f"{private.HEAP_VECTOR}\n{heap_query(begin, header)}"
                f"{private.HEAP_SOURCE}\n{heap_query(source, header)}"
                f"{private.HEAP_DONE}\n")
        event = {"body": body, "reader": 0x200000000}
        sample = private.selected_copy(event)
        self.assertEqual(sample["source_file_offset"], 0x1003F)
        self.assertEqual(sample["copied_bytes"], 2)
        self.assertTrue(sample["span_within_whole_file_vector"])
        self.assertTrue(sample["span_within_reported_backend_chunk"])

        other = body.replace(f"{header:x}\nChunk size", "ffff0000\nChunk size", 1)
        with self.assertRaises(ValueError):
            private.selected_copy({"body": other, "reader": 0x200000000})

    def test_control_refuses_missing_uuid_route(self) -> None:
        with self.assertRaisesRegex(ValueError, "route is incomplete"):
            private.review_case([], private.CASES[1], set())

    def test_control_accepts_later_mismatch_after_first_copy(self) -> None:
        blocks = [
            ("image_image_open", ""),
            ("provenance_manifest_entry", ""),
            ("provenance_sdk_validation", ""),
            ("uuid_read_call", "r8=0000000000000001 r9=0000000000000010"),
            ("uuid_segment_after", "ax=0000"),
            ("uuid_uuid_second_compare", ""),
            ("uuid_copy_decision", ""),
            ("uuid_uuid_mismatch", ""),
        ]
        result = private.review_case(blocks, private.CASES[1], set())
        self.assertTrue(result["accepted_uuid_copy_route"])
        self.assertTrue(result["later_uuid_mismatch_observed"])
        self.assertFalse(result["wrapped_seek_route"])

    def test_old_split_refuses_missing_ordered_postseek_chain(self) -> None:
        blocks = [
            ("image_image_open", ""),
            ("provenance_manifest_entry", ""),
            ("provenance_sdk_validation", ""),
            ("uuid_read_call", "r8=0000000000000001 r9=0000000000000010"),
            ("uuid_segment_after", "ax=ffff"),
            ("uuid_uuid_second_compare", ""),
            ("uuid_uuid_mismatch", ""),
        ]
        with self.assertRaisesRegex(ValueError, "marker/read/seek order"):
            private.review_case(blocks, private.CASES[0], set())

    def test_cap_refuses_full_coverage_claim(self) -> None:
        with self.assertRaisesRegex(ValueError, "cap fired"):
            private.review_case([], private.CASES[0], {"reader_copy"})


if __name__ == "__main__":
    unittest.main()