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

Python · 31,053 bytes
#!/usr/bin/env python3
"""Reduce a completed signed new-Paint Batch E child-decision guest offline.

The guest, fixtures, profile, results, and raw debugger logs are private inputs.
Only an address-free, claim-bounded JSON summary may be written to the public
evidence directory. This program never stages input or starts a guest.
"""

from __future__ import annotations

import argparse
import json
import re
from pathlib import Path
from typing import Any

from export_provenance_sdk_matrix import (
    LAB, MARKER_RE, VERSIONS, case_id, digest, read_json, require,
    require_clean_guest, require_normal_close, section_value,
)


SCHEMA = "paint-provenance-e-child-decision-review-v1"
STAGE_SCHEMA = "paint-provenance-e-child-decision-stage-v1"
PROFILE_SCHEMA = "paint-provenance-e-child-decision-profile-v1"
CASES = ("control", "child_jumb_parent_plus1",
         "child_unknown_parent_plus1")
FOCUS_IDS = ("40_official_c2pa_jpeg", "sdk_child_jumb_parent_plus1",
             "sdk_child_unknown_parent_plus1")
FIRST_CHILD_CURSOR = 0x81
PARENT_REMAINING = 0xC72D
MODULE_SHA256 = "3e913b50757364b5cf04e7f84c0fcb81704f9522a2b6a95399a22eadf95c2238"
GUEST_ENTRY_SHA256 = "ced4e5f81d5e96142f94964e1ce1a21fe5a6f4ccc6de444fff324baa6ee52e27"
CORPUS_SHA256 = "3af209ab19db7c216efe265e92435b2be1df97e5b5e468cf26a0c3defa8eb522"
# Frozen r2 contract. Its script and manifest are also bound by the published
# SHA-256 values; later profile builders may append or reorder other gates.
_R2_POINT_DATA = """
selected_header_call|4C9901|e8eacbffff|frame,reader,base,length,cursor,parent_end
header_reader_entry|4C64F0|415741564154|reader,result,cursor,return
header_vector_guard|4C6517|4d39e7|base,length,cursor
header_available_compare|4C652B|4883f908|source,remaining
header_width_clamp|4C6534|480f42d9|remaining,candidate_width
header_copy_call|4C656D|e82e48b400|source,destination,width,cursor
header_copy_return|4C6572|4c01e3|width,cursor
selected_header_return|4C9906|4c8bb578010000|reader,kind,declared,cursor
kind_decision|4C9951|0f871b050000|kind,declared,cursor,parent_end,flags
recursive_call|4C996D|e86ef6ffff|reader,depth,declared,cursor
recursive_return|4C9972|488b9510030000|result_status,cursor
unknown_fallback|4C9E72|488b056f970f01|kind,declared,cursor
unknown_next_header|4C9F3F|e8acc5ffff|cursor,parent_end
unknown_payload_call|4C9F90|e8bb652b00|reader,requested,cursor
generic_read_entry|780550|55|reader,requested,return
generic_overflow_add|7805DF|4801f9|cursor,requested,reader_length
generic_carry_branch|7805E2|7347|end,flags
generic_end_compare|780638|4d39fd|end,reader_length,cursor,requested,reader_base
generic_end_branch|78063B|764f|end,reader_length,flags
generic_small_copy|780795|e806a68800|source,destination,width,cursor
parent_bound_compare|4C9E54|4c396b10|cursor,parent_end,kind
parent_overshoot_status|4CA14A|48c7460805000000|cursor,parent_end,result
parent_result_return|4C9075|4889f0|result,status
"""
R2_POINTS = tuple((label, int(rva, 16), opcode, tuple(fields.split(",")))
                  for label, rva, opcode, fields in
                  (line.split("|") for line in _R2_POINT_DATA.strip().splitlines()))
LABEL_RE = re.compile(r"[a-z0-9][a-z0-9-]{0,39}\Z")
VALUE_RE = re.compile(r"(?m)(?<!\S)PAINT_ECHILD_VALUE=(echild_[a-z0-9_]+)\.([a-z_]+):([0-9a-fA-F`]+)(?=\s|$)")
TID_RE = re.compile(r"(?m)(?<!\S)PAINT_ECHILD_TID=(echild_[a-z0-9_]+):([0-9]+)(?=\s|$)")
HIT_RE = re.compile(r"(?m)(?<!\S)PAINT_ECHILD_HIT=(echild_[a-z0-9_]+):([0-9]+)(?=\s|$)")
SHA_RE = re.compile(r"[0-9a-f]{64}\Z")
PRIVATE_RE = re.compile(r"(?i)(?:[a-z]:[\\/]|\\\\|file:/|0x[0-9a-f]{9,}|\b(?:10|127|192\.168)\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)")
MAX_LOG = 16 * 1024 * 1024
POINT_MAP = {f"echild_{label}": fields for label, _rva, _opcode, fields
             in R2_POINTS}
CORE = (
    "selected_header_call", "header_reader_entry", "header_vector_guard",
    "header_available_compare", "header_width_clamp", "header_copy_call",
    "header_copy_return", "selected_header_return", "kind_decision",
)
TYPE_BYTES = {
    "control": b"jumb",
    "child_jumb_parent_plus1": b"jumb",
    "child_unknown_parent_plus1": b"zzzz",
}
EXPECTED = {
    "control": ((int.from_bytes(b"jumb", "big") << 32) | 1,
                32252, "0x00000000", "raw_export"),
    "child_jumb_parent_plus1": ((int.from_bytes(b"jumb", "big") << 32) | 1,
                                50990, "0x80004005", "null"),
    "child_unknown_parent_plus1": ((int.from_bytes(b"zzzz", "big") << 32) | 12,
                                   50990, "0x80004005", "null"),
}


def _number(raw: str) -> int:
    return int(raw.replace("`", ""), 16)


def _single(pattern: re.Pattern[str], section: str, label: str) -> re.Match[str]:
    matches = list(pattern.finditer(section))
    require(len(matches) == 1 and matches[0].group(1) == label,
            f"Missing or duplicate {pattern.pattern[:20]} for {label}")
    return matches[0]


def parse_child_events(log: str, markers: list[str], paint_pid: int,
                       name: str, c2pa_base: int) -> dict[str, Any]:
    """Check bound first-child observations; return only safe derived values."""
    require(name in EXPECTED and isinstance(paint_pid, int) and paint_pid > 0 and
            isinstance(c2pa_base, int) and c2pa_base > 0,
            "Unknown case, Paint PID, or signed C2PA base")
    require(not re.search(
        r"(?im)^(?:Error evaluating breakpoint condition\b|"
        r"Breakpoint condition did not evaluate to a boolean\b|"
        r"Unable to bind name\b|(?:Expression )?Syntax error\b)", log),
        "Debugger condition, binding, or syntax failed; marker reach is unreliable")
    hits = list(MARKER_RE.finditer(log))
    require([hit.group(1) for hit in hits] == markers,
            "Focused result and raw debugger marker lists differ")
    first_child = next((hit.start() for hit in hits
                        if hit.group(1).startswith("echild_")), len(log))
    require("PAINT_ECHILD_DUPLICATE=" not in log[first_child:] and
            "PAINT_ECHILD_CAP=" not in log[first_child:],
            "Selected child repeated or trace cap fired")
    sections: dict[str, str] = {}
    child_order: list[str] = []
    for index, hit in enumerate(hits):
        label = hit.group(1)
        if not label.startswith("echild_"):
            continue
        require(label in POINT_MAP and label not in sections,
                f"Unknown or repeated child gate: {label}")
        section = log[hit.end(): hits[index + 1].start()
                      if index + 1 < len(hits) else len(log)]
        sections[label] = section
        child_order.append(label)
    require(all(f"echild_{label}" in sections for label in CORE),
            "Core selected child/header/decision gates incomplete")
    require(child_order[0] == "echild_selected_header_call",
            "Selected first-child gate did not precede other child markers")
    require(child_order.index("echild_selected_header_call") <
            child_order.index("echild_header_reader_entry") <
            child_order.index("echild_selected_header_return") <
            child_order.index("echild_kind_decision"),
            "First-child gate sequence differs")
    require("newdesc_c_reader" in markers and
            markers.index("newdesc_c_reader") <
            markers.index("echild_selected_header_call") and
            "newdesc_reader_ffi_return" in markers and
            markers.index("echild_selected_header_call") <
            markers.index("newdesc_reader_ffi_return"),
            "Child gate is outside the signed C-reader window")

    values: dict[str, dict[str, int]] = {}
    tids: set[int] = set()
    for label in child_order:
        section = sections[label]
        tid_match = _single(TID_RE, section, label)
        hit_match = _single(HIT_RE, section, label)
        require(int(hit_match.group(2)) == 1,
                f"Child gate was not first selected hit: {label}")
        tids.add(int(tid_match.group(2)))
        rows = list(VALUE_RE.finditer(section))
        expected_fields = POINT_MAP[label]
        require(tuple(row.group(2) for row in rows) == expected_fields and
                all(row.group(1) == label for row in rows),
                f"Child operands incomplete or out of order: {label}")
        values[label] = {row.group(2): _number(row.group(3)) for row in rows}
        if label in {"echild_header_copy_call", "echild_generic_small_copy"}:
            require(section.count(f"PAINT_ECHILD_HEAP_BEGIN={label}") == 1 and
                    section.count(f"PAINT_ECHILD_HEAP_END={label}") == 1,
                    f"Bounded private heap sample incomplete: {label}")
    require(len(tids) == 1 and next(iter(tids)) > 0,
            "Child gates crossed thread identities")

    call = values["echild_selected_header_call"]
    entry = values["echild_header_reader_entry"]
    vector = values["echild_header_vector_guard"]
    available = values["echild_header_available_compare"]
    copy = values["echild_header_copy_call"]
    returned = values["echild_selected_header_return"]
    decision = values["echild_kind_decision"]
    kind, declared, _status, _return = EXPECTED[name]
    require(call["reader"] != 0 and call["base"] != 0 and
            call["length"] >= FIRST_CHILD_CURSOR + 8 and
            call["cursor"] == FIRST_CHILD_CURSOR and
            call["parent_end"] - call["cursor"] == PARENT_REMAINING and
            entry["reader"] == call["reader"] and
            entry["cursor"] == FIRST_CHILD_CURSOR and
            entry["return"] == c2pa_base + 0x4C9906 and
            vector == {"base": call["base"], "length": call["length"],
                       "cursor": FIRST_CHILD_CURSOR} and
            available["source"] == call["base"] + FIRST_CHILD_CURSOR and
            available["remaining"] == call["length"] - FIRST_CHILD_CURSOR and
            copy["source"] == available["source"] and
            copy["width"] == 8 and
            copy["cursor"] == FIRST_CHILD_CURSOR and
            copy["source"] + copy["width"] <= call["base"] + call["length"] and
            returned["reader"] == call["reader"] and
            returned["cursor"] == FIRST_CHILD_CURSOR + 8 and
            returned["kind"] == kind and returned["declared"] == declared and
            decision["kind"] == kind and
            decision["cursor"] == FIRST_CHILD_CURSOR and
            decision["parent_end"] == call["parent_end"],
            "Selected child identity, logical bound, or expected header differs")
    require(values["echild_header_copy_return"]["cursor"] ==
            FIRST_CHILD_CURSOR,
            "Header copy cursor differs before selected return")
    require(values["echild_header_width_clamp"]["remaining"] ==
            available["remaining"],
            "Header available-byte count differs at width clamp")

    recursive = "echild_recursive_call" in sections
    fallback = "echild_unknown_fallback" in sections
    require(not (recursive and fallback), "Contradictory child branch gates")
    if recursive:
        row = values["echild_recursive_call"]
        require((kind & 0xFFFFFFFF) == 1 and row["reader"] == call["reader"] and
                row["declared"] == declared and
                row["cursor"] == FIRST_CHILD_CURSOR,
                "Recursive branch changed selected child identity")
        if "echild_recursive_return" in sections:
            require(child_order.index("echild_recursive_call") <
                    child_order.index("echild_recursive_return"),
                    "Recursive return preceded call")
    if fallback:
        row = values["echild_unknown_fallback"]
        require((kind & 0xFFFFFFFF) == 12 and row["kind"] == kind and
                row["declared"] == declared and
                row["cursor"] == FIRST_CHILD_CURSOR,
                "Unknown fallback changed selected child identity")
    for label in ("unknown_next_header", "unknown_payload_call",
                  "generic_read_entry", "generic_overflow_add",
                  "generic_carry_branch", "generic_end_compare",
                  "generic_end_branch", "generic_small_copy"):
        if f"echild_{label}" in sections:
            require(fallback, f"{label} reached without selected fallback")
    if "echild_parent_overshoot_status" in sections:
        require("echild_parent_bound_compare" in sections,
                "Parent status writer reached without selected comparison")
    if "echild_parent_result_return" in sections:
        require(child_order.index("echild_parent_result_return") >
                child_order.index("echild_kind_decision"),
                "Selected parent return preceded child decision")

    generic_names = ("generic_read_entry", "generic_overflow_add",
                     "generic_carry_branch", "generic_end_compare",
                     "generic_end_branch", "generic_small_copy")
    generic_seen = [label for label in generic_names
                    if f"echild_{label}" in sections]
    generic_guard = ("not_applicable_recognized_child" if
                     (kind & 0xFFFFFFFF) != 12 else
                     "guard_checkpoints_reached_unverified_extent" if
                     all(label in generic_seen for label in
                         ("generic_read_entry", "generic_end_compare",
                          "generic_end_branch")) else
                     "partial_inconclusive" if generic_seen else
                     "not_observed_in_bounded_trace")
    branch = ("recognized_recursive_call" if recursive else
              "unknown_fallback" if fallback else "decision_only_inconclusive")
    return {
        "first_child_cursor": FIRST_CHILD_CURSOR,
        "parent_remaining": PARENT_REMAINING,
        "child_kind": TYPE_BYTES[name].decode("ascii"),
        "child_kind_enum": kind & 0xFFFFFFFF,
        "declared_lbox": declared,
        "header_copy_width": 8,
        "header_read_within_logical_vector": True,
        "branch": branch,
        "generic_payload_guard": generic_guard,
        "signed_gates_reached": [label.removeprefix("echild_")
                                 for label in child_order],
        "status_writer_instruction_localized": False,
        "exact_user_allocation_extent_measured": False,
    }


def trial_inputs(lab: Path, label: str) -> dict[str, Any]:
    """Select immutable per-trial inputs when present, without fallback."""
    snapshot = lab / "output" / "provenance-e-child-snapshots" / label
    require(not snapshot.exists() or snapshot.is_dir(),
            "Per-trial snapshot path is not a directory")
    if snapshot.is_dir():
        return {
            "snapshot": True,
            "profile": snapshot / "new.auto.cdb.txt",
            "guest": snapshot / "guest_focus_entry.ps1",
            "followup": snapshot / "followup.manifest.json",
            "corpus": snapshot / "corpus.manifest.json",
        }
    return {
        "snapshot": False,
        "profile": lab / "output" / "provenance-e-child-decision" /
                   "new.auto.cdb.txt",
        "guest": lab / "output" / "provenance-e-child-decision" /
                 "guest_focus_entry.ps1",
        "followup": lab / "isolation" / "input" / "new" /
                    "followup" / "manifest.json",
        "corpus": lab / "isolation" / "input" / "new" /
                  "corpus" / "manifest.json",
    }


def verify_input_hashes(paths: dict[str, Any], sidecar: dict[str, Any],
                        base: dict[str, Any],
                        guest_hash: str = GUEST_ENTRY_SHA256) -> dict[str, str]:
    """Bind selected profile/guest/manifest bytes to the original stage."""
    profile = paths["profile"]
    profile_manifest = Path(str(profile) + ".json")
    needed = (profile, profile_manifest, paths["guest"],
              paths["followup"], paths["corpus"])
    require(all(path.is_file() for path in needed),
            "Selected trial inputs are incomplete")
    hashes = {
        "profile": digest(profile),
        "profile_manifest": digest(profile_manifest),
        "guest": digest(paths["guest"]),
        "followup": digest(paths["followup"]),
        "corpus": digest(paths["corpus"]),
    }
    require(hashes["profile"] == sidecar.get("profile_sha256") ==
            base.get("profile_sha256") and
            hashes["profile_manifest"] == sidecar.get("profile_manifest_sha256") ==
            base.get("profile_manifest_sha256") and
            hashes["guest"] == sidecar.get("guest_entry_sha256") ==
            base.get("guest_entry_sha256") == guest_hash and
            hashes["followup"] == base.get("staged_manifest_sha256"),
            "Selected profile, guest entry, or followup manifest hash differs")
    return hashes


def _profile_and_stage(label: str, lab: Path,
                       manifest_sha: str) -> tuple[dict[str, Any], dict[str, Any]]:
    generated = lab / "isolation" / "generated"
    sidecar = read_json(generated / f"{label}.provenance-e-child-decision-stage.json")
    base_path = generated / f"{label}.provenance-sdk-matrix-stage.json"
    base = read_json(base_path)
    wsb = generated / f"{label}.wsb"
    paths = trial_inputs(lab, label)
    staged_corpus = paths["corpus"]
    staged_followup = paths["followup"]
    base_corpus = lab / "corpus" / "generated" / "manifest.json"
    require(sidecar.get("schema") == STAGE_SCHEMA and
            sidecar.get("status") == "staged_not_run" and
            sidecar.get("trial_label") == label and
            sidecar.get("build") == "new" and
            sidecar.get("selected_case_ids") == list(CASES) and
            sidecar.get("selected_focus_ids") == list(FOCUS_IDS) and
            base.get("schema") == "paint-provenance-sdk-matrix-stage-v1" and
            base.get("build") == "new" and base.get("batch") == "E" and
            base.get("trial_label") == label and
            base.get("selected_cases") == list(FOCUS_IDS) and
            base.get("corpus_schema") == "paint-provenance-sdk-child-frontier-v1" and
            base.get("corpus_manifest_sha256") == manifest_sha and
            staged_corpus.is_file() and
            (paths["snapshot"] or (base_corpus.is_file() and
             digest(staged_corpus) == digest(base_corpus))) and
            staged_followup.is_file() and
            base.get("mode") == "new-handler-signed-rust" and
            base.get("internal_rust") is True and
            base.get("lean_internal_rust") is True and
            base.get("heap_context") is False and
            base.get("description_guard") is False and
            base.get("diagnostic_mode") == "new-e-first-child-decision" and
            sidecar.get("source_stage_sha256") == digest(base_path) and
            wsb.is_file() and sidecar.get("wsb_sha256") == digest(wsb) and
            base.get("wsb_sha256") == digest(wsb),
            "Signed child stage/WSB/fixture selection differs")
    input_hashes = verify_input_hashes(paths, sidecar, base)
    profile_path = paths["profile"]
    profile_meta_path = Path(str(profile_path) + ".json")
    profile = read_json(profile_meta_path)
    require(profile.get("schema") == PROFILE_SCHEMA and
            profile.get("profile") == "new" and
            profile.get("version") == VERSIONS["new"] and
            profile.get("diagnostic_mode") == "new-e-first-child-decision" and
            profile.get("auto_continue") is True,
            "Signed child profile or canonical guest entry differs")
    selected = profile.get("selected_first_child", {})
    expected_points = [dict(label=point_label, rva=f"0x{rva:X}",
                            opcode=opcode, breakpoint=620 + index,
                            selected=index == 0)
                       for index, (point_label, rva, opcode, _fields)
                       in enumerate(R2_POINTS)]
    require(selected.get("case_ids") == list(CASES) and
            selected.get("focus_ids") == list(FOCUS_IDS) and
            selected.get("cursor_in_assembled_jumbf") == FIRST_CHILD_CURSOR and
            selected.get("parent_remaining") == PARENT_REMAINING and
            selected.get("signed_module_sha256") == MODULE_SHA256 and
            selected.get("pinned_guest_entry_sha256") == GUEST_ENTRY_SHA256 and
            selected.get("points") == expected_points and
            len([row for row in profile.get("checkpoints", [])
                 if row.get("path") == "echild"]) == len(R2_POINTS) and
            profile.get("modules", {}).get("c2pa_c.dll", {}).get("sha256") ==
            MODULE_SHA256 and
            profile.get("fixture_manifest", {}).get("sha256") == manifest_sha,
            "Selected child gate, module, or fixture profile differs")
    module_hashes = {name: row["sha256"] for name, row in profile["modules"].items()}
    for name, row in profile["modules"].items():
        package = lab.parent / row["package_path"]
        require(package.is_file() and digest(package) == row["sha256"],
                f"Local signed module differs: {name}")
    published_path = lab / "evidence" / "provenance-e-child-decision-r2.json"
    if label == "new-e-child-r2" and published_path.is_file():
        published = read_json(published_path)
        require(published.get("schema") == SCHEMA and
                published.get("stage_sha256") == digest(generated /
                    f"{label}.provenance-e-child-decision-stage.json") and
                published.get("wsb_sha256") == sidecar.get("wsb_sha256") and
                published.get("profile_sha256") == input_hashes["profile"] and
                published.get("profile_manifest_sha256") ==
                input_hashes["profile_manifest"] and
                published.get("signed_module_sha256", {}).get("c2pa_c.dll") ==
                MODULE_SHA256,
                "Published r2 stage/profile/module pins differ")
    return sidecar, {"stage_sha256": digest(generated /
                                            f"{label}.provenance-e-child-decision-stage.json"),
                     "profile_manifest_sha256": input_hashes["profile_manifest"],
                     "base_corpus_sha256": input_hashes["corpus"],
                     "staged_manifest_sha256": base["staged_manifest_sha256"],
                     "module_hashes": module_hashes}


def review(label: str = "new-e-child-r1", lab: Path = LAB) -> dict[str, Any]:
    require(LABEL_RE.fullmatch(label) is not None, "Unsafe trial label")
    corpus_path = lab / "corpus" / "provenance_sdk_child_frontier" / "generated" / "manifest.json"
    manifest = read_json(corpus_path)
    manifest_sha = digest(corpus_path)
    require(manifest_sha == CORPUS_SHA256 and
            manifest.get("schema") == "paint-provenance-sdk-child-frontier-v1" and
            len(manifest.get("cases", [])) == 15,
            "Pinned child-frontier corpus differs")
    source_rows = {row["id"]: row for row in manifest["cases"]}
    require(all(name in source_rows for name in CASES),
            "Selected child fixtures missing")
    stage, identity = _profile_and_stage(label, lab, manifest_sha)
    root = lab / "results" / label
    batch_files = list(root.glob("focus-batch-*.json"))
    shutdown_files = list(root.glob("focus-shutdown-*.json"))
    require(len(batch_files) == len(shutdown_files) == 1,
            "Completed guest batch or shutdown receipt missing/ambiguous")
    summary = read_json(batch_files[0])
    shutdown = read_json(shutdown_files[0])
    teardown = read_json(root / "teardown-result.json")
    require_clean_guest(summary, shutdown, teardown, "new", label,
                        list(FOCUS_IDS))

    cases: dict[str, Any] = {}
    for name, summary_case in zip(CASES, summary["cases"]):
        focused_id = case_id(name)
        require(summary_case.get("case_id") == focused_id and
                summary_case.get("status") == "complete" and
                summary_case.get("child_exited_verified") is True and
                summary_case.get("timed_out") is False and
                summary_case.get("process_exit_code") == 0 and
                summary_case.get("error") is None,
                f"New child/{name} focused trial incomplete")
        results = list((root / "focus" / "new" / focused_id).glob("*/result.json"))
        require(len(results) == 1 and
                digest(results[0]) == summary_case.get("result_sha256"),
                f"New child/{name} result missing/ambiguous/different")
        result_path = results[0]
        log_path = result_path.with_name("cdb.log")
        require(log_path.is_file() and 0 < log_path.stat().st_size <= MAX_LOG,
                f"New child/{name} debugger log missing/oversized")
        result = read_json(result_path)
        source = source_rows[name]
        fixture = corpus_path.parent / source["file"]
        require(fixture.is_file() and fixture.stat().st_size == source["bytes"] and
                digest(fixture) == source["sha256"] and
                fixture.read_bytes()[0xA5:0xA9] == TYPE_BYTES[name] and
                result.get("schema") == "paint-ab-focused-cdb-v1" and
                result.get("build") == "new" and
                result.get("case_id") == focused_id and
                result.get("status") == "complete" and
                result.get("error") is None and
                result.get("file_open_filename_value_verified") is True and
                result.get("fixture", {}).get("sha256") == source["sha256"] and
                result.get("fixture_manifest_sha256") ==
                (identity["base_corpus_sha256"] if name == "control" else
                 identity["staged_manifest_sha256"]) and
                result.get("trace_script_sha256") == stage["profile_sha256"] and
                result.get("trace_manifest_sha256") == identity["profile_manifest_sha256"] and
                result.get("installed_package", {}).get("version") == VERSIONS["new"] and
                result.get("installed_exe_sha256") ==
                identity["module_hashes"]["mspaint.exe"],
                f"New child/{name} file/profile/package identity differs")
        modules = result.get("loaded_module_checks", [])
        hashes = identity["module_hashes"]
        require({row.get("module") for row in modules} == set(hashes) and
                all(row.get("matches_signed_package") is True and
                    row.get("sha256") == hashes[row.get("module")]
                    for row in modules),
                f"New child/{name} loaded module identity differs")
        pid = result.get("blank_pid")
        before = result.get("markers_before_open", [])
        after = result.get("markers_after_open", [])
        marker_pids = result.get("marker_pid_records", [])
        require(isinstance(pid, int) and pid > 0 and
                result.get("file_open_launch_pid") == pid and
                result.get("cdb_initial_pid") == pid and
                [row.get("marker") for row in marker_pids] == before + after and
                all(row.get("pid") == pid for row in marker_pids) and
                not any(marker.startswith("echild_") for marker in before) and
                "newdesc_c_reader" in after and
                after[:2] == ["image_image_open", "image_decoder"] and
                "flow_handoff_success_route" in after,
                f"New child/{name} Paint PID/marker route differs")
        log = log_path.read_text(encoding="utf-8", errors="replace")
        module_base = next(row.get("base") for row in modules
                           if row.get("module") == "c2pa_c.dll")
        require(isinstance(module_base, str) and
                re.fullmatch(r"0x[0-9a-fA-F]{8,16}", module_base) is not None,
                f"New child/{name} signed C2PA loaded base missing")
        child = parse_child_events(log, before + after, pid, name,
                                   int(module_base, 16))
        require_normal_close(result.get("cleanup", {}),
                             result.get("post_close_health", {}), pid,
                             "new", name)
        status = section_value(log, "newdesc_backend_return", "ebx")
        expected_kind, expected_length, expected_status, expected_return = EXPECTED[name]
        reader_return = ("raw_export" if "newdesc_c_raw" in after else
                         "null" if "newdesc_reader_null" in after else
                         "not_observed")
        require("rustjpeg_assembled_result" in after and
                "newdesc_c_reader" in after and
                status == expected_status and
                reader_return == expected_return and
                child["declared_lbox"] == expected_length and
                child["child_kind"] == TYPE_BYTES[name].decode("ascii") and
                child["child_kind_enum"] == (expected_kind & 0xFFFFFFFF),
                f"New child/{name} signed C-reader outcome differs")
        cases[name] = {
            "fixture_sha256": source["sha256"],
            "private_result_sha256": digest(result_path),
            "private_log_sha256": digest(log_path),
            "bridge_status_hex": status,
            "reader_return": reader_return,
            "first_child": child,
        }
    output = {
        "schema": SCHEMA,
        "scope": "signed_new_build_three_case_first_child_decision",
        "version": VERSIONS["new"],
        "selected_case_names": list(CASES),
        "stage_sha256": identity["stage_sha256"],
        "wsb_sha256": stage["wsb_sha256"],
        "profile_sha256": stage["profile_sha256"],
        "profile_manifest_sha256": identity["profile_manifest_sha256"],
        "signed_module_sha256": identity["module_hashes"],
        "batch_result_sha256": digest(batch_files[0]),
        "shutdown_verified": True,
        "cases": cases,
        "limits": [
            "A selected guard and branch describe one bounded first-child route, not every parser path.",
            "The eight-byte header read is within the logical reader vector; this does not measure an exact allocator user extent.",
            "Write watchpoints and private heap output are not promoted to exact writer or user-allocation claims here.",
            "No result here establishes an out-of-bounds read, disclosure, code execution, or CVE patch site.",
        ],
    }
    encoded = json.dumps(output, indent=2)
    require(PRIVATE_RE.search(encoded) is None,
            "Public review unexpectedly contains a private address/path/host")
    return output


def main() -> None:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--trial-label", default="new-e-child-r1")
    parser.add_argument("--output", type=Path)
    args = parser.parse_args()
    try:
        output = review(args.trial_label)
    except (ValueError, OSError, KeyError, TypeError, IndexError) as exc:
        parser.exit(2, f"Refused signed child decision review: {exc}\n")
    rendered = json.dumps(output, indent=2) + "\n"
    if args.output:
        args.output.parent.mkdir(parents=True, exist_ok=True)
        args.output.write_text(rendered, encoding="utf-8")
    else:
        print(rendered, end="")


if __name__ == "__main__":
    main()