Skip to content

Commit b944de0

Browse files
authored
Merge branch 'HackTricks-wiki:master' into rustnotes
2 parents 9e0cdcd + 1da9db2 commit b944de0

1 file changed

Lines changed: 50 additions & 2 deletions

File tree

src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/structural-file-format-exploit-detection.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Structural signals:
9090
Pseudo‑logic:
9191

9292
```pseudo
93-
# Flag undocumented TrueType opcodes leveraged by TRIANGULATION
93+
# Flag undocumented TrueType bytecode leveraged by TRIANGULATION
9494
switch opcode:
9595
case 0x8F, 0x90:
9696
mark_malicious("Undocumented TrueType bytecode")
@@ -172,10 +172,54 @@ Notes:
172172

173173
---
174174

175+
## HEIF/AVIF – libheif & libde265 (CVE‑2024‑41311, CVE‑2025‑29482, CVE‑2025‑65586)
176+
177+
Target: HEIF/AVIF containers parsed by libheif (and ImageIO/OpenImageIO builds that bundle it).
178+
179+
Structural signals:
180+
- Overlay items (iloc/iref) whose source rectangles exceed the base image dimensions or whose offsets are negative/overflowing → triggers ImageOverlay::parse out‑of‑bounds (CVE‑2024‑41311).
181+
- Grid items referencing non‑existent item IDs (ImageItem_Grid::get_decoder NULL deref, CVE‑2025‑43967) – easy structural check, no decoding required.
182+
- SAO/loop‑filter parameters or tile counts that force table allocations larger than the max allowed by libde265 (CVE‑2025‑29482): overly large band counts or slice dimensions.
183+
- Box length/extent sizes that point past EOF (typical in CVE‑2025‑65586 PoCs discovered via fuzzing).
184+
185+
Pseudo‑logic:
186+
187+
```pseudo
188+
# HEIF overlay bounds check
189+
for overlay in heif_overlays:
190+
if overlay.x < 0 or overlay.y < 0: mark_malicious("HEIF overlay negative offset")
191+
if overlay.x + overlay.w > base.w or overlay.y + overlay.h > base.h:
192+
mark_malicious("HEIF overlay exceeds base image (CVE‑2024‑41311 pattern)")
193+
194+
# Grid item reference validation
195+
for grid in heif_grids:
196+
if any(ref_id not in item_ids):
197+
mark_malicious("HEIF grid references missing item (CVE‑2025‑43967 pattern)")
198+
199+
# SAO / slice allocation guard
200+
if sao_band_count > 32 or (tile_cols * tile_rows) > MAX_TILES or sao_eo_class not in {0..3}:
201+
mark_malicious("HEIF SAO/tiling exceeds safe bounds (CVE‑2025‑29482 pattern)")
202+
```
203+
204+
Practical triage:
205+
- Quick metadata sanity without full decode:
206+
- heif-info sample.heic
207+
- oiiotool --info --stats sample.heic
208+
- Validate extents versus file size:
209+
- heif-convert --verbose sample.heic /dev/null | grep -i extent
210+
- Carve suspicious boxes for manual inspection:
211+
- dd if=sample.heic bs=1 skip=$((box_off)) count=$((box_len)) of=box.bin
212+
213+
Notes:
214+
- These checks catch malformed structure before heavy decode; useful for mail/MMS gateways that only need allow/deny decisions.
215+
- libheif limits shift across versions; re‑baseline constants when upstream changes (1.18.x → 1.21.x tightened overlay and grid validation).
216+
217+
---
218+
175219
## Implementation patterns and performance
176220

177221
A practical scanner should:
178-
- Auto‑detect file type and dispatch only relevant analyzers (PDF/JBIG2, WebP/VP8L, TTF, DNG/TIFF)
222+
- Auto‑detect file type and dispatch only relevant analyzers (PDF/JBIG2, WebP/VP8L, TTF, DNG/TIFF, HEIF/AVIF)
179223
- Stream/partial‑parse to minimize allocations and enable early termination
180224
- Run analyses in parallel (thread‑pool) for bulk triage
181225

@@ -208,6 +252,8 @@ $ elegant-bouncer --tui --scan /path/to/samples
208252
- fontTools/ttx – dump TrueType tables and bytecode
209253
- exiftool – read TIFF/DNG/EXIF metadata
210254
- dwebp/webpmux – parse WebP metadata and chunks
255+
- heif-info/heif-convert (libheif) – HEIF/AVIF structure inspection
256+
- oiiotool – validate HEIF/AVIF via OpenImageIO
211257

212258
---
213259

@@ -221,5 +267,7 @@ $ elegant-bouncer --tui --scan /path/to/samples
221267
- [Researching TRIANGULATION – Detecting CVE‑2023‑41990 with single‑byte signatures](https://www.msuiche.com/posts/researching-triangulation-detecting-cve-2023-41990-with-single-byte-signatures/)
222268
- [CVE‑2025‑43300: Critical vulnerability found in Apple’s DNG image processing](https://www.msuiche.com/posts/cve-2025-43300-critical-vulnerability-found-in-apples-dng-image-processing/)
223269
- [LANDFALL: New Commercial-Grade Android Spyware in Exploit Chain Targeting Samsung Devices](https://unit42.paloaltonetworks.com/landfall-is-new-commercial-grade-android-spyware/)
270+
- [CVE‑2024‑41311 analysis (libheif overlay OOB)](https://www.wiz.io/vulnerability-database/cve/cve-2024-41311)
271+
- [CVE‑2025‑65586 libheif metadata iterator flaw](https://securityonline.info/cve-2025-65586-libheif-flaw-exposes-image-decoders-to-denial-of-service/)
224272

225273
{{#include ../../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)