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 files5

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

lab/corpus/provenance_bfdb_marker/verify_fixtures.py

Python · 11,430 bytes
#!/usr/bin/env python3
"""Independently verify bounded bfdb marker carriers and decoded rasters.

This reads generated JPEGs, never starts Paint, and does not import the
builder. A structurally coherent JUMBF tree is not a valid C2PA signature or
proof that Paint's SDK will process each added leaf.
"""

from __future__ import annotations

import argparse
import hashlib
import io
import json
import re
from pathlib import Path

from PIL import Image


ROOT = Path(__file__).resolve().parents[3]
HERE = Path(__file__).resolve().parent
SOURCE = ROOT / "lab/corpus/third_party/c2pa_org_adobe_20220124_C.jpg"
DEFAULT_OUTPUT = ROOT / "lab/output/provenance-bfdb-marker"
SOURCE_SHA = "75a8da33f6eaf1e16bf3b42cd78913b22b2e6a671fda217a508b1ba4230ce864"
TRIGGER_SHA = "82e1ad0b1be3183b0a6075ce53a44a888f149765f24cd2a681b0656b348a8f9a"
RASTER_SHA = "7f25d7f8c55e7191e3bf1488268d8c5d92fc6766398903229a612e7fe7e7de6b"
TINY_SHA = "02f3266d22333786627b3f8a1e36da7d8451d1967f19bffefbb57f402440b2af"
NAME = re.compile(r"^(siblings|assertions)-(sameparse|firstopen)-(01|04|16)\.jpg$")
SOURCE_LENGTHS = {0x16: (2, 51128), 0x20: (4, 51118), 0x46: (4, 51080),
                  0xA1: (4, 32252), 0xD2: (4, 31695)}


def sha(data: bytes) -> str:
    return hashlib.sha256(data).hexdigest()


def box_at(data: bytes, offset: int, limit: int) -> tuple[int, bytes, bytes]:
    if offset < 0 or offset + 8 > limit or limit > len(data):
        raise ValueError("JUMBF box header lies outside parent")
    length = int.from_bytes(data[offset:offset + 4], "big")
    kind = data[offset + 4:offset + 8]
    if length < 8 or offset + length > limit:
        raise ValueError("JUMBF LBox leaves parent")
    return offset + length, kind, data[offset + 8:offset + length]


def marker(index: int) -> bytes:
    if not 1 <= index <= 16:
        raise ValueError("Marker index differs")
    return f"A{index:02d}".encode("ascii") + b"\x00"


def checked_source() -> bytes:
    data = SOURCE.read_bytes()
    if len(data) != 140297 or sha(data) != SOURCE_SHA:
        raise ValueError("Licensed source identity differs")
    segment_end = 0x14 + 2 + int.from_bytes(data[0x16:0x18], "big")
    if (data[:2] != b"\xff\xd8" or data[-2:] != b"\xff\xd9" or
            data[0x14:0x16] != b"\xff\xeb" or segment_end != 51150 or
            data[0x10D:0x121] != b"\x00\x00\x00\x14bfdb\x00image/jpeg\x00"):
        raise ValueError("Licensed source APP11/bfdb geometry differs")
    return data


def verify_structure(data: bytes, source: bytes, layout: str,
                     sequence: str, count: int) -> None:
    segment_end = 0x14 + 2 + int.from_bytes(data[0x16:0x18], "big")
    original_segment_end = 0x14 + 2 + SOURCE_LENGTHS[0x16][1]
    delta = count * (24 if layout == "siblings" else 722)
    if (segment_end != original_segment_end + delta or
            segment_end > 0x14 + 2 + 65535 or
            len(data) != len(source) + delta or
            data[segment_end:] != source[original_segment_end:]):
        raise ValueError("APP11 size or untouched JPEG tail differs")
    ancestors = (0x16, 0x20, 0x46, 0xA1, 0xD2) if layout == "siblings" else (
        0x16, 0x20, 0x46, 0xA1,
    )
    for offset, (width, old) in SOURCE_LENGTHS.items():
        if layout == "assertions" and offset == 0xD2:
            # A new child occupies this absolute offset. The original child's
            # unchanged LBox is checked at offset+delta below.
            continue
        expected = old + delta if offset in ancestors else old
        if int.from_bytes(data[offset:offset + width], "big") != expected:
            raise ValueError("Ancestor JUMBF LBox differs")
    root_end, kind, _ = box_at(data, 0x20, segment_end)
    manifest_end, manifest_kind, _ = box_at(data, 0x46, root_end)
    assertions_end, assertions_kind, _ = box_at(data, 0xA1, manifest_end)
    if (root_end != segment_end or manifest_end != 0x46 + 51080 + delta or
            assertions_end != 0xA1 + 32252 + delta or
            (kind, manifest_kind, assertions_kind) != (b"jumb",) * 3 or
            box_at(data, 0x28, root_end)[1] != b"jumd" or
            box_at(data, 0x4E, manifest_end)[1] != b"jumd" or
            box_at(data, 0xA9, assertions_end)[1] != b"jumd"):
        raise ValueError("Nested source JUMBF hierarchy differs")
    if layout == "siblings":
        inserted_at = 0x10D
        current = inserted_at
        embedded_start = 0xD2
        embedded_end, embedded_kind, _ = box_at(data, embedded_start,
                                                 assertions_end)
        if embedded_kind != b"jumb" or embedded_end != 0xD2 + 31695 + delta:
            raise ValueError("Embedded-file parent size differs")
        desc_end, desc_kind, _ = box_at(data, 0xDA, embedded_end)
        if desc_end != inserted_at or desc_kind != b"jumd":
            raise ValueError("Embedded-file description differs")
        for index in range(1, count + 1):
            current, child_kind, body = box_at(data, current, embedded_end)
            if child_kind != b"bfdb" or body != b"\x00image/jpeg\x00" + marker(index):
                raise ValueError("Inserted sibling bfdb marker differs")
    elif layout == "assertions":
        inserted_at = 0xD2
        current = inserted_at
        for index in range(1, count + 1):
            child_end, child_kind, _ = box_at(data, current, assertions_end)
            if child_kind != b"jumb" or child_end - current != 722:
                raise ValueError("Compact assertion parent differs")
            description_end, description_kind, description = box_at(
                data, current + 8, child_end,
            )
            label = f"c2pa.thumbnail.mark-{index:05d}".encode("ascii")
            if (description_kind != b"jumd" or
                    description != source[0xE2:0xF3] + label + b"\x00"):
                raise ValueError("Compact assertion UUID/label differs")
            bfdb_end, bfdb_kind, body = box_at(data, description_end, child_end)
            if bfdb_kind != b"bfdb" or body != b"\x00image/jpeg\x00" + marker(index):
                raise ValueError("Compact assertion media marker differs")
            bidb_end, bidb_kind, payload = box_at(data, bfdb_end, child_end)
            if bidb_kind != b"bidb" or bidb_end != child_end or sha(payload) != TINY_SHA:
                raise ValueError("Compact assertion binary differs")
            with Image.open(io.BytesIO(payload)) as tiny:
                tiny.load()
                if tiny.format != "JPEG" or tiny.size != (1, 1):
                    raise ValueError("Compact assertion binary is not a tiny JPEG")
            current = child_end
        embedded_start = current
        embedded_end, embedded_kind, _ = box_at(data, embedded_start,
                                                 assertions_end)
        if embedded_kind != b"jumb" or embedded_end != embedded_start + 31695:
            raise ValueError("Original embedded-file child moved incorrectly")
        original_desc_end, original_desc_kind, _ = box_at(
            data, embedded_start + 8, embedded_end,
        )
        if original_desc_kind != b"jumd" or original_desc_end != embedded_start + 59:
            raise ValueError("Original embedded-file description moved incorrectly")
        current = original_desc_end
    else:
        raise ValueError("Unknown layout")
    original_bfdb_end, original_kind, original_body = box_at(data, current,
                                                             embedded_end)
    if (original_kind != b"bfdb" or original_bfdb_end != current + 20 or
            original_body != b"\x00image/jpeg" +
                (b"\x01" if sequence == "sameparse" else b"\x00")):
        raise ValueError("Original target bfdb differs")
    original_bidb_end, original_bidb_kind, _ = box_at(data, original_bfdb_end,
                                                     embedded_end)
    if original_bidb_kind != b"bidb" or original_bidb_end != embedded_end:
        raise ValueError("Original bidb end differs")
    reduced = bytearray(data[:inserted_at] + data[inserted_at + delta:])
    for offset in ancestors:
        width, _ = SOURCE_LENGTHS[offset]
        reduced[offset:offset + width] = source[offset:offset + width]
    if sequence == "sameparse":
        reduced[0x120] = 0
    if bytes(reduced) != source:
        raise ValueError("Carrier changed bytes outside insertion and target")


def verify(output_dir: Path = DEFAULT_OUTPUT) -> None:
    source = checked_source()
    manifest = json.loads((HERE / "manifest.json").read_text(encoding="utf-8"))
    rows = manifest.get("outputs")
    if (manifest.get("schema") != "paint-bfdb-marker-placement-offline-v1" or
            manifest.get("source_file") !=
                "lab/corpus/third_party/c2pa_org_adobe_20220124_C.jpg" or
            manifest.get("source_sha256") != SOURCE_SHA or
            manifest.get("source_license") != "CC-BY-SA-4.0" or
            manifest.get("source_upstream_commit") !=
                "22beccc075707475b038d8789d0136c009e43143" or
            manifest.get("target_trigger_sha256") != TRIGGER_SHA or
            manifest.get("synthetic_bidb_jpeg_sha256") != TINY_SHA or
            manifest.get("decoded_raster_sha256") != RASTER_SHA or
            manifest.get("decoded_raster") != {
                "width": 2048, "height": 1365, "mode": "RGB"} or
            manifest.get("marker_counts") != [1, 4, 16] or
            manifest.get("box_length_status") != "recomputed_and_structurally_checked" or
            manifest.get("c2pa_cryptographic_status") !=
                "original_claim_and_signature_not_reissued" or
            manifest.get("paint_acceptance") != "not_tested" or
            not isinstance(rows, list) or len(rows) != 12):
        raise ValueError("Marker manifest identity differs")
    expected_names = {
        f"{layout}-{sequence}-{count:02d}.jpg"
        for layout in ("siblings", "assertions")
        for sequence in ("sameparse", "firstopen")
        for count in (1, 4, 16)
    }
    if (not output_dir.is_dir() or output_dir.is_symlink() or
            {item.name for item in output_dir.iterdir()} != expected_names or
            {row.get("file") for row in rows} != expected_names):
        raise ValueError("Generated marker file set differs")
    for row in rows:
        name = row["file"]
        match = NAME.fullmatch(name)
        path = output_dir / name
        if not match or path.is_symlink() or not path.is_file():
            raise ValueError("Generated marker file name/type differs")
        data = path.read_bytes()
        if len(data) != row.get("bytes") or sha(data) != row.get("sha256"):
            raise ValueError("Generated marker fixture digest differs")
        layout, sequence, count_text = match.groups()
        verify_structure(data, source, layout, sequence, int(count_text))
        with Image.open(io.BytesIO(data)) as image:
            image.load()
            if (image.format != "JPEG" or image.size != (2048, 1365) or
                    image.mode != "RGB" or sha(image.tobytes()) != RASTER_SHA):
                raise ValueError("Generated marker raster differs")
    print("Independently verified 12 structural marker carriers and rasters; Paint not run")


if __name__ == "__main__":
    cli = argparse.ArgumentParser(description=__doc__)
    cli.add_argument("--output-dir", type=Path, default=DEFAULT_OUTPUT)
    verify(cli.parse_args().output_dir)