GHSA-rqgh-gxv4-6657 Gotenberg has Unauthenticated RCE via ExifTool Metadata Key Injection
Unauthenticated RCE in Gotenberg via Metadata Key Newline InjectionSummaryGotenberg's `/forms/pdfengines/metadata/write` HTTP endpoint accepts a JSON metadata object and passes its keys directly to ExifTool via the go-exiftool library. No validation is performed on key characters. A `\n` embedded in a JSON key splits the ExifTool stdin stream into a new argument line, allowing an attacker to inject arbitrary ExifTool flags — including `-if`, which evaluates Perl expressions. This achieves unauthenticated OS command execution in a single HTTP request. The response is HTTP 200 with a valid PDF, making the attack transparent to basic monitoring.Vulnerability Details| Field            | Value                                    |
|------------------|------------------------------------------|
| Product          | Gotenberg                                |
| Version          | 8.29.1 (default `gotenberg/gotenberg:8`) |
| Component        | `pdfengines/metadata/write` endpoint     |
| CWE              | CWE-78 — Improper Neutralization of Special Elements used in an OS Command |Affected Code**Product:** Gotenberg  
**Endpoint:** `/forms/pdfengines/metadata/write`  
**Root cause:** JSON metadata keys are passed to go-exiftool without control-character
validation. The existing `dangerousTags` blocklist uses exact-match deletion and
provides no defense against `\n`-embedded keys.The injection occurs because go-exiftool writes each key to ExifTool's stdin as:When `k` is `Title\n-if\nsystem('cmd')||1\n-Comment`, ExifTool's stdin becomes:ExifTool's `-if` flag evaluates its argument as a Perl expression, giving the attacker arbitrary code execution.**Why it's vulnerable:** Gotenberg is the HTTP entry point. It controls what data enters go-exiftool. The `dangerousTags` blocklist (`FileName`, `Directory`) shows that the authors are aware that certain keys are dangerous, but the fix is incomplete: it uses exact string matching and does not strip or reject control characters in keys.
This vulnerability exists entirely within Gotenberg's responsibility and is independently fixable without changing go-exiftool.Attack Scenario**Threat actor:** Unauthenticated remote attacker  
**Preconditions:** Gotenberg port 3000 is reachable (common in internal/cloud deployments)Attacker sends a POST request to `/forms/pdfengines/metadata/write` with any valid PDF and a metadata JSON object whose key contains embedded newlines.Gotenberg deserializes the JSON key — `\n` is preserved as a literal newline in Go's  `map[string]any` after `json.Unmarshal`.The key is forwarded to go-exiftool, which writes it verbatim to ExifTool's stdin, splitting it across multiple argument lines.ExifTool processes `-if system('cmd')||1` as a Perl expression and executes `cmd`.The attacker exfiltrates output via an OOB HTTP callback. Response to the attacker is HTTP 200 with a valid PDF — no error signal.Proof of ConceptOOB exfiltration via base64-encoded HTTP callback:Self-contained Python PoC (auto-generates PDF from target, exfiltrates via OOB):Expected output:ImpactFull unauthenticated remote code execution as the Gotenberg process user (`uid=1001(gotenberg)`, member of `root` group in the default Docker image). An attacker can read arbitrary files, write files, establish reverse shells, or pivot within the network. The attack requires no credentials and returns no error signal. Any deployment that exposes Gotenberg's port 3000 without an authenticating proxy is fully compromised by a single HTTP request.RemediationIn Gotenberg's metadata handler, reject any key containing control characters before passing it to go-exiftool:Operators should also place Gotenberg behind an authenticated reverse proxy and never expose port 3000 directly to untrusted networks.**Note:** A companion advisory covers the same class of injection at the go-exiftool library layer (independently fixable — see go-exiftool advisory).Timeline| Date       | Event                                      |
|------------|--------------------------------------------|
| 2026-04-04 | Vulnerability discovered                   |
| 2026-04-04 | RCE confirmed — local file write + OOB HTTP |
| 2026-04-04 | Report drafted for disclosure              |
| 2026-04-08 | Split into separate per-product advisories |ResourcesCWE-78: https://cwe.mitre.org/data/definitions/78.htmlExifTool `-if` flag: https://exiftool.org/exiftool_pod.htmlgo-exiftool: https://github.com/barasher/go-exiftoolCVSS calculator: https://www.first.org/cvss/calculator/3.1
CVSS v3.1 score: 9.8