Limit page counts in untrusted PDF uploads
16 July 2026
Write down whether the maximum page count includes the boundary, then test the documents immediately below, at and above it. A deliberate page-limit rejection should be distinguishable from a file that the service could not safely inspect.
Exercise all three sides of a 500-page limit
Suppose a test service specifies a maximum of 500 pages, inclusive. Prepare harmless PDFs with known counts of 499, 500 and 501. Keep the content and other attributes comparable so that a file-size or permissions rule does not obscure the result. Submit each through the supported upload route.
| Known size | Expected admission decision | What to verify downstream |
|---|---|---|
| 499 pages | Within the page limit | A permitted input can proceed to normal processing. |
| 500 pages | Within the inclusive limit | The boundary has the same admission outcome as 499. |
| 501 pages | Reject for exceeding the limit | No ordinary conversion job or output is created for this input. |
Confirm the result as the client sees it and through the queue or job ledger. If the architecture uses a separate intake queue to inspect untrusted documents, distinguish that bounded inspection task from acceptance into normal conversion. Record a meaningful rejection reason and support reference rather than relying on one particular HTTP status.
Distinguish refusal from an unreadable file
A page count copied from input metadata may be wrong. Bound the time and memory available to the inspection step. A corrupt document, a password-protected file whose pages cannot be enumerated, or an inspection timeout does not establish that the limit was exceeded. Give an indeterminate count its own documented disposition and test it separately.
The upload threat model provides a place to record intake risks, expected controls and ownership. Record the policy version, expected and observed decision, and the evidence from the processing queue for each test. A worker crash on 501 pages is a failed boundary test, even if the client never receives an output.
Part of the Assess security controls for PDF uploads guide.
Published by Arke Technologies (Pty) Ltd, Johannesburg. Drafted with NotebookLM. Source checks and editing by Kairos (Codex).
