# GHSA-R4MX-QX34-MRX3: NULL pointer dereference in PDFPageInput when the page object is missing

- 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

`PDFPageInput::AssertPageObjectValid` logs when it gets a NULL page object but does not return, then dereferences it. A page index that does not resolve to a page (an out-of-range index, or a `null` entry in `/Kids`) crashes the process.

## Root Cause

```text
packages/native-with-source/src/deps/PDFWriter/PDFPageInput.cpp:39-42
    if(!mPageObject)
        TRACE_LOG(...);                       // no return
    ... mPageObject->QueryDirectObject("Type");   // NULL deref
```

(Line numbers refer to the 7.2.3 source.) `PDFParser::ParsePage` returns NULL for an out-of-range index and for a `null` `/Kids` entry, which the parser accepts as a missing page, and callers pass that straight to `PDFPageInput`.

## Impact

Denial of service.

- Native: `getImageDimensions(pdf, ...)` with a page index outside the document crashes with SIGSEGV, even on a valid one-page PDF. A PDF with a `null` `/Kids` entry reaches the same code, and so does a password-protected PDF measured without its password.
- Wasm: the same NULL read does not trap in linear memory, so the result is undefined: `getImageDimensions` silently returns 595x842 for a missing page. `getPageInfo` / `getPageBox` throw a clean `RangeError` in the released build. The Wasm exports that build `PDFPageInput` from `ParsePage()` (`packages/wasm/src/wasm_api_reader.cpp:584,610`) run the same code.

## Proof of Concept

Any valid one-page PDF, then call native `getImageDimensions` with a page index past the last page:

```javascript
const writer = muhammara.createWriter("out.pdf");
writer.getImageDimensions("one-page.pdf", 5);  // native: SIGSEGV
```

## 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` and `7.2.2`, Wasm `1.2.3` and `1.2.2`

## Patches

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

`PDFPageInput::AssertPageObjectValid` now returns after logging a NULL page object, and `DocumentContext::GetImageDimensions` measures a missing page as 0 by 0 instead of the A4 default. `getImageDimensions()` then throws `Unable to read image dimensions`:

- Native: for a PDF that opens but whose requested page is missing or cannot be read, including a password-protected PDF measured without its password, where it crashed before. Other unreadable images, including a PDF that does not open, still return `{ width: 0, height: 0 }`, as before.
- Wasm: for a missing page, and for a PDF whose page cannot be read without its password, where it returned a made-up 595x842 before. Code that relied on that value must handle the error.

## Workarounds

Validate the page index against the page count and check that the page object exists before asking for page dimensions.

## References

- Related: GHSA-8j62-hp3j-vp33 (same `null` `/Kids` input shape, different defect).
- 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-r4mx-qx34-mrx3

Page: https://cve.now/GHSA-R4MX-QX34-MRX3

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