From 963573182bcfcc97f992b9451edb53e2191dc1bd Mon Sep 17 00:00:00 2001 From: Ryan McCahan Date: Sun, 22 Nov 2026 18:35:27 -0700 Subject: [PATCH 1/3] docs: document container hardening with a read-only root and noexec temp mounts --- docs/operate/secure.mdx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/operate/secure.mdx b/docs/operate/secure.mdx index 9c760b65..76f8bb60 100644 --- a/docs/operate/secure.mdx +++ b/docs/operate/secure.mdx @@ -82,6 +82,31 @@ Each of these flags trades a protection for a feature. Turn one on only when eve The image already runs as an unprivileged user, `gotenberg`, UID 1001. +## Harden the container + +The image needs no writable root and no Linux capabilities. Lock both down, so a caller who plants a file can't run it and a flaw that writes outside the temp space has nowhere to land. + +Gotenberg writes its working files under `/tmp`. Mount the root file system read-only and give it writable `tmpfs` space there. Mark every writable mount `noexec` and `nosuid`: a `noexec` mount refuses to run any file on it, and the loader can't map a file from it and jump in either. Drop all capabilities and block privilege escalation. + +```yaml title="compose.yaml" +services: + gotenberg: + image: gotenberg/gotenberg:9 + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=1g + - /home/gotenberg:rw,noexec,nosuid,size=128m,uid=1001,gid=1001 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + shm_size: 256m +``` + +Size `/tmp` for your largest conversions: each request's files live there until it finishes. Chromium needs shared memory, which `shm_size` sets; a heavy page may want more. + +Filter egress as well. [Refusing private addresses](/docs/operate/outbound) keeps Gotenberg off your internal network. A firewall or Kubernetes NetworkPolicy that allows only the destinations your conversions need backs that up at the network layer. + ## Next [Restrict outbound requests](/docs/operate/outbound), then [limit resources](/docs/operate/limits). From cdca26dd4a738cada6326217c218a2ce2fac4a3f Mon Sep 17 00:00:00 2001 From: Ryan McCahan Date: Sun, 22 Nov 2026 18:40:59 -0700 Subject: [PATCH 2/3] docs: harden the Kubernetes sample and link it from the user-HTML cookbook --- docs/cookbook/user-html.mdx | 1 + docs/getting-started/installation.mdx | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/docs/cookbook/user-html.mdx b/docs/cookbook/user-html.mdx index f8457a68..4045a1a5 100644 --- a/docs/cookbook/user-html.mdx +++ b/docs/cookbook/user-html.mdx @@ -48,3 +48,4 @@ The PDF prints as before. An image or a style sheet the HTML points at an intern - The templates need your own assets: upload them with the page, or allow your asset host with `CHROMIUM_ALLOW_LIST`, together with `^file:///tmp/` for the files uploaded with the page. - The templates need scripts: keep JavaScript on, and keep the timeout short. - Users send URLs, not HTML: the same settings apply to `/forms/chromium/convert/url`. +- Harden the container itself: a [read-only root and `noexec` temp mounts](/docs/operate/secure#harden-the-container) stop a caller who plants a file from running it. diff --git a/docs/getting-started/installation.mdx b/docs/getting-started/installation.mdx index d001af09..29da8535 100644 --- a/docs/getting-started/installation.mdx +++ b/docs/getting-started/installation.mdx @@ -85,9 +85,22 @@ containers: ports: - containerPort: 3000 securityContext: + runAsNonRoot: true runAsUser: 1001 + runAsGroup: 1001 allowPrivilegeEscalation: false privileged: false + readOnlyRootFilesystem: true + capabilities: + drop: + - ALL + seccompProfile: + type: RuntimeDefault + volumeMounts: + - name: tmp + mountPath: /tmp + - name: home + mountPath: /home/gotenberg readinessProbe: httpGet: path: /health @@ -100,8 +113,19 @@ containers: requests: memory: 512Mi cpu: 200m +volumes: + - name: tmp + emptyDir: + medium: Memory + sizeLimit: 1Gi + - name: home + emptyDir: + medium: Memory + sizeLimit: 128Mi ``` +The `securityContext` locks the container down: a read-only root file system, no capabilities, no privilege escalation, and the runtime's default seccomp profile. Gotenberg writes under `/tmp` and its home directory, so two in-memory `emptyDir` volumes keep those writable. Kubernetes mounts an `emptyDir` with execution allowed and offers no `noexec` for it, so the read-only root carries the weight here; Docker adds [`noexec` temp mounts](/docs/operate/secure#harden-the-container) on top. The 386 image needs `socketcall`: drop `seccompProfile` there, or set a profile that allows it, as the Docker note above describes. + A community-maintained Helm chart lives at [MaikuMori/helm-charts](https://github.com/MaikuMori/helm-charts). ## Cloud Run From 7fe1f3f9004dba8c75e0c14c288f30a553b23e01 Mon Sep 17 00:00:00 2001 From: Ryan McCahan Date: Mon, 23 Nov 2026 08:45:59 -0700 Subject: [PATCH 3/3] docs: clarify that /tmp is the writable mount Gotenberg needs --- docs/getting-started/installation.mdx | 2 +- docs/operate/secure.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/getting-started/installation.mdx b/docs/getting-started/installation.mdx index 29da8535..8173b23b 100644 --- a/docs/getting-started/installation.mdx +++ b/docs/getting-started/installation.mdx @@ -124,7 +124,7 @@ volumes: sizeLimit: 128Mi ``` -The `securityContext` locks the container down: a read-only root file system, no capabilities, no privilege escalation, and the runtime's default seccomp profile. Gotenberg writes under `/tmp` and its home directory, so two in-memory `emptyDir` volumes keep those writable. Kubernetes mounts an `emptyDir` with execution allowed and offers no `noexec` for it, so the read-only root carries the weight here; Docker adds [`noexec` temp mounts](/docs/operate/secure#harden-the-container) on top. The 386 image needs `socketcall`: drop `seccompProfile` there, or set a profile that allows it, as the Docker note above describes. +The `securityContext` locks the container down: a read-only root file system, no capabilities, no privilege escalation, and the runtime's default seccomp profile. Gotenberg writes its working files under `/tmp`, so an in-memory `emptyDir` keeps it writable; a second one covers the home directory, where the engines may cache. Kubernetes mounts an `emptyDir` with execution allowed and offers no `noexec` for it, so the read-only root carries the weight here; Docker adds [`noexec` temp mounts](/docs/operate/secure#harden-the-container) on top. The 386 image needs `socketcall`: drop `seccompProfile` there, or set a profile that allows it, as the Docker note above describes. A community-maintained Helm chart lives at [MaikuMori/helm-charts](https://github.com/MaikuMori/helm-charts). diff --git a/docs/operate/secure.mdx b/docs/operate/secure.mdx index 76f8bb60..42261c7b 100644 --- a/docs/operate/secure.mdx +++ b/docs/operate/secure.mdx @@ -103,7 +103,7 @@ services: shm_size: 256m ``` -Size `/tmp` for your largest conversions: each request's files live there until it finishes. Chromium needs shared memory, which `shm_size` sets; a heavy page may want more. +`/tmp` is the mount that must stay writable: every conversion's working files live there, LibreOffice's user profile included. Size it for your largest conversions. The home mount only covers what the engines cache in the home directory. Chromium needs shared memory, which `shm_size` sets; a heavy page may want more. Filter egress as well. [Refusing private addresses](/docs/operate/outbound) keeps Gotenberg off your internal network. A firewall or Kubernetes NetworkPolicy that allows only the destinations your conversions need backs that up at the network layer.