Repository navigation
Description
Part of the general PDF reader epic.
Status update, 2026-08-28. The fixture-corpus half is done. What remains is fuzzing and the
round-trip oracle, and the latter turns out to be blocked rather than merely unstarted.
Done — the corpus
Two committed corpora cover every axis this issue asked for:
tests/VellumPdf.Reader.Tests/Fixtures/Encrypted/— 17 encrypted fixtures plus
plaintext-baseline.pdf: one per/V+/Rcombination, plus/EncryptMetadata false, linearized,
object-stream, two-revision, empty-user-password, long-password, nested-strings,
PDFDocEncoding-password and same-password variants. Landed in9ed1229(PR test(reader): commit the encrypted fixture corpus for the decrypt work #195), extended by
bfb64e1(feat(reader): decrypt on read — PdfReader.Open takes a password #212).tests/VellumPdf.Reader.Tests/Fixtures/ThirdParty/— 12 fixtures: classic, xref-stream,
object-stream, both hybrid/XRefStmshapes, linearized, incremental update, non-zero generations,
and three deliberately damaged files. Landed in2f8a13d(PR test(reader): add a third-party PDF fixture corpus #205, issue Reader: no third-party PDF fixture exists anywhere in the tree #196).
Both were generated once with qpdf 12.3.2 and poppler 25.07.0, or hand-built where neither tool
can produce the construct, and committed rather than generated at test time — so the corpus is
byte-identical everywhere and there is no GateOnCi skip hole. Each has a README recording the exact
commands. (mutool, named in the original filing, was not used and is nowhere in the tree.)
Both corpora are SHA-256-pinned with MustContain/MustNotContain token scans, so a regeneration
that silently drops the construct a fixture exists for is caught rather than just re-baselined.
Remaining — lexer fuzzing
Nothing exists today: no harness, no fuzz job, no fuzzing dependency. Target
PdfLexer.NextToken + PdfObjectParser.ParseObject, seeded from the two corpora plus the
minimised inputs from every malformed-input bug already fixed (MalformedInputTests.cs,
EncryptDictionaryDenialOfServiceTests.cs, PdfDictionaryIndexTests.cs) — those are the shapes the
parser is known to be fragile on.
A harness whose only passing condition is "no unhandled exception in N seconds" is satisfied on
iteration 1 and never regresses. Four things make it real:
- An oracle, not just "doesn't crash". Assert that only
InvalidDataException,
UnsupportedPdfFeatureExceptionandPdfPasswordExceptionescape — anIndexOutOfRangeException,
NullReferenceException,OutOfMemoryExceptionorOverflowExceptionis a finding. That
vocabulary is already asserted by hand atThirdPartyReaderBehaviorTests.cs:266-275. Add a
per-input wall-clock and allocation ceiling; PdfDictionary is a linear scan, so building one is O(n²) — on the pre-authentication path #208 and fix(kernel): bound the cost of building a very large PdfDictionary #215 were both DoS fixes and the class is
live. - Determinism. A fixed seed printed on failure. A fuzz failure that cannot be reproduced is a
flaky test that gets deleted. - Crash triage → regression capture. On failure, write the minimised input as a CI artifact and
require the fixing PR to commit it intoFixtures/Fuzz/with a SHA pin and a token scan, exactly
like the existing corpora. Each finding then becomes a permanent, fast, deterministic unit test and
the seed corpus grows. Make capture the required output of a finding — otherwise "found nothing"
and "findings were fixed without capture" are indistinguishable six months later. - Budget shape. Short and always-on for PRs; longer nightly with a persisted corpus. A fuzzer
whose corpus resets each run explores the same first inputs forever.
On substrate: CsCheck is already a dependency (Apache-2.0, the repo's own licence), runs in-process
inside the normal dotnet test loop on Windows, has PCG-based automatic shrinking and CsCheck_Seed
replay, and iter:/time: budget control. SharpFuzz is AFL-based — "AFL works on Linux and
macOS", Windows needs WSL or libFuzzer — so it would be CI-only for this maintainer, reproducing the
exact complaint #198 exists to fix. Prefer CsCheck unless a spike shows otherwise.
Remaining — the CI round-trip oracle, blocked on #186
qpdf --check on re-serialized output presupposes a serializer for parsed documents, and the reader
has none. The only write path is PdfDocumentReader.AppendRevision
(src/VellumPdf.Reader/PdfDocumentReader.cs:951, internal), which copies the base file verbatim
and appends — so checking its output proves nothing about serialization. That serializer is #186.
Also worth folding in here: consolidate the per-file synthetic PDF builders. There are dozens of
private static byte[] Build… helpers spread across the test files with no shared type, and #184 and
#186 both add more.
Relates to
- Reader: write out a decrypted copy of an encrypted document #186 — provides the serializer this issue's round-trip oracle needs.
- Test: the veraPDF oracles in Layout.Tests never run locally on Windows #198 — the duplicated oracle process helpers, which Reader A5: fixture corpus + fuzzing + CI round-trip oracles #99's new oracles would otherwise duplicate
again.
Activity
Tim81 commentedon Aug 18, 2026
Validated the encrypted-fixture recipe against qpdf before anyone builds on it. Three findings, one of
which would have produced silently empty fixtures.
1.
--allow-weak-cryptois required for RC4, and its absence fails silently-ishqpdf refuses RC4 by default:
It still creates the output file, at 0 bytes.
lsshows it present. Anything that checked "the fixtureexists" rather than "the fixture contains the feature" would sail straight past this — the exact trap
CLAUDE.mddescribes.--allow-insecuredoes not help; that flag is about empty owner passwords on256-bit. The flag needed is
--allow-weak-crypto, documented as "necessary to create 40-bit files or128-bit files that use RC4 encryption".
2. Validated matrix
Base is
tests/VellumPdf.Kernel.Tests/GoldenTests.StandardFont_rawBytes.verified.pdf, first normalizedthrough
qpdf base.pdfso that encryption is the only delta against the plaintext baseline.Passwords: user
u, ownero.--encrypt u o)enc-rc4-4040 --with--allow-weak-cryptoenc-rc4-128128 --use-aes=n --with--allow-weak-cryptoenc-rc4-128-v4128 --force-V4 --use-aes=n --with--allow-weak-crypto/CF/V2enc-aes-128128 --use-aes=y --enc-aes-256-r5256 --force-R5 --enc-aes-256-r6256 --enc-256-cleartextmd256 --cleartext-metadata --That covers the whole #97 support matrix. Each fixture's
Rand cipher are confirmed byqpdf --password=u --show-encryption, which is the assertion to run before trusting any decrypt result.3. The KAT can be much stronger than "streams match"
qpdf --password=u --decrypton every one of the seven fixtures produces output byte-identical to theplaintext baseline except for 27 bytes, all in the second
/IDarray element (qpdf regenerates it;the first element is preserved). Verified across all seven.
So the decrypt KAT can assert two things, not one:
/IDelement is normalized.The second is a far tighter net than comparing streams alone, and it is version-skew-immune because it
compares our decrypted output to a checked-in plaintext baseline rather than to anything qpdf emits at
test time.
--cleartext-metadatais externally observable too:xpacketappears in the raw bytes ofenc-256-cleartextmd.pdfand does not appear inenc-aes-256-r6.pdf. That is the same assertion shape#182 needs on the write side.
Consequence for this issue
Generate the corpus once and check the fixtures in, rather than generating at test time. CI qpdf is
11.9.0 and local is 12.3.2; checked-in fixtures are byte-identical everywhere and take qpdf out of the
test-execution path entirely, so there is no
GateOnCiskip hole on the core corpus. Record the exactcommands above in a README beside the fixtures.
test(reader): check in the encrypted fixture corpus for the decrypt work
test(reader): guard the encrypted corpus and embed it for consumption
test(reader): pin each fixture by digest, and correct the baseline claim
test(reader): restore a clobbered 1.4.0 entry, and close two corpus gaps
test(reader): close three holes review found in the corpus guard
test(reader): commit the encrypted fixture corpus for the decrypt work (
feat(kernel): add the decrypt side of the Standard security handler (#…
docs: release 2.1.0 — decryption on read, and the docs that describe …
test(reader): add CsCheck lexer/parser fuzzing and a round-trip oracle (
test(reader): commit the encrypted fixture corpus for the decrypt work (
feat(kernel): add the decrypt side of the Standard security handler (#…
docs: release 2.1.0 — decryption on read, and the docs that describe …
test(reader): add CsCheck lexer/parser fuzzing and a round-trip oracle (
test(reader): commit the encrypted fixture corpus for the decrypt work (
feat(kernel): add the decrypt side of the Standard security handler (#…
docs: release 2.1.0 — decryption on read, and the docs that describe …
test(reader): add CsCheck lexer/parser fuzzing and a round-trip oracle (