Skip to Content

Security

How Papyrus handles untrusted documents and URLs, and what to lock down in your deployment

Papyrus processes documents and web pages you do not control. This page lists what it protects by default, what it leaves to your deployment, and the settings to review before you expose it.

Checklist

  • Long random API keys from your secret manager, rotated by listing old and new keys together.
  • TLS and a request body size limit at your reverse proxy.
  • http.allow_private: false, and http.allowed_hosts set when your sources come from known hosts.
  • Egress from the container limited to the hosts and buckets Papyrus needs, and the OCR backend if you use one.
  • With ocr, a backend your documents are allowed to reach.
  • PAPYRUS_AUTH_DISABLED and PAPYRUS_TIMING unset.
  • Storage credentials passed as environment variables, scoped to the buckets Papyrus reads and writes.

Authentication

Every /v1 request needs a static bearer key from PAPYRUS_API_KEY; /, /health and /ready are public and reveal only the version and status. Keys are compared in constant time. Papyrus has no users or per-key permissions: every key can call every endpoint and read every configured connector, so give it to services, not to end users.

Fetching URLs

Every URL source, redirect and resource a screenshot page loads is checked before Papyrus connects:

  • Hostnames that resolve to private, loopback, link-local or other internal addresses are refused with 403 source_forbidden, unless http.allow_private is on.
  • With http.allowed_hosts, any other host is refused, for every hop and every page resource.
  • Downloads stop at limits.max_file_size, even when the server does not announce a size.

The browser connects only through this check, with the resolved address pinned, so a page cannot change its DNS answer between the check and the connection. Plain URL downloads check the address but do not pin it yet, so a host that switches its DNS answer right after the check could reach an internal address. Until pinning lands, set http.allowed_hosts for known sources, or block internal ranges with an egress policy on the container.

Untrusted documents

  • Every converter runs in a separate worker process. A document that crashes or hangs a worker fails its own request with 500 processing_failed or 504 processing_timeout, and the worker is replaced.
  • Image files are checked against a pixel limit before decoding. The limit does not cover images inside a PDF, which can expand to gigabytes, and worker processes have no memory limit of their own. Set a memory limit on the container.
  • Error responses never include stack traces or internal paths.
  • Every request works in its own temporary folder, removed when the response is sent.

LibreOffice is configured to run no macros and to load no remote or local resources that a document links to. Its workers still have network access, and the fetch policy does not apply to them, so a document that exploits LibreOffice could use it. Deny egress for the container, or at least to internal ranges, when you process office files from untrusted sources.

OCR

With ocr configured, the default readMode: auto sends the page images of scans, images and presentations to the backend, and readMode: ocr sends every page, also from clients that never asked for OCR. With mistral, or a hosted OpenAI-compatible server, that is a third party: check that your agreements allow it, or run the model in your own infrastructure. The operator decides where documents go; a request can keep its pages away with readMode: text.

  • Only use a backend you trust. Its URL is not subject to the fetch policy, so that it can be a private address.
  • Text on a page can steer the model, for example an instruction to ignore the rest of the page. The output is plain text and Papyrus never acts on it, but your pipeline must treat it as untrusted.
  • Papyrus does not log page content, model answers or keys, and errors never include the backend's response.
  • Leave MISTRAL_SDK_TELEMETRY unset: the Mistral SDK telemetry it turns on can include page content.

Browser isolation

Chromium runs without its own sandbox by default, because the default Docker seccomp profile blocks the user namespaces the sandbox needs. Each request still gets an isolated browser context, and the container runs as a non-root user.

Without the sandbox, a Chromium exploit in a hostile page runs as the Papyrus user, with access to its environment variables, including API keys and storage credentials, and to other requests' temporary files. To close that gap, run the container with a seccomp profile that allows unprivileged user namespaces, and set:

browser:
  sandbox: true

With sandbox: true on a runtime that does not allow it, screenshots and HTML thumbnails fail with 500 processing_failed. If you do not need screenshots or website thumbnails, block URL sources to untrusted hosts with http.allowed_hosts to keep hostile pages out entirely.

Request size

The server parses multipart uploads before it checks their size, so an oversized upload uses disk and time before it is refused. Enforce a body limit slightly above limits.max_file_size at your reverse proxy, for example client_max_body_size 110m; in nginx.

On this page