# GHSA-FVPV-4WX7-85F6: Content written after createWriterToContinue on an encrypted PDF is stored unencrypted

- Database: GitHub
- Severity: medium (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

## Description

## Summary

When an encrypted document is written in several sessions with `createWriterToContinue`, everything written after the continue is stored in plaintext, while the file still carries the `/Encrypt` dictionary. The new pages, strings and streams can be read from the file without the password; content the application meant to protect is not encrypted.

## Root Cause

`DocumentContext::ReadState` restores the encryption helper state but never calls `mObjectsContext->SetEncryptionHelper(&mEncryptionHelper)`, so the objects context writes new strings and streams without encryption.

```text
packages/native-with-source/src/deps/PDFWriter/DocumentContext.cpp:1853-1895   ReadState: restores mEncryptionHelper, no SetEncryptionHelper
packages/native-with-source/src/deps/PDFWriter/DocumentContext.cpp:506,525     the other setup paths do call SetEncryptionHelper
packages/native-with-source/src/deps/PDFWriter/EncryptionHelper.cpp:523-579    ReadState: restores only the "StdCF" crypt filter
```

(Line numbers refer to the 7.2.3 source.) Fixing only the missing call exposes a second defect: the saved state keeps only the crypt filter named `StdCF` and restores it for both streams and strings, so a continued modification of a document whose crypt filters have other names ends with a NULL `mXcryptStreams` (the crash described in GHSA-wj5h-wf8p-8vhv), and one with separate stream and string filters would encrypt with the wrong one.

## Impact

Loss of confidentiality for applications that write encrypted PDFs across multiple writer sessions: `createWriter` with `userPassword`/`ownerPassword`, or `createWriterToModify` on an encrypted PDF, then `shutdown(state)` and `createWriterToContinue`. Native only; `@muhammara/wasm` has no `createWriterToContinue`.

## Proof of Concept

Create an encrypted writer, write a page, `shutdown()` to a state file, continue with `createWriterToContinue`, write a second page, `end()`. The second page's content stream is stored unencrypted in the output: its operators appear verbatim in the file bytes.

## Affected Versions

- **Ecosystem:** `npm`
- **Packages:** `@muhammara/native-with-source` and `@muhammara/native` `<= 7.2.3`
- **Patched versions:** `@muhammara/native-with-source` and `@muhammara/native` `7.2.4`
- **Confirmed on:** `7.2.3` and `7.2.2`

`@muhammara/wasm` is not affected.

## Patches

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

`DocumentContext::ReadState` now hands the encryption helper to the objects context, as the other setup paths do. The state keeps the stream and the string crypt filter separately, whatever their names, so continued modifications encrypt with the source document's filters. States written by 7.2.3 or earlier are still read. A state whose AESV2 key is shorter than 88 bits or whose AESV3 key is not 256 bits is now rejected, and `createWriterToContinue()` throws `Unable to continue PDF`, instead of setting up an unusable AES context (see GHSA-7rr8-wph2-845v).

Upgrading does not repair files already written by an affected version: the objects added after the continue stay in plaintext. Regenerate such files from their source content.

## Workarounds

Do not use `createWriterToContinue` for encrypted output; write encrypted documents in a single session, or write unencrypted and encrypt with `recrypt` at the end.

## References

- Related: GHSA-wj5h-wf8p-8vhv (the NULL stream crypt filter a continued modification reached), GHSA-7rr8-wph2-845v (AES key lengths the state now rejects).
- 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-fvpv-4wx7-85f6

Page: https://cve.now/GHSA-FVPV-4WX7-85F6

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