You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PdfDictionary is a linear scan, so building one is O(n²) — on the pre-authentication path #208
Found during the #97 review; recorded there as out of scope and stated as a residual in SECURITY.md rather than fixed.
PdfDictionary stores its entries in a List<KeyValuePair<PdfName, PdfObject>> and scans it linearly
(src/VellumPdf.Kernel/Core/PdfDictionary.cs:9, :14, :34). Set walks the whole list before
appending, so building an n-entry dictionary is O(n²), and every Get is O(n).
That is ordinary for the two-to-twenty-key dictionaries a real PDF is made of. It stops being ordinary
on /Encrypt, because everything the handler reads out of that dictionary runs before the password
is checked, on a file anyone can send. Measured on this machine, directly in /Encrypt with no /CF
at all: roughly 1.4 s at 16 000 keys, roughly 50 s at 128 000.
Three quadratic terms are in play and only one is bounded today:
the parser building the dictionary — unbounded;
EncryptionSetup.DereferenceValues rebuilding it — unbounded;
the /CF copy inside it — capped at 64 entries (EncryptionSetup.cs, MaxCryptFilters), which
is why a /CF-shaped attack is no longer the cheapest route to the cost.
So the cap closed the cheap path and not the cost. SECURITY.md says so outright rather than implying
the reader cannot be made to spend time, and DecryptObjectGraph has the same shape on any large
dictionary it decrypts (d.Set per entry).
Fix direction. A hybrid PdfDictionary — keep the list for order and the small-n fast path, add a Dictionary<PdfName, int> index above some threshold — leaves the public surface and the serialisation
order alone. Whatever the shape, this needs a bounded-input test that fails without it, because a
green suite says nothing about a quadratic: the existing tests all use small dictionaries.
Not urgent, not ignorable. Bounding input size is the caller's job, and no correctness bug
follows from this. It is a denial-of-service surface reachable without a password, which is a different
class from the rest of the reader's failure modes.
Activity
Address review findings on the dictionary index fix (#208)
docs: release 2.2.0 — encryption and parser hardening (#217)
chore(test): migrate to Microsoft.Testing.Platform for xunit.v3 4.x
fix(test): scope coverlet.MTP via testconfig.json, not CLI filters
fix(test): scope coverlet.MTP via testconfig.json, not CLI filters
Migrate tests to Microsoft.Testing.Platform for xunit.v3 4.x (#390)
fix(kernel): bound the cost of building a very large PdfDictionary (#215
docs: release 2.2.0 — encryption and parser hardening (#217)
Migrate tests to Microsoft.Testing.Platform for xunit.v3 4.x (#390)
fix(kernel): bound the cost of building a very large PdfDictionary (#215
docs: release 2.2.0 — encryption and parser hardening (#217)
Migrate tests to Microsoft.Testing.Platform for xunit.v3 4.x (#390)
test: widen the encrypt-dictionary pin instead of tightening its clock
test: widen the encrypt-dictionary pin instead of tightening its clock
test: widen the encrypt-dictionary pin instead of tightening its clock
test: widen the encrypt-dictionary pin instead of tightening its clock
test: widen the encrypt-dictionary pin instead of tightening its clock
test: widen the encrypt-dictionary pin instead of tightening its clock
test: assert the fixture is huge, and correct what shares the fuzzer
test: widen the encrypt-dictionary pin instead of tightening its clock
test: assert the fixture is huge, and correct what shares the fuzzer
test: assert the encrypt-dictionary fixture is huge, and widen its pin (
test: replace wall-clock cost assertions with deterministic pins (#577)