संरचनात्मक फ़ाइल‑फ़ॉर्मेट एक्सप्लॉइट की पहचान (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 का समर्थन करें

यह पृष्ठ 0‑click mobile exploit files का पता लगाने के लिए उनके फॉर्मैट्स के structural invariants को मान्य करने वाली व्यावहारिक तकनीकों का सार देता है, बजाय कि byte signatures पर निर्भर रहने के। यह तरीका नमूनों, polymorphic variants, और भविष्य के उन्हीं parser logic का दुरुपयोग करने वाले exploits पर सामान्यीकरण करता है।

Key idea: encode structural impossibilities and cross‑field inconsistencies that only appear when a vulnerable decoder/parser state is reached.

See also:

PDF File analysis

क्यों संरचना, न कि signatures

जब weaponized samples उपलब्ध नहीं होते और payload bytes बदलते रहते हैं, तो पारंपरिक IOC/YARA पैटर्न विफल हो जाते हैं। Structural detection कंटेनर की घोषित लेआउट का निरीक्षण करता है बनाम उस बात के जो फॉर्मैट के implementation के लिए गणितीय या सेमांटिक रूप से संभव है।

सामान्य जांच:

  • spec और सुरक्षित implementations से निकले table sizes और bounds को validate करें
  • एमबेडेड bytecode में गैरकानूनी/अदलेखित opcodes या state transitions को flag करें
  • metadata को वास्तविक encoded stream components के साथ cross‑check करें
  • parser confusion या integer overflow set‑ups का संकेत देने वाले विरोधाभासी फ़ील्ड्स का पता लगाएँ

नीचे कई high‑impact chains के लिए ठोस, field‑tested पैटर्न दिए गए हैं।


PDF/JBIG2 – FORCEDENTRY (CVE‑2021‑30860)

Target: JBIG2 symbol dictionaries embedded inside PDFs (often used in mobile MMS parsing).

Structural signals:

  • ऐसा विरोधाभासी dictionary state जो benign content में नहीं हो सकता पर जिसे arithmetic decoding में overflow ट्रिगर करने के लिए आवश्यक होता है।
  • refinement coding के दौरान abnormal symbol counts के साथ global segments का संदिग्ध उपयोग।

Pseudo‑logic:

# 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")

Practical triage:

  • PDF से JBIG2 streams की पहचान करें और निकालें
  • streams locate और dump करने के लिए pdfid/pdf-parser/peepdf का उपयोग करें
  • arithmetic coding flags और symbol dictionary parameters को JBIG2 spec के खिलाफ सत्यापित करें

Notes:

  • embedded payload signatures के बिना काम करता है
  • व्यवहार में FP कम है क्योंकि flagged state गणितीय रूप से असंगत है

WebP/VP8L – BLASTPASS (CVE‑2023‑4863)

Target: WebP lossless (VP8L) Huffman prefix‑code tables.

Structural signals:

  • बनाए गए Huffman तालिकाओं का कुल आकार reference/patched implementations द्वारा अपेक्षित सुरक्षित ऊपरी सीमा से अधिक है, जो overflow precondition का संकेत देता है।

Pseudo‑logic:

# 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")

व्यावहारिक triage:

  • WebP container chunks की जाँच करें: VP8X + VP8L
  • VP8L prefix codes को पार्स करें और actual allocated table sizes की गणना करें

नोट्स:

  • payload के byte‑level polymorphism के प्रति robust
  • Bound upstream limits/patch analysis से व्युत्पन्न है

TrueType – TRIANGULATION (CVE‑2023‑41990)

लक्ष्य: TrueType bytecode जो fpgm/prep/glyf programs के अंदर है।

संरचनात्मक संकेत:

  • exploit chain द्वारा उपयोग किए जाने वाले Apple’s interpreter में undocumented/forbidden opcodes की उपस्थिति।

Pseudo‑logic:

# Flag undocumented TrueType bytecode leveraged by TRIANGULATION
switch opcode:
case 0x8F, 0x90:
mark_malicious("Undocumented TrueType bytecode")
default:
continue

व्यावहारिक ट्रायाज:

  • font tables को dump करें (उदा., fontTools/ttx का उपयोग करके) और fpgm/prep/glyf प्रोग्राम स्कैन करें
  • presence checks से उपयोगी जानकारी प्राप्त करने के लिए interpreter को पूरी तरह emulate करने की आवश्यकता नहीं है

नोट्स:

  • यदि nonstandard fonts अज्ञात opcodes शामिल करते हैं तो दुर्लभ FPs उत्पन्न हो सकते हैं; secondary tooling से सत्यापित करें

DNG/TIFF – CVE‑2025‑43300

लक्ष्य: DNG/TIFF image metadata बनाम एन्कोडेड स्ट्रीम में वास्तविक component count (उदा., JPEG‑Lossless SOF3).

संरचनात्मक संकेत:

  • EXIF/IFD fields (SamplesPerPixel, PhotometricInterpretation) और pipeline द्वारा उपयोग किए गए image stream header से parsed component count के बीच असंगति।

छद्म-तर्क:

# 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")

Practical triage:

  • प्राथमिक IFD और EXIF टैग पार्स करें
  • एम्बेडेड JPEG‑Lossless header (SOF3) ढूंढें और पार्स करें तथा घटक गिनती की तुलना करें

Notes:

  • वाइल्ड में शोषित होने की रिपोर्ट; संरचनात्मक सुसंगतता जाँचों के लिए उत्कृष्ट उम्मीदवार

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.

Structural signals:

  • फ़ाइल मैजिक TIFF/DNG (II*\x00 or MM\x00*) दर्शाती है, पर फ़ाइलनाम JPEG की नकल करता है (उदाहरण: .jpg/.jpeg WhatsApp नामकरण)।
  • EOF के पास ZIP Local File Header या EOCD magic (PK\x03\x04 या PK\x05\x06) का होना जो किसी TIFF IFD डेटा क्षेत्र (strips/tiles/JPEGInterchangeFormat) द्वारा संदर्भित नहीं है।
  • अंतिम संदर्भित IFD डेटा ब्लॉक के परे असामान्य रूप से बड़ा ट्रेलिंग डेटा (सैकड़ों KB से MB तक), जो .so मॉड्यूल्स के बंडल्ड आर्काइव के अनुरूप है।

Pseudo‑logic:

# 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)")

व्यावहारिक प्राथमिक जाँच:

  • Identify format vs name:
  • file sample; exiftool -s -FileType -MIMEType sample
  • EOF के पास ZIP footer/header ढूँढें और 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
  • सैनिटी‑चेक: TIFF डेटा क्षेत्र carved ZIP क्षेत्र से ओवरलैप न करें:
  • tiffdump -D sample.dng | egrep ‘StripOffsets|TileOffsets|JPEGInterchangeFormat|StripByteCounts|TileByteCounts|JPEGInterchangeFormatLength’
  • सत्यापित करें max(offset+length) << zip_off
  • एक ही बार carving (coarse): binwalk -eM sample.dng

Notes:

  • जंगली में Samsung’s libimagecodec.quram.so के खिलाफ exploit किया गया (CVE‑2025‑21042). Append की गई ZIP में native modules (e.g., loader + SELinux policy editor) थे जो post‑RCE के बाद निकालकर/execute किए गए।

HEIF/AVIF – libheif & libde265 (CVE‑2024‑41311, CVE‑2025‑29482, CVE‑2025‑65586)

लक्ष्य: libheif द्वारा parse किए जाने वाले HEIF/AVIF कंटेनर (और वे ImageIO/OpenImageIO बिल्ड जो इसे bundle करते हैं).

संरचनात्मक संकेत:

  • Overlay items (iloc/iref) जिनके source rectangles base image dimensions से अधिक हैं या जिनके offsets negative/overflowing हैं → ImageOverlay::parse को out‑of‑bounds condition trigger करता है (CVE‑2024‑41311).
  • Grid items जो non‑existent item IDs को reference करते हैं (ImageItem_Grid::get_decoder NULL deref, CVE‑2025‑43967) – आसान structural check, कोई decoding आवश्यक नहीं.
  • SAO/loop‑filter parameters या tile counts जो libde265 द्वारा allowed max से बड़े table allocations मजबूर करते हैं (CVE‑2025‑29482): बहुत बड़े band counts या slice dimensions.
  • Box length/extent sizes जो EOF के पार इशारा करते हैं (आम तौर पर CVE‑2025‑65586 PoCs जो fuzzing से मिले).

छद्म‑लॉजिक:

# HEIF overlay bounds check
for overlay in heif_overlays:
if overlay.x < 0 or overlay.y < 0: mark_malicious("HEIF overlay negative offset")
if overlay.x + overlay.w > base.w or overlay.y + overlay.h > base.h:
mark_malicious("HEIF overlay exceeds base image (CVE‑2024‑41311 pattern)")

# Grid item reference validation
for grid in heif_grids:
if any(ref_id not in item_ids):
mark_malicious("HEIF grid references missing item (CVE‑2025‑43967 pattern)")

# SAO / slice allocation guard
if sao_band_count > 32 or (tile_cols * tile_rows) > MAX_TILES or sao_eo_class not in {0..3}:
mark_malicious("HEIF SAO/tiling exceeds safe bounds (CVE‑2025‑29482 pattern)")

व्यावहारिक triage:

  • बिना पूर्ण decode के त्वरित मेटाडेटा सत्यापन:
  • heif-info sample.heic
  • oiiotool –info –stats sample.heic
  • फाइल आकार के सापेक्ष extents सत्यापित करें:
  • heif-convert –verbose sample.heic /dev/null | grep -i extent
  • मैन्युअल निरीक्षण के लिए संदिग्ध boxes carve करें:
  • dd if=sample.heic bs=1 skip=$((box_off)) count=$((box_len)) of=box.bin

नोट:

  • ये जाँचें भारी decode से पहले बिगड़ी हुई संरचना पकड़ती हैं; उन mail/MMS गेटवे के लिए उपयोगी जो केवल allow/deny निर्णय करते हैं।
  • libheif की सीमाएँ संस्करणों के साथ बदलती रहती हैं; upstream में बदलाव होने पर constants को पुनः बेसलाइन करें (1.18.x → 1.21.x ने overlay और grid validation को कड़ा किया)।

कार्यान्वयन पैटर्न और प्रदर्शन

एक व्यावहारिक स्कैनर को चाहिए:

  • फाइल प्रकार को ऑटो‑डिटेक्ट करें और केवल संबंधित analyzers (PDF/JBIG2, WebP/VP8L, TTF, DNG/TIFF, HEIF/AVIF) को भेजें
  • स्ट्रीम/आंशिक‑पार्सिंग करके आवंटन कम करें और जल्दी समापन सक्षम करें
  • बड़े पैमाने पर triage के लिए विश्लेषणों को समानांतर (thread‑pool) में चलाएँ

ElegantBouncer (इन जाँचों का open‑source Rust implementation) के साथ उदाहरण वर्कफ़्लो:

# 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 may embed images (JBIG2) and fonts (TrueType); इन्हें निकालें और पुनरावर्ती रूप से स्कैन करें
  • Decompression safety: ऐसी लाइब्रेरीज़ उपयोग करें जो allocation से पहले tables/buffers पर सख्त सीमाएँ लागू करें
  • False positives: नियमों को कन्ज़रवेटिव रखें, ऐसे विरोधाभासों को प्राथमिकता दें जो spec के तहत असम्भव हों
  • Version drift: जब upstream parsers सीमाएँ बदलें, तो bounds का पुनः बेसलाइन करें (e.g., VP8L table sizes)

  • ElegantBouncer – ऊपर दिए गए detections के लिए संरचनात्मक स्कैनर
  • pdfid/pdf-parser/peepdf – PDF object extraction और स्टैटिक अनालिसिस
  • pdfcpu – PDF लिंटर/सैनिटाइज़र
  • fontTools/ttx – TrueType तालिकाएँ और बाइटकोड डंप करें
  • exiftool – TIFF/DNG/EXIF मेटाडेटा पढ़ें
  • dwebp/webpmux – WebP मेटाडेटा और chunks पार्स करें
  • heif-info/heif-convert (libheif) – HEIF/AVIF संरचना निरीक्षण
  • oiiotool – OpenImageIO के जरिए HEIF/AVIF मान्य करें

References

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 का समर्थन करें