From 56fa3c522c7bfc0b1f9bcee4f8da66d1ee560525 Mon Sep 17 00:00:00 2001 From: Antonis Grigoriadis <5454455+antonisgr@users.noreply.github.com> Date: Sun, 29 Nov 2026 16:17:43 +0200 Subject: [PATCH] Deny container attach unless POST=1 With CONTAINERS=1, GET /containers/{id}/attach/ws passed both POST=0 and the /containers allow rule: it replayed a container's whole log (what ALLOW_LOGS=0 denies on /logs) and could write to the stdin of a container started with -i. Attach now needs POST=1, also in its WebSocket form, so POST=1 setups (docker run, docker start -a, docker compose up) keep working as before. Co-authored-by: spannerman79 <7542384+spannerman79@users.noreply.github.com> --- readme-vars.yml | 1 + root/templates/haproxy.cfg | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/readme-vars.yml b/readme-vars.yml index d52b2a9..f5cc6a2 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -471,6 +471,7 @@ full_custom_readme: | ## Versions + * **29.11.26:** - Container attach's WebSocket form (`/containers/{id}/attach/ws`) now needs `POST=1`, like its `POST` form. * **05.10.26:** - Add `TIMEOUT_CLIENT` & `TIMEOUT_SERVER` options. * **18.08.26:** - Add `ALLOW_ARCHIVE`, `ALLOW_CHANGES`, `ALLOW_EXPORT`, `ALLOW_LOGS`, `ALLOW_TOP` options. * **15.06.26:** - Rebase to Alpine 3.24. diff --git a/root/templates/haproxy.cfg b/root/templates/haproxy.cfg index 1932e16..a6b7004 100644 --- a/root/templates/haproxy.cfg +++ b/root/templates/haproxy.cfg @@ -44,6 +44,10 @@ frontend proxy http-request deny if { path,url_dec -m reg -i ^(/v[\d\.]+)?(/libpod)?/(containers|pods)/[a-zA-Z0-9_.-]+/(pause) } !allow_pause http-request deny if { path,url_dec -m reg -i ^(/v[\d\.]+)?(/libpod)?/containers/[a-zA-Z0-9_.-]+/(exec) } !allow_exec + # attach can write to a container's stdin and replay its log, so it needs POST=1 + # even in its GET (WebSocket) form, /containers/{id}/attach/ws + http-request deny if { path,url_dec -m reg -i ^(/v[\d\.]+)?(/libpod)?/containers/[a-zA-Z0-9_.-]+/attach } !{ env(POST) -m bool } + # Docker's archive extraction endpoint only consumes tar request bodies when # their media type is application/x-tar. Supply the documented media type # when clients omit Content-Type rather than forwarding a request that the