Skip to content

fix: deny exec-create and pause paths when their env vars are unset - #56

Merged
thespad merged 1 commit into
linuxserver:mainfrom
minima1cha0s:main
Nov 6, 2026
Merged

thespad merged 1 commit into
linuxserver:mainfrom
minima1cha0s:main

Conversation

@minima1cha0s

Copy link
Copy Markdown
Contributor

Description:

root/templates/haproxy.cfg does not enforce two of its documented ACLs on
nested container paths:

  1. EXEC=0 does not block exec-create. The exec rule
    (http-request allow if ... ^(/v...)?/exec { env(EXEC) }) only matches
    paths starting with /exec (i.e. POST /exec/{id}/start). The actual
    exec-create call, POST /containers/{id}/exec, matches the generic
    allow if ^(/v...)?/containers { env(CONTAINERS) } rule instead, so with
    CONTAINERS=1 and POST=1 it succeeds regardless of EXEC. The README
    documents EXEC=0 as covering /exec & /containers/{id}/exec, so the
    template fails to implement its own documented behaviour.

  2. ALLOW_PAUSE=0 does not block pause. The pause rule is allow-only
    (allow if .../pause { env(ALLOW_PAUSE) }) with no corresponding deny
    rule. With CONTAINERS=1 and POST=1 the request falls through to the
    generic containers allow. The same asymmetry exists for
    start/stop/kill under ALLOW_START/ALLOW_STOP/ALLOW_RESTARTS,
    though this PR keeps scope to the two demonstrated gaps (start/stop/kill
    fall-through can be a follow-up).

This PR adds two deny rules in the same style as the existing
archive/change/export/logs/top denies (they must precede the generic
allows — HAProxy http-request rules are first-match-wins), plus the two
missing

acl definitions:

acl allow_pause env(ALLOW_PAUSE) -m bool
acl allow_exec env(EXEC) -m bool

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

Benefits of this PR and context:

Aligns the template with the README's documented ACL semantics and closes a
real hardening gap: a user with CONTAINERS=1, POST=1, EXEC=0, ALLOW_PAUSE=0 — the standard read-plus-restart profile — currently exposes
exec-instance creation and container pause to whatever process can reach the
proxy. This fixes the intent expressed by the existing deny block for
archive/change/export/logs/top.

Related: Tecnativa/docker-socket-proxy#114 (exec open when POST=1),
Tecnativa/docker-socket-proxy#176 (proposed fix, still open).

How Has This Been Tested?

  • Static: haproxy -c -f config validation passes with the patched template.
  • Live regression sweep against a running instance of the patched image
    (CONTAINERS=1 IMAGES=1 NETWORKS=1 VOLUMES=1 LOGS=1 EVENTS=1 INFO=1 VERSION=1 PING=1 POST=1 ALLOW_START=1 ALLOW_STOP=1 ALLOW_RESTARTS=1 ALLOW_UNPAUSE=1, all other vars 0):
    • GET /_ping → 200
    • GET /containers/json → 200
    • POST /v1.47/volumes/create → 201
    • POST /v1.47/containers/x/unpause → 204 (ALLOW_UNPAUSE=1 still granted)
    • POST /v1.47/containers/x/exec → 403 (was 201)
    • POST /v1.47/containers/x/pause → 403 (was 204)
    • POST /v1.47/exec/{id}/start → 403 (unchanged)
    • POST /v1.47/build, /commit, /containers/x/top,
      /containers/x/archive PUT → 403 (unchanged)
  • Template source read against the current README table to confirm
    EXEC and ALLOW_PAUSE documented coverage.

Source / References:

EXEC=0 documented as covering /containers/{id}/exec but the template
only gated paths starting with /exec, so exec-create fell through the
generic containers allow. ALLOW_PAUSE was allow-only with no deny rule,
so pause fell through whenever CONTAINERS=1 and POST=1. Add the missing
deny rules in the same style as the existing archive/change/export/
logs/top denies. Ref: Tecnativa/docker-socket-proxy#114
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! Be sure to follow the pull request template!

@github-project-automation github-project-automation Bot moved this from PRs to PRs Approved in Issue & PR Tracker Nov 6, 2026
@thespad
thespad merged commit a17cf86 into linuxserver:main Nov 6, 2026
3 checks passed
@LinuxServer-CI LinuxServer-CI moved this from PRs Approved to Done in Issue & PR Tracker Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants