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_review_bfdb_cache_trial.py

Python · 11,586 bytes
"""Offline, address-free reducer tests. No Paint process or guest is launched."""

from __future__ import annotations

import json
import sys
import unittest
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parent))
from review_bfdb_cache_trial import classify_cache_log, parse_cache_hits, review
from test_bfdb_sink_gate import sample_log
from test_review_bfdb_postopen_trial import sample


PID = 1956
TID = 72
SESSION = 0x10000
PARENT = 0x20000
FRESH = 0x30000
RECORD = 0x40000
MEDIA = 0x50000
MEDIA_END = MEDIA + 10


def event(name: str, hit: int = 1, *, pid: int = PID, tid: int = TID,
          **values: int) -> str:
    fields = {"hit": hit, "pid": pid, "tid": tid, **values}
    return "\n".join([
        f"PAINT_BFDB_CACHE_EVENT={name}",
        *(f"PAINT_BFDB_CACHE_VALUE={name}.{key}:{value:016x}"
          for key, value in fields.items()),
        f"PAINT_BFDB_CACHE_PID={name}:{pid}",
        f"PAINT_BFDB_CACHE_TID={name}:{tid}",
    ]) + "\n"


def log(*, cache_ptr: int = 0x90000, edited: int = 0,
        other_manifest: bool = False, semantic_read: bool = False) -> str:
    lines = [
        "PAINT_BFDB_CACHE_PROFILE=paint-bfdb-cache-gates-v1:old\n",
        "PAINT_BFDB_CACHE_ARMED=41\n",
        "0:000> bu500 provenancesdk+0x5C059 \".echo PAINT_BFDB_CACHE_EVENT=bogus\"\n",
        "PAINT_BFDB_POSTOPEN_EVENT=save_call\n",
        "PAINT_BFDB_POSTOPEN_EVENT=sdk_authoring_entry\n",
        event("reparse_validation_return", session=SESSION, validation=0x80000,
              status=0),
        event("reparse_parent_ready", session=SESSION, parent=PARENT, status=0,
              selected_record=RECORD, selected_media=MEDIA,
              selected_media_end=MEDIA_END, matches=1),
        event("authored_manifest_ready", session=SESSION, parent=PARENT,
              new_manifest=FRESH),
        "PAINT_BFDB_POSTOPEN_EVENT=authoring_embed\n",
        event("embed_parent", parent=PARENT, callback=0, callback_data=0,
              cache_ptr=cache_ptr, edited_byte=edited, selected_record=RECORD,
              selected_media=MEDIA, selected_media_end=MEDIA_END, matches=1),
    ]
    if other_manifest:
        lines += [event("parent_tojumbf_entry", this=0xABCD, callback=0,
                        callback_data=0, cache_ptr=0, edited_byte=0)]
    lines += [
        event("parent_tojumbf_entry", 2 if other_manifest else 1, this=PARENT,
              callback=0, callback_data=0, cache_ptr=cache_ptr, edited_byte=edited),
        event("parent_cache_test", this=PARENT, cache_ptr=cache_ptr,
              edited_byte=edited),
    ]
    if cache_ptr:
        lines += [event("parent_edited_test", this=PARENT, cache_ptr=cache_ptr,
                        edited_byte=edited)]
    branch = "parent_cached_branch" if cache_ptr and edited == 0 else "parent_no_cache_branch"
    lines += [event(branch, this=PARENT, cache_ptr=cache_ptr, edited_byte=edited)]
    if semantic_read:
        lines += [event("parent_record_loop", record=RECORD, callback=0),
                  event("parent_media_read", record=RECORD, media=MEDIA,
                        media_end=MEDIA_END)]
    lines += ["PAINT_BFDB_POSTOPEN_EVENT=save_call_return\n"]
    return "".join(lines)


class CacheReviewTests(unittest.TestCase):
    def test_cached_reparsed_parent_is_bounded_nonhit(self) -> None:
        result = classify_cache_log(log(), PID)
        self.assertEqual(result["category"],
                         "authored_parent_cached_no_selected_semantic_read")
        self.assertEqual(result["parent_branch"], "cached")
        self.assertFalse(result["selected_semantic_media_read_seen"])
        self.assertNotIn(str(PARENT), json.dumps(result))
        self.assertNotIn(str(MEDIA), json.dumps(result))

    def test_other_manifest_entry_does_not_replace_selected_parent(self) -> None:
        result = classify_cache_log(log(other_manifest=True), PID)
        self.assertEqual(result["other_manifest_entries_in_save_window"], 1)
        self.assertEqual(result["parent_branch"], "cached")

    def test_uncached_selected_media_read_is_positive_semantic_hit(self) -> None:
        result = classify_cache_log(log(cache_ptr=0, semantic_read=True), PID)
        self.assertEqual(result["category"],
                         "authored_parent_uncached_selected_semantic_read")
        self.assertTrue(result["selected_record_loop_seen"])
        self.assertTrue(result["selected_semantic_media_read_seen"])

    def test_edited_cache_uses_no_cache_branch(self) -> None:
        result = classify_cache_log(log(edited=1, semantic_read=True), PID)
        self.assertEqual(result["parent_edited_state"], "set")
        self.assertEqual(result["parent_branch"], "no_cache")

    def test_multiple_same_parent_cached_episodes_with_later_callback(self) -> None:
        extra = "".join([
            event("parent_tojumbf_entry", 2, this=PARENT, callback=0,
                  callback_data=0, cache_ptr=0x90000, edited_byte=0),
            event("parent_cache_test", 2, this=PARENT, cache_ptr=0x90000,
                  edited_byte=0),
            event("parent_edited_test", 2, this=PARENT, cache_ptr=0x90000,
                  edited_byte=0),
            event("parent_cached_branch", 2, this=PARENT, cache_ptr=0x90000,
                  edited_byte=0),
            event("parent_tojumbf_entry", 3, this=PARENT, callback=0xABC,
                  callback_data=0xDEF, cache_ptr=0x90000, edited_byte=0),
            event("parent_cache_test", 3, this=PARENT, cache_ptr=0x90000,
                  edited_byte=0),
            event("parent_edited_test", 3, this=PARENT, cache_ptr=0x90000,
                  edited_byte=0),
            event("parent_cached_branch", 3, this=PARENT, cache_ptr=0x90000,
                  edited_byte=0),
        ])
        candidate = log().replace("PAINT_BFDB_POSTOPEN_EVENT=save_call_return\n",
                                  extra + "PAINT_BFDB_POSTOPEN_EVENT=save_call_return\n")
        result = classify_cache_log(candidate, PID)
        self.assertEqual(result["category"],
                         "authored_parent_cached_no_selected_semantic_read")
        self.assertEqual(result["same_parent_serializer_calls"], 3)
        broken = candidate.replace("parent_cached_branch.cache_ptr:0000000000090000",
                                   "parent_cached_branch.cache_ptr:0000000000000000", 1)
        with self.assertRaises(ValueError):
            classify_cache_log(broken, PID)

    def test_uncached_parent_without_selected_read_is_incomplete(self) -> None:
        for candidate in (log(cache_ptr=0), log(edited=1)):
            with self.subTest(case=candidate[:30]), self.assertRaises(ValueError):
                classify_cache_log(candidate, PID)

    def test_missing_or_ambiguous_identity_fails_closed(self) -> None:
        cases = [
            log().replace(f"new_manifest:{FRESH:016x}", f"new_manifest:{PARENT:016x}"),
            log().replace(f"embed_parent.parent:{PARENT:016x}",
                          "embed_parent.parent:000000000000dead"),
            log().replace("PAINT_BFDB_CACHE_EVENT=parent_cache_test", "BAD_EVENT"),
            log().replace("PAINT_BFDB_CACHE_EVENT=reparse_parent_ready", "BAD_EVENT"),
            log().replace(f"embed_parent.matches:{1:016x}",
                          "embed_parent.matches:0000000000000000"),
            log().replace(f"parent_cached_branch.this:{PARENT:016x}",
                          "parent_cached_branch.this:000000000000dead"),
            log().replace(f"parent_cache_test.cache_ptr:{0x90000:016x}",
                          "parent_cache_test.cache_ptr:0000000000000000"),
            log().replace(f"reparse_parent_ready.status:{0:016x}",
                          "reparse_parent_ready.status:0000000000000001"),
        ]
        for index, candidate in enumerate(cases):
            with self.subTest(index=index), self.assertRaises(ValueError):
                classify_cache_log(candidate, PID)

    def test_missed_cap_skip_or_process_mismatch_fails_closed(self) -> None:
        cases = [
            log().replace("PAINT_BFDB_CACHE_ARMED=41", "PAINT_BFDB_CACHE_ARMED=40"),
            log() + "PAINT_BFDB_CACHE_CAP=parent_media_read\n",
            log() + "PAINT_BFDB_CACHE_SKIP=parent_record_not_unique\n",
            log().replace("PAINT_BFDB_CACHE_PID=embed_parent:1956",
                          "PAINT_BFDB_CACHE_PID=embed_parent:9999"),
            log().replace("PAINT_BFDB_CACHE_VALUE=embed_parent.tid:0000000000000048",
                          "PAINT_BFDB_CACHE_VALUE=embed_parent.tid:0000000000000049"),
        ]
        for index, candidate in enumerate(cases):
            with self.subTest(index=index), self.assertRaises(ValueError):
                classify_cache_log(candidate, PID)

    def test_duplicate_hit_or_wrong_counter_fails_closed(self) -> None:
        duplicate = log().replace("PAINT_BFDB_POSTOPEN_EVENT=save_call_return\n",
                                  event("parent_cache_test", 2, this=PARENT,
                                        cache_ptr=0x90000, edited_byte=0) +
                                  "PAINT_BFDB_POSTOPEN_EVENT=save_call_return\n")
        with self.assertRaises(ValueError):
            classify_cache_log(duplicate, PID)
        miscount = log().replace("parent_cache_test.hit:0000000000000001",
                                 "parent_cache_test.hit:0000000000000002")
        with self.assertRaises(ValueError):
            parse_cache_hits(miscount, PID)

    def test_cached_branch_cannot_have_selected_reader(self) -> None:
        with self.assertRaises(ValueError):
            classify_cache_log(log(semantic_read=True), PID)

    def test_selected_reader_outside_parent_episode_fails_closed(self) -> None:
        early = event("parent_media_read", record=RECORD, media=MEDIA,
                      media_end=MEDIA_END)
        candidate = log().replace("PAINT_BFDB_CACHE_EVENT=authored_manifest_ready",
                                  early + "PAINT_BFDB_CACHE_EVENT=authored_manifest_ready")
        with self.assertRaises(ValueError):
            classify_cache_log(candidate, PID)

    def test_full_route_review_and_missing_source_fail_closed(self) -> None:
        stage, guest, teardown = sample()
        stage["schema"] = "paint-bfdb-cache-stage-v1"
        guest["schema"] = "paint-bfdb-cache-guest-v1"
        guest["paint_pid"] = PID
        guest["debugger_initial_pid"] = PID
        guest["marker_pid_records"] = [
            {"event": row["event"], "pid": PID} for row in guest["marker_pid_records"]
        ]
        joined = (
            "PAINT_BFDB_POSTOPEN_PROFILE=paint-bfdb-cache-gates-v1:old\n"
            "PAINT_BFDB_POSTOPEN_ARMED=41\n"
            + sample_log("control") + log()
        )
        result = review(stage, guest, teardown, joined, True, True)
        self.assertEqual(result["category"],
                         "authored_parent_cached_no_selected_semantic_read")
        self.assertTrue(result["same_guest_source_handoff_verified"])
        self.assertEqual(result["paint_visible_disclosure"], "not_established")
        self.assertNotIn(str(PARENT), json.dumps(result))
        missing_source = review(stage, guest, teardown, log(), True, True)
        self.assertEqual(missing_source["category"], "incomplete_or_invalid")
        self.assertFalse(missing_source["same_guest_source_handoff_verified"])
        wrong_input = review(stage, guest, teardown, joined, True, False)
        self.assertEqual(wrong_input["category"], "incomplete_or_invalid")


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