구조적 파일 형식 익스플로잇 탐지 (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 지원하기

이 페이지는 바이트 시그니처에 의존하는 대신 형식의 구조적 불변성(structural invariants)을 검증하여 0‑click 모바일 익스플로잇 파일을 탐지하는 실무 기법을 요약한다. 이 접근법은 샘플, 폴리모픽 변형, 동일한 파서 로직을 악용하는 향후 익스플로잇 전반에 걸쳐 일반화된다.

핵심 아이디어: 취약한 decoder/parser 상태에 도달했을 때만 나타나는 구조적 불가능성과 필드 간 불일치를 표현(encode)한다.

See also:

PDF File analysis

Why structure, not signatures

무기화된 샘플이 없거나 페이로드 바이트가 변이할 때 기존의 IOC/YARA 패턴은 실패한다. 구조적 탐지는 컨테이너가 선언한 레이아웃과 포맷 구현에서 수학적·의미적으로 가능한 범위 사이를 비교 검사한다.

Typical checks:

  • 스펙과 안전한 구현에서 유도된 테이블 크기 및 경계 검증
  • 임베디드 bytecode 내의 불법/미문서화된 opcode 또는 상태 전환 표시
  • 메타데이터와 실제 인코딩된 스트림 구성요소의 대조 검증
  • 파서 혼란 또는 정수 오버플로우 설정을 가리키는 모순되는 필드 탐지

아래에는 여러 고영향 체인에 대해 현장에서 검증된 구체적 패턴들이 나열되어 있다.


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

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

Structural signals:

  • 정상적인 콘텐츠에서는 발생할 수 없지만 산술 디코딩에서 오버플로우를 트리거하기 위해 필요한 모순된 딕셔너리 상태
  • refinement coding 동안 비정상적인 심볼 수와 결합된 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")

실무 트리아지:

  • PDF에서 JBIG2 스트림 식별 및 추출
  • 스트림을 찾고 덤프하기 위해 pdfid/pdf-parser/peepdf 사용
  • 산술 코딩 플래그와 심볼 사전 매개변수를 JBIG2 사양과 대조하여 검증

참고:

  • 임베디드 payload 서명 없이 동작
  • 표시된 상태가 수학적으로 일관성이 없기 때문에 실무에서 오탐률이 낮음

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

대상: WebP 무손실 (VP8L) Huffman prefix‑code 테이블.

구조적 신호:

  • 구성된 Huffman 테이블의 총 크기가 참조(reference) 또는 패치된 구현에서 예상되는 안전 상한을 초과하여 오버플로우 전제 조건을 나타냄.

의사‑로직:

# 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 prefix codes를 파싱하여 실제 할당된 테이블 크기 계산

참고:

  • payload의 byte‑level polymorphism에 대해 견고함
  • 경계는 업스트림 제한/패치 분석에서 도출됨

TrueType – TRIANGULATION (CVE‑2023‑41990)

대상: fpgm/prep/glyf 프로그램 내부의 TrueType bytecode.

구조적 신호:

  • 익스플로잇 체인에서 사용되는 Apple의 interpreter에 문서화되지 않았거나 금지된 opcodes의 존재.

의사 로직:

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

실무 트리아지:

  • 폰트 테이블을 덤프(예: fontTools/ttx 사용)하고 fpgm/prep/glyf 프로그램을 스캔
  • 존재 확인(presence checks)으로부터 가치를 얻기 위해 인터프리터를 완전히 에뮬레이트할 필요 없음

참고:

  • 비표준 폰트에 알 수 없는 opcode가 포함된 경우 드물게 오탐(FP)을 유발할 수 있음; 보조 도구로 검증

DNG/TIFF – CVE‑2025‑43300

대상: DNG/TIFF 이미지 메타데이터와 인코딩된 스트림의 실제 컴포넌트 수(component count) 간의 불일치(예: JPEG‑Lossless SOF3).

구조적 신호:

  • EXIF/IFD 필드(SamplesPerPixel, PhotometricInterpretation)와 파이프라인에서 사용하는 이미지 스트림 헤더에서 파싱된 컴포넌트 수(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")

실전 트리아지:

  • 주요 IFD 및 EXIF 태그 파싱
  • 임베디드 JPEG‑Lossless 헤더(SOF3)를 찾고 파싱한 후 컴포넌트 수 비교

Notes:

  • 현장에서 악용 사례 보고됨; 구조적 일관성 검증에 매우 적합

DNG/TIFF – Samsung libimagecodec.quram.so (CVE‑2025‑21042) + 추가된 ZIP 페이로드 (LANDFALL)

Target: DNG (TIFF‑derived) 이미지는 EOF에 추가된 임베디드 ZIP 아카이브를 포함하여 parser RCE 이후 네이티브 페이로드를 스테이징함.

구조적 신호:

  • 파일 매직은 TIFF/DNG (II*\x00 또는 MM\x00*)를 가리키지만 파일명은 JPEG처럼 위장됨(예: .jpg/.jpeg — WhatsApp 명명).
  • EOF 근처에 ZIP Local File Header 또는 EOCD 매직(PK\x03\x04 또는 PK\x05\x06)이 존재하지만 이는 어떤 TIFF IFD 데이터 영역(스트립/타일/JPEGInterchangeFormat)에도 참조되지 않음.
  • 마지막으로 참조된 IFD 데이터 블록 이후에 비정상적으로 큰 후행 데이터(수백 KB ~ MB)가 존재 — .so 모듈 번들 아카이브와 일치.

의사 로직:

# 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:

  • Samsung의 libimagecodec.quram.so (CVE‑2025‑21042)를 대상으로 실제 공격에서 악용됨. 첨부된 ZIP에는 네이티브 모듈(예: loader + SELinux policy editor)이 포함되어 RCE 후 추출/실행됨.

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

Target: HEIF/AVIF containers parsed by libheif (and ImageIO/OpenImageIO builds that bundle it).

Structural signals:

  • 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).
  • Grid items referencing non‑existent item IDs (ImageItem_Grid::get_decoder NULL deref, CVE‑2025‑43967) – 구조적 검사로 쉽게 확인 가능, 디코딩 불필요.
  • 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.
  • Box length/extent sizes that point past EOF (typical in CVE‑2025‑65586 PoCs discovered via fuzzing).

Pseudo‑logic:

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

실전 트리아지:

  • 전체 디코딩 없이 빠른 메타데이터 검증:
  • heif-info sample.heic
  • oiiotool –info –stats sample.heic
  • 파일 크기와 extent 검증:
  • heif-convert –verbose sample.heic /dev/null | grep -i extent
  • 수동 검사를 위해 의심스러운 box를 카빙:
  • dd if=sample.heic bs=1 skip=$((box_off)) count=$((box_len)) of=box.bin

참고:

  • 이러한 검사들은 무거운 디코딩 전에 잘못된 구조를 포착한다; 허용/차단 결정만 필요한 mail/MMS 게이트웨이에 유용하다.
  • libheif의 제한은 버전마다 변경되므로 업스트림이 변경될 때 상수 값을 재기준화해야 한다 (1.18.x → 1.21.x에서 overlay와 grid 검증이 강화됨).

구현 패턴 및 성능

실용적인 스캐너는 다음을 수행해야 한다:

  • 파일 유형을 자동 감지하고 관련된 분석기만 디스패치 (PDF/JBIG2, WebP/VP8L, TTF, DNG/TIFF, HEIF/AVIF)
  • 스트리밍/부분 파싱으로 할당을 최소화하고 조기 종료를 가능하게 함
  • 대량 트리아지를 위해 분석을 병렬로 실행(thread‑pool)

ElegantBouncer (이 검사들의 오픈소스 Rust 구현)을 이용한 예시 워크플로:

# 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 린터/정리 도구
  • fontTools/ttx – TrueType 테이블 및 바이트코드 덤프
  • exiftool – TIFF/DNG/EXIF 메타데이터 읽기
  • dwebp/webpmux – WebP 메타데이터 및 청크 파싱
  • heif-info/heif-convert (libheif) – HEIF/AVIF 구조 검사
  • oiiotool – OpenImageIO를 통해 HEIF/AVIF 검증

참고자료

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 지원하기