Skip to content

fix(lab): put the lab, SOC and sensor Alloys behind a Docker socket proxy (#836) - #867

Merged
Gerrrt merged 7 commits into
mainfrom
gerrrt/836-socket-proxy
Oct 3, 2026
Merged

Gerrrt merged 7 commits into
mainfrom
gerrrt/836-socket-proxy

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Oct 3, 2026

Copy link
Copy Markdown
Owner

What changed

  • stacks/lab, stacks/soc and stacks/sensor each get a docker-socket-proxy, the estate's from Put the Docker socket behind an allowlisting proxy — Alloy can still POST to it #193: the same pinned digest and the same GET-only allowlist (CONTAINERS, IMAGES, INFO, VERSION, EVENTS, NETWORKS; POST: 0).
    • Each stack's Alloy sets DOCKER_API: tcp://docker-socket-proxy:2375, which docker.alloy's three components already read, and its socket mount is removed.
  • scripts/check_compose_health.py fails on any docker.sock mount in a compose file outside the proxy image, matched by image, not service name, in the short and long volume forms.
    • Four fixtures under --self-test.
    • CI already runs the check on every stack (ci.yml, Verify health dependencies…).
  • Docs. docs/security.md named only oracle as still exposed and now names all four. The three stack READMEs, README.md and docs/architecture.md list the new service.

Why

Refs #836. :ro on the socket applies to the file, not the API behind it: POST /containers/create with / bound read-write still works, so each bare mount was root on its host. All three hosts sit on VLAN 30, the segment built to hold attackers. alexander holds the lab's only age key (#671), and odin holds the SOC's key and Velociraptor's CA.

Blast radius

alexander, odin and fenrir, each at its next make up. None of them converges, so merging changes nothing that is running.

The failure to watch for is the one #193 measured: a too-narrow allowlist does not error, it just collects less. The allowlist is the estate's verbatim, including NETWORKS, without which discovery.docker fails and container logs stop while the agent stays healthy. After deploying, check that loki_source_docker_target_entries_total is climbing on each guest.

Expect a merge conflict with #865. It also edits these three compose files and the lab README's service count, in different services. Whichever merges second needs the count set to six (caddy and the proxy both).

  • No change to network segmentation or firewall rules
  • No new port published to a VLAN that could not already reach the service. The proxy is expose: only.
  • No credential added outside secrets/*.sops.yaml

Verification

  • check_compose_health.py --self-test: the four new fixtures pass.

  • Before the fix, the check flagged exactly the three Alloys and passed stacks/observability. After it, all eight stacks pass.

  • check_docs.py, yamllint and markdownlint pass on every changed file.

  • Not run locally, because this machine has no Docker: docker compose config and the image probe. CI runs both.

  • make validate passes (CI)

  • Deployed: on each guest, docker logs <stack>-docker-socket-proxy shows no 403s, and container logs still reach the lab's Loki

  • Docs updated

Not covered

oracle's agent still mounts the socket. It is a single docker run in deploy-agent.sh, not a compose service, so the new check cannot see it. It is recorded in docs/security.md and the changelog.

🤖 Generated with Claude Code

…roxy (#836)

alexander, odin and fenrir each mounted /var/run/docker.sock into Alloy. `:ro`
does not stop POST /containers/create, so that was root on three VLAN 30
hosts, two of them holding age keys, while docs/security.md named only oracle.

- each stack gets the estate's docker-socket-proxy (#193): same digest, same
  GET-only allowlist; Alloy reads the API through DOCKER_API, which
  docker.alloy already honours, and the socket mount is gone
- check_compose_health.py fails on any docker.sock mount outside the proxy
  image (four fixtures); CI runs it on every stack
- docs/security.md, the stack READMEs, README.md and architecture.md say so

oracle's agent is a `docker run` from deploy-agent.sh, outside any compose
file, and is still direct; recorded as open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 3, 2026 14:22
@Gerrrt Gerrrt added security A credential, an exposure, or a control that is weaker than recorded lab stacks/lab on alexander (VLAN 30) soc stacks/soc on odin (VLAN 30) priority/critical labels Oct 3, 2026
@Gerrrt
Gerrrt enabled auto-merge (squash) October 3, 2026 14:23
…n-out pin (#836)

check_image_pins.py refused the self-test's literal
tecnativa/docker-socket-proxy:v0.5.0@sha256:... as a pin outside
compose.yaml, which it is. The guard matches on the image prefix, so the
fixture is built from SOCKET_PROXY_IMAGE instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Retained rootfs mounts allow proxy bypass, and the guard misses /run/docker.sock mounts.

Review effort: Balanced
Findings: 2 High severity

Open (2)
What changed in this PR

Extends the estate’s Docker socket proxy approach to the lab, SOC, and sensor stacks to limit Alloy’s Docker API access.

Changes:

  • Adds pinned GET-only proxies and redirects Alloy clients.
  • Adds a Compose socket-mount guard with four fixtures.
  • Updates service inventories and security documentation.
File Description
stacks/​soc/​README.md Lists the new proxy.
stacks/​soc/​compose.yaml Adds proxy and redirects Alloy.
stacks/​sensor/​README.md Lists the new proxy.
stacks/​sensor/​compose.yaml Adds proxy and redirects Alloy.
stacks/​lab/​README.md Updates service inventory and counts.
stacks/​lab/​compose.yaml Adds proxy and redirects Alloy.
scripts/​check_compose_health.py Adds socket-mount guard and fixtures.
README.md Updates lab service count.
docs/​security.md Describes proxy coverage and remaining exposure.
docs/​changelog.md Records the change and deployment status.
docs/​architecture.md Adds alexander’s socket proxy.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/check_compose_health.py Resolved
Comment thread stacks/lab/compose.yaml Resolved
… cannot be bypassed (#836)

Review on #867 found two ways around the proxy:

- /:/rootfs:ro carries /rootfs/run/docker.sock. A read-only mount does not
  stop connect() on a socket, and Alloy runs as uid 0, the socket's owner, so
  every Alloy, the estate's behind #193's proxy included, could reach the full
  Docker API with no capability at all. /rootfs/run is now an empty tmpfs in
  all four (observability, lab, soc, sensor), and smaug's node-exporter gets
  the same at /host/run. Nothing reads /run: the journal is /var/log/journal,
  and tmpfs is excluded from the filesystem collector and from every
  host.rules.yaml rule.
- the guard matched /var/run/docker.sock only. On Ubuntu /run/docker.sock is
  the same file. It now refuses both spellings, a mount of /run or /var/run,
  and the host's / without a tmpfs over <target>/run. Ten fixtures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gerrrt added a commit that referenced this pull request Oct 3, 2026
…ay a docker run reaches the socket

The review finding on #867 applies here: deploy-agent.sh gives Alloy
-v /:/rootfs:ro, which carries /rootfs/run/docker.sock past the new proxy,
because a read-only mount does not stop connect() and Alloy is the socket's
owner. Alloy now gets --tmpfs /rootfs/run.

check_image_pins.py's socket rule now matches check_compose_health.py's: the
socket under either spelling, a mount of /run or /var/run, or the host's /
without --tmpfs over <target>/run. Nine fixtures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gerrrt added a commit that referenced this pull request Oct 3, 2026
…k every docker run for the socket (#868)

* fix(agent): put oracle's Alloy behind a Docker socket proxy, and check every docker run for the socket

oracle's Alloy is a `docker run` in deploy-agent.sh, not a compose service, so
neither #193 nor #836's compose check reached it, and it kept
/var/run/docker.sock mounted: root on the host, since `:ro` does not stop
POST /containers/create.

- deploy-agent.sh's Docker runtime starts alloy-socket-proxy beside Alloy on
  a private `alloy` network: the estate's image (image-for.sh
  docker-socket-proxy) and its GET-only allowlist. Alloy reads the API via
  DOCKER_API, and its socket mount is gone.
- check_image_pins.py refuses a socket bind in any `docker run` in the repo
  except one running an image traced to the proxy service (five fixtures under
  --self-test). Its first run found exactly this site.
- docs/security.md, add-monitored-device.md and the changelog say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(agent): mask /rootfs/run on oracle's Alloy too, and catch every way a docker run reaches the socket

The review finding on #867 applies here: deploy-agent.sh gives Alloy
-v /:/rootfs:ro, which carries /rootfs/run/docker.sock past the new proxy,
because a read-only mount does not stop connect() and Alloy is the socket's
owner. Alloy now gets --tmpfs /rootfs/run.

check_image_pins.py's socket rule now matches check_compose_health.py's: the
socket under either spelling, a mount of /run or /var/run, or the host's /
without --tmpfs over <target>/run. Nine fixtures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(ci): exempt a socket mount only when the run's IMAGE is the proxy, not when its variable appears anywhere

Review on #868: the exemption accepted a proxy-traced variable anywhere in the
arguments, so `docker run -e "$PROXY_IMAGE" -v /var/run/docker.sock:... "$IMAGE"`
passed while the collector held the socket. The rule now finds the image
operand (the first positional, past flags and their values) and exempts only
when that is the proxy. Unknown boolean flags misparse toward refusing, never
toward allowing. Four new fixtures: three decoys, and the real proxy run from
deploy-agent.sh flag for flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Gerrrt added 3 commits October 3, 2026 14:12
# Conflicts:
#	docs/changelog.md
#	docs/security.md
# Conflicts:
#	docs/architecture.md
#	docs/changelog.md
#	stacks/lab/README.md
#	stacks/sensor/compose.yaml
@Gerrrt
Gerrrt merged commit c910e50 into main Oct 3, 2026
8 checks passed
@Gerrrt
Gerrrt deleted the gerrrt/836-socket-proxy branch October 3, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lab stacks/lab on alexander (VLAN 30) security A credential, an exposure, or a control that is weaker than recorded soc stacks/soc on odin (VLAN 30)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants