Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/cookbook/user-html.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
24 changes: 24 additions & 0 deletions docs/getting-started/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 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).

## Cloud Run
Expand Down
25 changes: 25 additions & 0 deletions docs/operate/secure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

`/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.

## Next

[Restrict outbound requests](/docs/operate/outbound), then [limit resources](/docs/operate/limits).