# Rebuilding MuPDF's old PDF key generator in Python: nine bits of randomness behind AES-256

Source: [DEV Community: python](https://dev.to/jose_pollman_fa7c6ec43cdd/rebuilding-mupdfs-old-pdf-key-generator-in-python-nine-bits-of-randomness-behind-aes-256-3hm6) · 2026-11-19 · Languages
Page: https://themorning.dev/story/rebuilding-mupdf-s-old-pdf-key-generator-in-python-nine-bits-of-randomness-behin-b2ab9b320eb67499
Kind: security · Impact: medium

## In brief

- MuPDF versions before 1.28.5 wrote AES-256 encrypted PDFs whose 256-bit file key depended on nine bits of randomness.
- The key was cut from one of only 512 possible byte streams, because it came from a 48-bit linear congruential generator seeded with the clock.
- The AES cipher itself was not the problem; the weakness was in key generation.

## Why it matters

PDFs encrypted by affected MuPDF versions may have keys drawn from a space of only 512 possibilities, so their protection is much weaker than AES-256 suggests.

## What to do

- Upgrade MuPDF to version 1.28.5 or later

## Versions

- MuPDF 1.28.5

## Coverage

- [Rebuilding MuPDF's old PDF key generator in Python: nine bits of randomness behind AES-256](https://dev.to/jose_pollman_fa7c6ec43cdd/rebuilding-mupdfs-old-pdf-key-generator-in-python-nine-bits-of-randomness-behind-aes-256-3hm6) — DEV Community: python, 2026-11-19

Tags: pdf, encryption, mupdf, aes-256, prng

---

Brief generated by AI (claude-haiku-5-5) from the reporting listed under Coverage. Headlines belong to their publishers. The Morning Dev – https://themorning.dev
