GHSA-H9Q7-3G27-7RCH
Disk-backed multipart uploads persist after conversion requests
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche v8.36.0 | github.com/gotenberg/gotenberg/v8 · -89 d desde divulgación | |
| Divulgación | Publicada | GHSA-H9Q7-3G27-7RCH divulgada · CVSS 7.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Gotenberg does not remove disk-backed temporary files created while parsing multipart requests. Uploaded files that exceed Go's in-memory multipart threshold are written to the process temporary directory as `multipart-*` and remain there after the request completes.
The files persist until the container or task is destroyed. Repeated requests can exhaust the temporary filesystem. More importantly, another conversion running as the same OS user can read documents left by earlier requests if it gains a local-file-read or code-execution primitive.
Affected versions
- Confirmed affected: Gotenberg 8.29.0 through 8.34.0.
- The current `main` branch was still affected at commit `9ec7be4` on 2026-08-11.
- Gotenberg 8.28.0 does not contain the request-cloning behavior that causes this cleanup failure.
The behavior appears to have been introduced with the OpenTelemetry middleware in 8.29.0.
Technical details
The API registers `telemetryMiddleware` as a pre-router middleware for every request:
a.srv.Pre(
latencyMiddleware(),
rootPathMiddleware(a.rootPath),
outputFilenameMiddleware(),
telemetryMiddleware(...),
)To attach the OpenTelemetry context, the middleware replaces Echo's request with a shallow clone:
request := c.Request()
savedCtx := request.Context()
// ...
c.SetRequest(c.Request().WithContext(ctx))Multipart parsing happens later through the cloned request:
form, err := echoCtx.MultipartForm()Go stores sufficiently large multipart file parts in `os.TempDir()` and records the resulting paths in the request's `MultipartForm`. At the end of an HTTP request, `net/http` invokes `RemoveAll()` only on the original server request's `MultipartForm`.
Because Gotenberg parses the body through the clone, the original request's `MultipartForm` remains nil. The standard-library cleanup therefore has nothing to remove. Restoring another clone to the Echo context after the handler returns does not update the original request object held by `net/http`.
Gotenberg copies each parsed upload into its UUID-based request working directory, so the parser-owned `multipart-*` file is no longer required once `newContext` returns. Existing cancellation cleanup removes only the UUID working directory, not the parser-owned temporary file.
Reproduction
The following uses a dummy upload. The conversion may fail because the dummy file is not a valid ODT; multipart parsing occurs before conversion and is sufficient to reproduce the leak.
docker run --rm --name gotenberg-multipart-repro -p 3000:3000 \
gotenberg/gotenberg:8.34.0-libreoffice
dd if=/dev/zero of=/tmp/input.odt bs=1M count=40
curl -sS -o /dev/null -w '%{http_code}\n' \
-F files=@/tmp/input.odt \
http://127.0.0.1:3000/forms/libreoffice/convert
docker exec gotenberg-multipart-repro \
sh -c 'find /tmp -maxdepth 1 -type f -name "multipart-*" -ls'Expected result
No `multipart-*` file remains after the request finishes.
Actual result
`/tmp/multipart-*` contains the uploaded bytes and remains readable by the `gotenberg` user. Repeating the request creates additional persistent files.
Impact
- Cross-request document remanence in deployments that reuse a worker for multiple users or tenants.
- Disclosure of earlier uploads when combined with a converter local-file-read or code-execution primitive.
- Temporary-filesystem exhaustion through repeated large multipart requests.
- Retention lasts for the lifetime of the container or task rather than the lifetime of the request.
Suggested classification: CWE-459, Incomplete Cleanup.
Proposed fix
Explicitly call `multipart.Form.RemoveAll()` inside `newContext` after Gotenberg has finished copying uploaded files into its request working directory. This avoids relying on `net/http` cleanup through a request pointer that middleware has replaced.
The attached patch implements this cleanup and adds a regression test that forces an upload into a real disk-backed multipart file, invokes `newContext`, and verifies that the temporary file has been removed before conversion begins.
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.36.0 | -89 d | v8.40.0 no afectada |
8.36.0v8.36.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-h9q7-3g27-7rchLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
