Repository navigation
Conversation
GET /containers/{id}/attach/ws passed with CONTAINERS=1, even with
POST=0: it replayed a container's whole log (logs=1, which ALLOW_LOGS=0
is meant to deny) and wrote to the stdin of containers started with -i.
With POST=1, POST /containers/{id}/attach replayed the log too.
With POST=1, docker compose up, docker run and docker start -a without
-d attach, so they now need ALLOW_ATTACH=1; so do their Podman
equivalents, through /libpod/containers/{id}/attach.
|
Thanks for opening this pull request! Be sure to follow the pull request template! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have read the contributing guideline and understand that I have made the correct modifications
An LLM assisted me in writing the code or text for this PR
An LLM agent wrote the code or text for this PR
Description:
With
CONTAINERS=1, the template lets/containers/{id}/attachthrough. Its WebSocket form,GET /containers/{id}/attach/ws, is aGET, so it passes even withPOST=0: withlogs=1Docker replays the container's whole log (whatALLOW_LOGS=0denies on/logs), and withstdin=1a client writes to the stdin of a container started with-i. WithPOST=1,POST /containers/{id}/attach?logs=1replays the log too.This adds
ALLOW_ATTACH, default0: a deny rule next to the other subpath denies, so it applies whateverPOSTis set to. WithPOST=1,docker compose up,docker runanddocker start -awithout-dattach, so they now needALLOW_ATTACH=1; so do Podman's, through/libpod/containers/{id}/attach(not tested with Podman).AI use: Claude Code found the gap, wrote the patch and this description, and ran the tests below; I reviewed all of it and re-ran the curl reproduction below myself.
Benefits of this PR and context:
The same kind of gap as #56: a control (
ALLOW_LOGS,POST=0) the template doesn't enforce on a nested container path. A usual Traefik setup (CONTAINERS=1,POST=0) gives whoever compromises Traefik the log of every container on the host.How Has This Been Tested?
An Ubuntu 26.04.1 LTS VM with Docker 29.10.0. This branch built with
docker build --no-cache --pull -f Dockerfile.aarch64 -t socket-proxy:attach-test .(arm64) and loaded into the VM, against3.4.8-r0-ls107:(
trdrops the WebSocket close frame's bytes,sedHAProxy's 403 page, so only the status code shows; the proxy was removed between runs.)Also checked, unset and
ALLOW_ATTACH=0alike,POST=0andPOST=1:POST /containers/{id}/attach?logs=1&stream=0(3.4.8: 403 withPOST=0, the log withPOST=1; this branch: 403), and a small WebSocket client sendingid -untoalpine shstarted with-i, throughattach/ws?stream=1&stdin=1&stdout=1(3.4.8:root; this branch: 403).ALLOW_ATTACH=1brings both back. Traefik's calls (/_ping,/version,/containers/json,/containers/{id}/json,/events) answer 200 in every case.The docker CLI through the proxy with
POST=1(andIMAGES,NETWORKS,INFO,VOLUMES), each command stopped after 20 s:ALLOW_ATTACH=1docker run --rm alpine:3.24 echo run-okrun-ok, then doesn't returnunable to upgrade to tcp, received 403docker run -d alpine:3.24 truedocker start -a <container>unable to upgrade to tcp, received 403docker compose upSource / References:
execandpause.ContainerAttach(POST /containers/{id}/attach) andContainerAttachWebsocket(GET /containers/{id}/attach/ws).