
Cloud Vulnerability DB
A community-led vulnerabilities database
Package / ecosystem: pip, pyhanko
Affected versions: all releases up to and including 0.38.1 (reproduced on every PyPI release from 0.1.0 onwards, except the yanked 0.5.0, which does not import); also present on master at 0ff50825 (2026-11-18).
Severity: High. Integrity of the coverage verdict, no confidentiality impact. CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N (7.5)
Summary
EmbeddedPdfSignature.evaluate_signature_coverage() in pkgs/pyhanko/src/pyhanko/sign/validation/pdf_embedded.py classifies a signature as SignatureCoverageLevel.ENTIRE_FILE when
file_size == len1 + len2 + (len(self.pkcs7_content) * 2 + 2) # lines ~465-469where self.pkcs7_content is the decoded value of /Contents (extract_contents(), line ~92, which accepts both ByteStringObject and TextStringObject, i.e. hex and literal strings).
In this branch, two things are not checked:
start2 is not compared against len1 + embedded_sig_content. The contiguity check contiguous = start2 == len1 + embedded_sig_content (line ~479) only runs in the subsequent ENTIRE_REVISION branch.[len1, start2) is not verified to contain exactly one hex string <...> of the expected length. The formula * 2 + 2 assumes hex encoding without whitespace, but a literal string decodes 1:1, and whitespace inside a hex string is skipped during decoding.
The CMS blob is then parsed with asn1crypto, which tolerates trailing bytes after the DER structure. So the decoded length need not equal the DER length.
Consequence
The bytes inside the hole are unsigned. If the decoded length of /Contents is made to differ from what the * 2 + 2 formula assumes, the computed signed_zone_len stops matching the real geometry. The file can then contain bytes outside the signed ranges (e.g. an appended incremental update) while the signature is still reported as ENTIRE_FILE. Because ENTIRE_FILE short-circuits the difference analysis (DiffResult(ModificationLevel.NONE, set()), line ~530), such an update is not reviewed.
This does not require any cooperation from the signer, nor access to the signing key: any signed PDF with a hex /Contents (the normal output of pyHanko and other signers) can be altered this way by anyone who obtains a copy. The altered file is non-conforming (PDF Reference 1.7, Table 8.102 requires a hex string for /Contents when /ByteRange is present), but pyHanko's default strict reader accepts it.
Proof of concept
Starting from a PDF signed by pyHanko with default settings:[len1, start2) with a literal string of the same width, encoding the same CMS bytes (escaping (, ), \ and CR) and padded with NUL bytes. The signed byte ranges and all offsets are unchanged, so the signature remains cryptographically intact. A hole of width 2W + 2 now decodes to roughly 2W bytes instead of W, so the formula expects a file roughly 2W bytes longer than the signed range.len1 + len2 + 2 * len(pkcs7_content) + 2.
pyHanko then reports the altered file as ENTIRE_FILE / ModificationLevel.NONE, with docmdp_ok and bottom_line both true, summary() giving INTACT:TRUSTED,UNTOUCHED, and pyhanko sign validate exiting with 0. The --pretty-print report is identical to that of the untouched file. Meanwhile, pyHanko's own reader and poppler's pdftotext return the replaced page content. The same incremental update appended without rewriting the hole is correctly reported as ILLEGAL_MODIFICATIONS.
Impact
Affected: applications that validate signed PDFs with pyHanko and act on bottom_line, coverage, modification_level, docmdp_ok, summary(), or the exit code of pyhanko sign validate or pyhanko sign adesverify.
Observed conditions:pdfsig 25.03.0 (non-strict reader only for the latter; the strict reader rejects even untouched pdfsig output), and for signatures with Adobe-style revocation data or PAdES B-LT (the later DSS revision is preserved).pdfsig).ILLEGAL_MODIFICATIONS and sign validate fails, but a caller validating only the last signature sees it as untouched.ILLEGAL_MODIFICATIONS.sign validate exits with 0; the document timestamp fails, and the AdES validation result is INDETERMINATE/NO_POE instead of PASSED.validate_pdf_timestamp reports ENTIRE_FILE / ModificationLevel.NONE.
Context
Initially found during a third-party security review (static code audit) of pyHanko 0.38.0 / pyhanko-certvalidator 0.33.0 before adopting it for offline validation of PAdES signatures. Subsequently independently discovered, confirmed and reproduced across releases and signer implementations by Nathan Cross (CyberBadger).
Reporters: Julian Neuber; Nathan Cross (CyberBadger)Source: NVD
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."