# GHSA-RW6G-24H2-52CH: Incomplete fix for GHSA-5pp7-hx79-5mm2: heap out-of-bounds read and endless stream from TIFF predictor rows that do not end on a byte

- Database: GitHub
- Severity: high (stated by ghsa, no CVSS score)
- Published: 2026-11-18
- Modified: 2026-11-18

## Affected versions

- @muhammara/native-with-source (npm): through 7.2.3
- @muhammara/native (npm): through 7.2.3
- @muhammara/wasm (npm): through 1.2.3

## Description

## Summary

A FlateDecode or LZWDecode stream with a TIFF predictor (`/Predictor 2`) and 1, 2 or 4 bits per component returns bytes read from outside its heap buffer whenever `/Colors` × `/Columns` is not a multiple of 8 / `/BitsPerComponent`, that is, whenever a row does not end on a byte. When the row is shorter than one byte (for example `/Columns 1 /Colors 1 /BitsPerComponent 4`), the stream also never ends, and behind a filter that skips the bytes it produces, such as `ASCII85Decode`, the endless loop can run inside a single read, so text extraction never returns. Any application that decodes streams of untrusted PDFs, for example with `startReadingFromStream()` or text extraction, can be made to receive heap memory in the decoded data and to hang. This is an incomplete fix of GHSA-5pp7-hx79-5mm2, which fixed the endless read only for rows whose size overflows.

## Root Cause

In `InputPredictorTIFFSubStream`:

- `Assign()` sizes the row buffer with a rounded-up byte count, but `Read()` asks the source for `(Columns * Colors * BitsPerComponent) / 8` bytes, rounded down. A row that does not end on a byte is read short, and a row of fewer than 8 bits reads 0 bytes, which "succeeds" without consuming the source, so the stream never ends.
- `Assign()` sizes the colour array to `Columns * Colors` entries, but for components of fewer than 8 bits `ReadByteFromColorsArray()` takes `8 / BitsPerComponent` entries for every output byte without checking how many are left. When `Columns * Colors` is not a multiple of `8 / BitsPerComponent`, the last output byte of each row reads past the end of the colour array; for a row under one byte, every output byte does.

`InputAscii85DecodeStream::ReadNextBuffer()` reads its source until it has five digits or the source ends, skipping any other byte. Behind such an endless predictor stream whose bytes are not ASCII85 digits, one read never returns.

```text
packages/native-with-source/src/deps/PDFWriter/InputPredictorTIFFSubStream.cpp:72         Read: asks the source for the rounded-down row size
packages/native-with-source/src/deps/PDFWriter/InputPredictorTIFFSubStream.cpp:143-152    Assign: rounded-up row buffer, colour array of Columns * Colors entries
packages/native-with-source/src/deps/PDFWriter/InputPredictorTIFFSubStream.cpp:176-184    ReadByteFromColorsArray: 8 / BitsPerComponent entries per byte, unbounded
packages/native-with-source/src/deps/PDFWriter/InputAscii85DecodeStream.cpp:91-117        ReadNextBuffer: reads until five digits or the end of the source
```

(Line numbers refer to the 7.2.3 source.)

## Impact

- Native: the returned bytes include heap memory read out of bounds. Valgrind on 7.2.3 reports invalid reads in `ReadByteFromColorsArray` for every output byte of a row under one byte, and for the last byte of every row with `/Columns 3 /Colors 1 /BitsPerComponent 4`. With a row under one byte, reading never finishes; with `/Filter [/FlateDecode /ASCII85Decode]`, a single `read()` of the stream and `extractPageText()` of its page never returned (stopped after 150 seconds). Confirmed on 7.2.3.
- Wasm: the same code reads past the array in linear memory (AddressSanitizer reports a heap-buffer-overflow in `ReadByteFromColorsArray`), and with a row under one byte the stream never ends; with `/Filter [/FlateDecode /ASCII85Decode]`, `extractPageText()` never returned (stopped after 150 seconds). Confirmed on 1.2.3.

## Proof of Concept

A stream `<< /Filter /FlateDecode /DecodeParms << /Predictor 2 /Colors 1 /BitsPerComponent 4 /Columns 1 >> >>` whose data inflates to two bytes, read with `createReader(path)` → `startReadingFromStream(parseNewObject(id))` in a `while (stream.notEnded())` loop, never ends. With `/Columns 3` the stream ends, but the last byte of every row is read past the colour array. For the hang inside one read, a page whose content stream is `<< /Filter [/FlateDecode /ASCII85Decode] /DecodeParms [<< /Predictor 2 /Colors 1 /BitsPerComponent 1 /Columns 2 >> null] >>` with data that inflates to a single zero byte: `extractPageText(0)` does not return.

## Affected Versions

- **Ecosystem:** `npm`
- **Packages:** `@muhammara/native-with-source` and `@muhammara/native` `<= 7.2.3`; `@muhammara/wasm` `<= 1.2.3`
- **Patched versions:** `@muhammara/native-with-source` and `@muhammara/native` `7.2.4`; `@muhammara/wasm` `1.2.4`
- **Confirmed on:** native `7.2.3`, Wasm `1.2.3`

## Patches

Fixed in `@muhammara/native-with-source` and `@muhammara/native` `7.2.4` and `@muhammara/wasm` `1.2.4`.

The TIFF predictor now reads each row at the rounded-up size that `Assign()` computes and sizes the colour array to the padded row, so the colours of every decoded byte stay inside the array and such streams decode their data and end. Rows that end on a byte decode as before; valid images whose rows do not, which affected versions decoded misaligned, now decode correctly.

## Workarounds

None short of not decoding streams of untrusted PDFs with affected versions.

## References

- Incomplete fix of GHSA-5pp7-hx79-5mm2.
- The same code is in upstream galkahana/PDF-Writer.

---

Found by the project's scheduled WebAssembly fuzzing and the follow-up review of its results.

## References

- https://github.com/julianhille/MuhammaraJS/security/advisories/GHSA-rw6g-24h2-52ch

Page: https://cve.now/GHSA-RW6G-24H2-52CH

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