Skip to content

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

Merged
Gerrrt merged 4 commits into
mainfrom
gerrrt/oracle-socket-proxy
Oct 3, 2026
Merged

Gerrrt merged 4 commits into
mainfrom
gerrrt/oracle-socket-proxy

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Oct 3, 2026

Copy link
Copy Markdown
Owner

What changed

  • scripts/deploy-agent.sh's Docker runtime starts alloy-socket-proxy beside Alloy, on a private alloy network.
    • The image comes from image-for.sh docker-socket-proxy, the estate's, and the allowlist is the estate's flag for flag: CONTAINERS, IMAGES, INFO, VERSION, EVENTS and NETWORKS are 1, and POST and everything else are 0.
    • Alloy gets DOCKER_API=tcp://alloy-socket-proxy:2375 and loses its socket mount.
    • Both containers are recreated on every run, so a redeploy is idempotent.
  • scripts/check_image_pins.py refuses a socket bind in any docker run in the repository's scripts, Makefile, workflows or runbooks, unless that run's image is traced to the proxy service.
    • The match is by image, not by variable name, so renaming a variable is not a way around it.
    • Five fixtures run under --self-test, which self-tests.sh discovers.
  • Docs: docs/security.md, add-monitored-device.md and the changelog.

Why

Found while fixing #836 (PR #867). #193 moved the estate's Alloy behind the proxy, and #836 moves the lab's three. oracle's Alloy is started by deploy-agent.sh as a single docker run, outside any compose file, so check_compose_health.py could not see it. It kept /var/run/docker.sock mounted. :ro does not stop POST /containers/create, so that was root on oracle.

Blast radius

oracle only, at its next deploy-agent.sh --runtime docker run. Merging changes nothing that is running. Native hosts (Saruman, phoenix) take a different branch and are untouched.

The failure to watch for is the one #193 measured: a too-narrow allowlist collects less without erroring. After the redeploy, check loki_source_docker_target_entries_total{host="oracle"}.

Expect a small conflict with #867 in the docs/security.md paragraph about who still holds the socket. Both PRs rewrite it; keep both halves.

  • No change to network segmentation or firewall rules
  • No new port published. The proxy is on a private bridge with no -p.
  • No credential added outside secrets/*.sops.yaml

Verification

  • check_image_pins.py --self-test: all 5 fixtures pass.
  • Before the fix, check_image_pins.py flagged exactly one site, deploy-agent.sh's Alloy run. After it: 52 invocations, all clean.
  • shellcheck, check_docs.py and markdownlint all pass.
  • Not run: a real deploy. There is no Docker here, and the redeploy against oracle is the operator's:
./scripts/deploy-agent.sh --runtime docker <user>@oracle
  • make validate passes (CI)
  • Deployed to oracle. docker logs alloy-socket-proxy shows no 403s, and oracle's container logs still arrive in Loki.

🤖 Generated with Claude Code

…k 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>
Copilot AI balanced review requested due to automatic review settings October 3, 2026 14:25
@Gerrrt Gerrrt added security A credential, an exposure, or a control that is weaker than recorded priority/critical labels Oct 3, 2026

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

The socket guard can be bypassed by placing the proxy image variable in a non-image argument.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Adds a Docker socket proxy for oracle’s Alloy agent and guards against unsafe socket mounts.

Changes:

  • Runs Alloy and its proxy on a private Docker network.
  • Adds repository-wide socket-mount validation and self-tests.
  • Updates security, runbook, and changelog documentation.
File Description
scripts/​deploy-agent.sh Deploys the proxy and routes Alloy through it.
scripts/​check_image_pins.py Adds socket-bind validation and fixtures.
docs/​security.md Documents oracle’s proxy protection.
docs/​runbooks/​add-monitored-device.md Updates deployment architecture.
docs/​changelog.md Records the security change.

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

Comment thread scripts/check_image_pins.py Resolved
…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

Gerrrt commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

Pushed the #867 review finding here too. -v /:/rootfs:ro carried /rootfs/run/docker.sock past the new proxy, because a read-only mount does not stop connect() and Alloy owns the socket. Alloy now gets --tmpfs /rootfs/run. check_image_pins.py's socket rule also matches the compose check now: the socket under either spelling, its directory, or an unmasked host /, with nine fixtures. After the redeploy on oracle, verify that docker exec alloy test -S /rootfs/run/docker.sock fails and that container logs still arrive.

🤖 Generated with Claude Code

@Gerrrt
Gerrrt enabled auto-merge (squash) October 3, 2026 15:11
Gerrrt and others added 2 commits October 3, 2026 08:11
…, 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>
@Gerrrt
Gerrrt merged commit 8a854e1 into main Oct 3, 2026
8 checks passed
@Gerrrt
Gerrrt deleted the gerrrt/oracle-socket-proxy branch October 3, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security A credential, an exposure, or a control that is weaker than recorded

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants