mozilla/pdf.js · error · FormatError
Invalid crypt filter name.
Error message
Invalid crypt filter name.
What it means
FormatError thrown inside the per-object cipher resolver (used for V=4/V=5 documents) when the crypt filter name passed in is not a PDF Name object. The StmF/StrF entries in the Encrypt dict must reference crypt filters by Name; if they resolve to something else (string, number, null), the resolver cannot look up the filter.
Source
Thrown at src/core/crypto.js:1287
password
);
this.encryptionKey = transform.encryptionKey;
}
/**
* @param {number} num
* Object number.
* @param {number} gen
* Generation number.
* @returns {CipherTransform}
* Cipher transform.
*/
createCipherTransform(num, gen) {
if (this.algorithm === 4 || this.algorithm === 5) {
/** @type {ResolveCipher} */
const resolveCipher = filterName => {
if (!(filterName instanceof Name)) {
throw new FormatError("Invalid crypt filter name.");
}
const cryptFilter = this.cf.get(filterName.name);
const cfm = cryptFilter?.get("CFM");
if (!cfm || cfm.name === "None") {
return NullCipher;
}
if (!this.encryptionKey) {
throw new PasswordException(
"No password given",
PasswordResponses.NEED_PASSWORD
);
}
if (this.algorithm === 5 || cfm.name === "AESV3") {
// V=5 always uses 256-bit AES with the file encryption key, even
// when a producer wrongly sets the crypt filter's CFM to AESV2
// (bug 2046659).
return AES256Cipher.bind(null, this.encryptionKey);View on GitHub (pinned to 5903d58d58)
Solutions
- Re-save the PDF with a conformant producer so StmF/StrF are Names.
- If you must handle such files, pre-process the Encrypt dict to coerce string-valued StmF/StrF to Names (advanced, requires xref access).
- Surface a 'corrupt crypt filter configuration' message to the user.
Defensive patterns
Strategy: try-catch
Try / catch
try {
const doc = await getDocument({ url }).promise;
} catch (e) {
if (e.name === 'FormatError' && e.message === 'Invalid crypt filter name.') {
notifyUser('The PDF has a corrupt crypt filter configuration and cannot be opened.');
return;
}
throw e;
} Prevention
- Repair Encrypt dict with qpdf before serving.
- Validate that StmF/StrF are PDF Names if you do low-level dict inspection.
- Reject malformed encryption configs at ingestion.
When it happens
Trigger: A V=4/V=5 Encrypt dict whose StmF or StrF entry is a string literal or other non-Name type; an indirect reference that resolved to a non-Name; a malformed CF lookup triggered when decrypting a stream or string object.
Common situations: Buggy producers that emit StmF as a string instead of a name; corrupt Encrypt dict; rarely hit because most producers emit Names correctly.
Related errors
- Unknown crypto method
- unknown encryption method
- unsupported encryption algorithm
- invalid key length
- No password given
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/b7d4c03448b23c26.
Report an issue: GitHub.