结构化文件格式漏洞检测 (0‑Click Chains)
Tip
学习和实践 AWS 黑客技术:
HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE)
学习和实践 Azure 黑客技术:
HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。
本页总结了通过验证格式的结构不变量而非依赖字节签名,来检测0‑click移动 exploit 文件的实用技术。该方法可在样本、变形变体以及滥用相同解析器逻辑的未来 exploit 间泛化。
关键思路:对那些只有在达到易受攻击的解码器/解析器状态时才会出现的结构不可能性和字段间不一致性进行编码。
另见:
为什么检查结构而不是签名
当 weaponized 样本不可用且 payload 字节会变异时,传统的 IOC/YARA 模式会失效。结构检测检查容器声明的布局与该格式实现在数学或语义上可能的情况之间的差异。
典型检查:
- 验证源自规范和安全实现的表大小与界限
- 标记嵌入字节码中非法/未记录的 opcode 或状态转换
- 交叉核对元数据 VS 实际编码流组件
- 检测指示解析器混乱或整型溢出设置的矛盾字段
下面是针对多个高影响链条的具体、实战验证的模式。
PDF/JBIG2 – FORCEDENTRY (CVE‑2021‑30860)
Target: JBIG2 symbol dictionaries embedded inside PDFs (often used in mobile MMS parsing).
结构性信号:
- 矛盾的字典状态:在正常内容中不会发生,但触发算术解码溢出所必需。
- 在细化编码期间,结合异常符号计数的全局段可疑使用。
伪逻辑:
# Detecting impossible dictionary state used by FORCEDENTRY
if input_symbols_count == 0 and (ex_syms > 0 and ex_syms < 4):
mark_malicious("JBIG2 impossible symbol dictionary state")
实用分诊:
- 识别并从PDF中提取JBIG2流
- 使用 pdfid/pdf-parser/peepdf 定位并转储流
- 根据JBIG2规范验证算术编码标志和符号字典参数
Notes:
- 即使没有嵌入的payload签名也能工作
- 实际中误报率低,因为被标记的状态在数学上不一致
WebP/VP8L – BLASTPASS (CVE‑2023‑4863)
目标:WebP lossless (VP8L) 的 Huffman 前缀编码表。
结构信号:
- 构建的 Huffman 表的总大小超过参考/已修补实现所期望的安全上限,暗示存在溢出触发的先决条件。
伪逻辑:
# Detect malformed Huffman table construction triggering overflow
let total_size = sum(table_sizes)
if total_size > 2954: # example bound: FIXED_TABLE_SIZE + MAX_TABLE_SIZE
mark_malicious("VP8L oversized Huffman tables")
实用初筛:
- 检查 WebP 容器块:VP8X + VP8L
- 解析 VP8L 前缀码并计算实际分配的表大小
注:
- 针对 payload 的字节级多态性具有鲁棒性
- 上限来自 upstream 的限制/patch 分析
TrueType – TRIANGULATION (CVE‑2023‑41990)
目标:fpgm/prep/glyf 程序内的 TrueType bytecode。
结构性信号:
- 在 exploit chain 使用的 Apple 的 interpreter 中存在未记录/禁止的 opcodes。
伪逻辑:
# Flag undocumented TrueType opcodes leveraged by TRIANGULATION
switch opcode:
case 0x8F, 0x90:
mark_malicious("Undocumented TrueType bytecode")
default:
continue
Practical triage:
- 转储字体表(例如使用 fontTools/ttx)并扫描 fpgm/prep/glyf 程序
- 无需完全模拟解释器即可通过存在性检查获取有价值信息
Notes:
- 如果非标准字体包含未知操作码,可能会产生罕见误报(FPs);请使用次级工具进行验证
DNG/TIFF – CVE‑2025‑43300
Target: DNG/TIFF image metadata VS actual component count in encoded stream (e.g., JPEG‑Lossless SOF3).
Structural signals:
- EXIF/IFD 字段(SamplesPerPixel, PhotometricInterpretation)与流水线使用的图像流头中解析出的分量计数之间存在不一致。
Pseudo‑logic:
# Metadata claims 2 samples per pixel but stream header exposes only 1 component
if samples_per_pixel == 2 and sof3_components == 1:
mark_malicious("DNG/TIFF metadata vs. stream mismatch")
实用初筛:
- 解析主 IFD 和 EXIF 标签
- 定位并解析嵌入的 JPEG‑Lossless header (SOF3) 并比较分量计数
注意:
- 已在野外被报告遭利用;非常适合做结构一致性检查
DNG/TIFF – Samsung libimagecodec.quram.so (CVE‑2025‑21042) + Appended ZIP payload (LANDFALL)
Target: DNG (TIFF‑derived) images carrying an embedded ZIP archive appended at EOF to stage native payloads after parser RCE.
结构指示:
- File magic indicates TIFF/DNG (
II*\x00orMM\x00*) but filename mimics JPEG (e.g.,.jpg/.jpegWhatsApp naming). - Presence of a ZIP Local File Header or EOCD magic near EOF (
PK\x03\x04orPK\x05\x06) that is not referenced by any TIFF IFD data region (strips/tiles/JPEGInterchangeFormat). - Unusually large trailing data beyond the last referenced IFD data block (hundreds of KB to MB), consistent with a bundled archive of .so modules.
伪逻辑:
# Detect appended ZIP payload hidden after DNG/TIFF data (Samsung chain)
if is_tiff_dng(magic):
ext = file_extension()
if ext in {".jpg", ".jpeg"}: mark_suspicious("Extension/magic mismatch: DNG vs JPEG")
zip_off = rfind_any(["PK\x05\x06", "PK\x03\x04"], search_window_last_n_bytes=8*1024*1024)
if zip_off >= 0:
end_dng = approx_end_of_tiff_data() # max(end of Strip/Tile/JPEGInterchangeFormat regions)
if zip_off > end_dng + 0x200:
mark_malicious("DNG with appended ZIP payload (LANDFALL‑style)")
Practical triage:
- Identify format vs name:
- file sample; exiftool -s -FileType -MIMEType sample
- Locate ZIP footer/header near EOF and carve:
- off=$(grep -aboa -E $‘PK\x05\x06|PK\x03\x04’ sample.dng | tail -n1 | cut -d: -f1)
- dd if=sample.dng of=payload.zip bs=1 skip=“$off”
- zipdetails -v payload.zip; unzip -l payload.zip
- Sanity‑check TIFF data regions don’t overlap the carved ZIP region:
- tiffdump -D sample.dng | egrep ‘StripOffsets|TileOffsets|JPEGInterchangeFormat|StripByteCounts|TileByteCounts|JPEGInterchangeFormatLength’
- Verify
max(offset+length) << zip_off - One‑shot carving (coarse): binwalk -eM sample.dng
Notes:
- Exploited in the wild against Samsung’s libimagecodec.quram.so (CVE‑2025‑21042). The appended ZIP contained native modules (e.g., loader + SELinux policy editor) extracted/executed post‑RCE.
Implementation patterns and performance
A practical scanner should:
- Auto‑detect file type and dispatch only relevant analyzers (PDF/JBIG2, WebP/VP8L, TTF, DNG/TIFF)
- Stream/partial‑parse to minimize allocations and enable early termination
- Run analyses in parallel (thread‑pool) for bulk triage
Example workflow with ElegantBouncer (open‑source Rust implementation of these checks):
# Scan a path recursively with structural detectors
$ elegant-bouncer --scan /path/to/directory
# Optional TUI for parallel scanning and real‑time alerts
$ elegant-bouncer --tui --scan /path/to/samples
DFIR 提示与边缘情况
- 嵌入对象:PDFs 可能嵌入图像 (JBIG2) 和 字体 (TrueType);提取并递归扫描
- 解压安全性:使用在分配前对表/缓冲区进行严格限制的库
- 误报:保持规则保守,优先识别在规范下不可能存在的矛盾
- 版本漂移:当上游解析器更改限制时,重新设定基线边界(例如 VP8L 表大小)
相关工具
- ElegantBouncer – 用于上述检测的结构扫描器
- pdfid/pdf-parser/peepdf – PDF 对象提取和静态分析
- pdfcpu – PDF linter/清理工具
- fontTools/ttx – 转储 TrueType 表和字节码
- exiftool – 读取 TIFF/DNG/EXIF 元数据
- dwebp/webpmux – 解析 WebP 元数据和块
参考资料
- ELEGANTBOUNCER: When You Can’t Get the Samples but Still Need to Catch the Threat
- ElegantBouncer project (GitHub)
- Researching FORCEDENTRY: Detecting the exploit with no samples
- Researching BLASTPASS – Detecting the exploit inside a WebP file (Part 1)
- Researching BLASTPASS – Analysing the Apple & Google WebP PoC file (Part 2)
- Researching TRIANGULATION – Detecting CVE‑2023‑41990 with single‑byte signatures
- CVE‑2025‑43300: Critical vulnerability found in Apple’s DNG image processing
- LANDFALL: New Commercial-Grade Android Spyware in Exploit Chain Targeting Samsung Devices
Tip
学习和实践 AWS 黑客技术:
HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE)
学习和实践 Azure 黑客技术:
HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。
HackTricks

