MuPDF and Foxit generate AES-256 PDF keys from timestamps, making them easy to crack
Several PDF implementations advertise AES-256[1] encryption but derive the 32-byte file key from insecure random sources, allowing protected documents to be decrypted without any password. In the current revision 6 of the format, the password does not encrypt the document directly: a random 32-byte file key encrypts the content, and the password plus a salt[2] are hashed — deliberately slowly, a hardening added after earlier RC4-based revisions — to derive a second key that encrypts the file key.
MuPDF versions before 1.28.5 generate randomness with drand48[3], a 48-bit linear congruential generator seeded once with the current epoch in seconds, and each output byte of the key comes from bits 17 to 24 of the generator's state. The bottom 16 state bits are fixed to the constant 0x330e, so only nine bits from the timestamp affect the key, and timestamps 512 seconds apart produce the same byte stream. Because of this, an unoptimized Python brute force over all 512 streams takes about 11 milliseconds, and the plaintext document /ID serves as an additional check. Foxit PDF Reader 2026.1.3.36551 derives the file key as a hash of the current timestamp, 32 uninitialized bytes and a constant, and in practice the uninitialized bytes are zero filled. A Rust implementation using Rayon on a Ryzen 9 7950X with 32 threads sustains 370 to 376 million timestamps per second, enough to cover every timestamp from 1970 to the present.
OpenPDF 3.0.5 and iText 9.7.1 route randomness through an IVGenerator class, an ARC4[4] stream seeded with a millisecond timestamp and the JVM's free memory; the same stream also produces 32 bytes of plaintext salts in /U and /O that can be used to verify guesses. The Foxit pattern appears in PDFium's initial public commit from May 2014, whose file header credits Foxit, and other editors may have picked it up through PDFium. The issues were disclosed to the vendors and fixed in MuPDF's case, decryptors for MuPDF and Foxit are published, but previously released protected copies cannot be retroactively protected.
Read the original v12.shDiscussion on GeekNews
Discussion
Commenters agree the keys were never cryptographically random and that the small keyspace is only part of the story. Several argue that PDF libraries and viewers should not implement their own encryption or random number generators, and one questions whether the PDF format needs built-in encryption at all. Another compares the flaw to a past hardware wallet entropy bug.
Sources
-
KRGeekNews KO
9비트 AES 키 사건 - PDF 암호화를 무력화한 취약한 난수 생성
-
v12.sh
The case of the 9 bit AES key


