Skip to content

Security audit follow-up: bound PDF split work to the page limit, document trust model - #2

Merged
hensing merged 2 commits into
mainfrom
sync-upstream-and-prs
Jul 7, 2026
Merged

Security audit follow-up: bound PDF split work to the page limit, document trust model#2
hensing merged 2 commits into
mainfrom
sync-upstream-and-prs

Conversation

@hensing

@hensing hensing commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

PR #1 got merged while this branch still had two more commits from the full security-audit pass queued up. This PR carries just those two:

  • fix(pdf): trim to page limit before splitting, not afterDownloadDocumentAsPDF's split step used to split every page of the source PDF via pdfcpu and only use the first OCR_LIMIT_PAGES outputs afterward, so an oversized document cost the same split work regardless of the configured limit. Now trims the source down to the limited page range first when a limit applies, then splits that instead. Added TestDownloadDocumentAsPDF_SplitWithPageLimit asserting only the limited number of split files gets created on disk.
  • docs: document the no-auth trust model and whole_pdf's page-limit exemption — the audit's other actionable finding was that paperless-gpt has no built-in authentication and binds all interfaces by default, which wasn't documented anywhere; added a ### Security section spelling this out plus the guidance to run it behind a reverse proxy/VPN. Also documented that OCR_LIMIT_PAGES doesn't apply to whole_pdf mode (by design — that mode always processes the whole document).

Test plan

  • go build ./... && go test ./... green (Docker Go 1.25.5 toolchain)
  • New test confirms only the page-limited count of split files are produced for a 5-page PDF with OCR_LIMIT_PAGES=2

hensing added 2 commits July 6, 2026 23:24
DownloadDocumentAsPDF's split step used pdfcpu.SplitFile on the full
original PDF and only used the first pagesToProcess outputs afterward,
so an oversized document cost the same split work (CPU/disk) no matter
what OCR_LIMIT_PAGES was set to. Trim the source down to the limited
page range first (pdfcpu's TrimFile) when a limit actually applies, and
split that instead.
…mption

Full security audit turned up two behaviors worth calling out
explicitly rather than changing: the app has no built-in auth and
binds all interfaces by default (this is an accepted trust model for
a self-hosted tool, but wasn't documented anywhere), and
OCR_LIMIT_PAGES intentionally has no effect in whole_pdf mode.
@hensing
hensing merged commit 13c99c5 into main Jul 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant