# Detecting CVE-2025-43300: A Deep Dive into Apple's DNG Processing Vulnerability

URL: https://www.msuiche.com/posts/detecting-cve-2025-43300-a-deep-dive-into-apples-dng-processing-vulnerability/
Date: 2025-08-23
Author: Matt Suiche
Tags: CVE-2025-43300, DNG, JPEG, iOS, 0-click, RCE, Detection


> Technical analysis and detection methodology for CVE-2025-43300, a critical 0-click RCE vulnerability in Apple's DNG image processing

---


## The Discovery

CVE-2025-43300 represents one of those subtle yet devastating vulnerabilities that security researchers dream (or have nightmares) about. According to [Apple's official advisory](https://www.cve.org/CVERecord?id=CVE-2025-43300), this out-of-bounds write issue was discovered in their implementation of JPEG Lossless Decompression code within the RawCamera.bundle, which processes Adobe's DNG (Digital Negative) files.

What elevates this from a typical vulnerability to a critical threat is Apple's chilling acknowledgment: **"Apple is aware of a report that this issue may have been exploited in an extremely sophisticated attack against specific targeted individuals."** This isn't theoretical - it's been weaponized.

The vulnerability affects a wide range of Apple devices and was patched across:
- iOS 18.6.2 and iPadOS 18.6.2
- macOS Sequoia 15.6.1
- macOS Sonoma 14.7.8
- macOS Ventura 13.7.8
- iPadOS 17.7.10

As a 0-click remote code execution vector, this represents the holy grail of mobile exploitation - no user interaction required, just silent compromise through a malicious image file.

## The Vulnerability Mechanics

The beauty (or horror) of this vulnerability lies in its simplicity. It exploits a fundamental assumption mismatch between two cooperating components:

1. **The Setup**: A DNG file declares it has 2 samples per pixel in its SubIFD metadata (SamplesPerPixel = 2)
2. **The Twist**: The actual JPEG Lossless data within that same file only contains 1 component in its SOF3 marker
3. **The Exploit**: This mismatch causes the decompression routine to write beyond allocated buffer boundaries

Think of it as telling someone you're sending them two packages, but only including one - except in this case, the recipient still tries to unpack both, reading into memory that doesn't belong to them.

## DNG File Format Internals

### TIFF Structure
DNG files are based on the TIFF (Tagged Image File Format) specification. The structure consists of:

```
Header (8 bytes):
- Byte Order: 0x4949 (Little Endian) or 0x4D4D (Big Endian)
- Magic Number: 0x002A
- IFD Offset: 32-bit offset to first Image File Directory

IFD (Image File Directory):
- Entry Count: 16-bit count of directory entries
- Directory Entries: 12 bytes each
  - Tag: 16-bit identifier
  - Type: 16-bit field type
  - Count: 32-bit number of values
  - Value/Offset: 32-bit value or file offset
- Next IFD Offset: 32-bit offset to next IFD (0 if last)
```

### SubIFD Structure
DNG files use SubIFDs (tag 0x014A) to store additional image data. The vulnerable code path involves:
- SubIFD containing JPEG Lossless compressed data (Compression tag = 7)
- SamplesPerPixel tag (0x0115) defining color components
- JPEG data referenced by StripOffsets (0x0111) or JPEGInterchangeFormat (0x0201)

### JPEG Lossless Format
JPEG Lossless uses the Start of Frame 3 (SOF3) marker (0xFFC3) which contains:
```
SOF3 Structure:
- Marker: 0xFFC3
- Length: 16-bit segment length
- Precision: 8-bit sample precision
- Height: 16-bit image height
- Width: 16-bit image width
- Component Count: 8-bit number of components
- Component specifications follow...
```

## Building a Detection Engine

To protect against this vulnerability, I developed [ELEGANT BOUNCER](https://github.com/msuiche/elegant-bouncer), a Rust-based detection tool. This work builds upon the excellent reproduction steps and analysis provided by [b1n4r1b01](https://github.com/b1n4r1b01), who first documented the technical details of triggering this bug. Here's how the detection works:

### The Detection Algorithm

1. **Parse the TIFF/DNG Structure**
   - Read and validate TIFF headers (checking for those magic numbers)
   - Walk through the IFD chains like a detective following clues
   - Identify and process SubIFDs where the vulnerability lurks

2. **Hunt for JPEG Lossless Compression**
   - Look for Compression tag with value 7 (the JPEG Lossless indicator)
   - Locate JPEG data offset from StripOffsets or JPEGInterchangeFormat

3. **Detect the Smoking Gun**
   - Check if SamplesPerPixel = 2 (first red flag)
   - Parse JPEG data to find the SOF3 marker
   - Verify if SOF3 component count = 1 (second red flag)

4. **Confirm the Exploit**
   - When both conditions align (SamplesPerPixel=2 AND SOF3 components=1)
   - Flag the file as a CVE-2025-43300 exploit attempt

## Implementation Details

The detection is implemented in Rust with the following key components:

### TIFF Reader
```rust
struct TIFFReader {
    file: File,
    is_little_endian: bool,
}
```
Handles endianness-aware reading of TIFF structures.

### IFD Entry Processing
```rust
struct IFDEntry {
    tag: u16,
    field_type: u16,
    count: u32,
    value_offset: u32,
}
```
Represents individual directory entries with proper type handling for inline values vs. file offsets.

### JPEG Parser
The JPEG parser scans for SOF3 markers and extracts component counts while properly handling segment lengths and skipping non-relevant markers.

## Why This Matters: The Attack Surface

This vulnerability should keep security teams up at night for several reasons:

1. **Zero-Click Exploitation**: DNG files can be processed automatically by iOS when received via iMessage or other messaging platforms. Your phone doesn't ask permission - it just renders the preview.

2. **Silent and Deadly**: The vulnerability triggers during image preview generation. No user interaction required. No warning signs. Just silent code execution.

3. **Widespread Attack Vector**: DNG is Adobe's open-source raw image format, commonly used by professional photographers. It's not some obscure format - it's everywhere.

4. **High-Value Target**: RawCamera.bundle processes various raw image formats, making it a prime target for attackers looking for a reliable entry point. Notably, [security researcher u0pattern_cs discovered](https://x.com/u0pattern_cs/status/1958788697165299868) that Apple's BlastDoor allows file-map-executable permissions specifically for RawCamera.bundle, potentially providing attackers with additional exploitation primitives once they achieve initial code execution.

## Defending Against CVE-2025-43300

The immediate mitigation is straightforward:
- **Update to iOS 18.6.2 or later** - Apple has patched this vulnerability
- **Implement file validation** before processing DNG files in your own applications
- **Use [ELEGANT BOUNCER](https://github.com/msuiche/elegant-bouncer)** - Our open-source tool specifically designed to detect this vulnerability
- **Disable automatic image preview** for untrusted sources when possible

## Testing the Detection

Want to validate the detection yourself? Here's how:

```bash
# Clone ELEGANT BOUNCER
git clone https://github.com/msuiche/elegant-bouncer
cd elegant-bouncer

# Build the tool
cargo build --release

# Test with a suspicious DNG file
./target/release/elegant-bouncer --scan suspicious.dng
```

For research purposes, you can create a proof-of-concept following [b1n4r1b01's reproduction steps](https://github.com/b1n4r1b01/n-days/blob/main/CVE-2025-43300.md) by modifying specific bytes in a legitimate DNG file:
- Offset 0x2FD00: Change 0x01 to 0x02 (modifies SamplesPerPixel)
- Offset 0x3E40B: Change 0x02 to 0x01 (modifies SOF3 component count)

## Key Takeaways

CVE-2025-43300 is a masterclass in how subtle inconsistencies can lead to critical vulnerabilities. It demonstrates several important lessons:

1. **Complexity is the Enemy of Security**: When multiple file format standards interact (TIFF + JPEG), assumptions can become attack vectors.

2. **Trust but Verify**: Never trust metadata to accurately describe data. Always validate consistency between declarations and actual content.

3. **Defense in Depth**: While patching is essential, having detection tools like [ELEGANT BOUNCER](https://github.com/msuiche/elegant-bouncer) provides an additional layer of security.

4. **0-Click is Real**: The automatic processing of image files in modern messaging apps creates a massive attack surface that we're only beginning to understand.

This vulnerability reminds us that even in 2025, file format parsing remains a rich hunting ground for security researchers and attackers alike. Stay vigilant, keep your systems updated, and always validate your inputs.

## Resources & References

- **[ELEGANT BOUNCER](https://github.com/msuiche/elegant-bouncer)** - Detection tool for CVE-2025-43300
- [ELEGANT BOUNCER Detection Algorithm Implementation](https://github.com/msuiche/elegant-bouncer/commit/949a34e5ace5ccac797c02bdd2cd4f36c5e07528) - Core detection algorithm commit
- [CVE-2025-43300 Official CVE Record](https://www.cve.org/CVERecord?id=CVE-2025-43300)
- [b1n4r1b01's Technical Analysis and Reproduction Steps](https://github.com/b1n4r1b01/n-days/blob/main/CVE-2025-43300.md) - Original bug reproduction and analysis
- [r00tkitsmm's iOS ImageIO Fuzzing Research](https://r00tkitsmm.github.io/fuzzing/2024/03/29/iOSImageIO.html) - Comprehensive fuzzing research on iOS ImageIO vulnerabilities
- [Apple Security Updates](https://support.apple.com/en-us/100100)
- [TIFF 6.0 Specification](https://www.adobe.io/content/dam/udp/en/open/standards/tiff/TIFF6.pdf)
- [DNG Specification](https://www.adobe.com/content/dam/acom/en/products/photoshop/pdfs/dng_spec_1.4.0.0.pdf)
- [JPEG Lossless Specification (ITU-T T.81)](https://www.w3.org/Graphics/JPEG/itu-t81.pdf)

---

*Have questions or found something interesting about this vulnerability? Reach out on [Twitter](https://twitter.com/msuiche) or check out the [ELEGANT BOUNCER](https://github.com/msuiche/elegant-bouncer) repository for the latest updates.*
