Skip to content

Reduce Alloy's privilege — it is root on the host and can read the age key #188

Description

@Gerrrt

#71 raises this in one clause and it is the largest thing in the file:

alloy:
  privileged: true
  cgroup: host
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock:ro
    - /:/rootfs:ro

privileged: true plus the Docker socket is root on the host — the socket alone
is enough to start a container with / bind-mounted read-write. And /:/rootfs
is read access to every file on the host, including
~/.config/sops/age/keys.txt, which is the single point of failure for every
secret in this repository, on an unencrypted disk.

Everything else in #71 is rounding error next to this. It is also why the other
hardening issues (#186, #187) deliberately exclude Alloy: a cap_drop next to a
privileged: true is a control that cannot act.

Why this is not a quick change

cgroup: host is required — compose.yaml explains at length that without
it cAdvisor reports exactly one series, id="/", and every per-container metric
disappears while the exporter stays healthy and the dashboard stays empty. That
is the #62 failure and it is silent, which is what makes this risky rather than
merely fiddly.

privileged: true may not be required. The documented minimum for the
cAdvisor + Docker pattern is closer to:

  • cap_add: [SYS_ADMIN, SYS_PTRACE, DAC_READ_SEARCH]
  • device_cgroup_rules for the block devices cAdvisor stats
  • security_opt: ["apparmor:unconfined"] on some hosts

and the socket could go behind a read-only proxy (e.g. a docker-socket-proxy
exposing only GET /containers, /images, /info) rather than being mounted
directly.

Done when

  • Alloy runs without privileged: true, or it is written down why it cannot
  • container_* series count and the Docker Containers dashboard are compared
    before and after — the failure mode here is silence, not an error
  • The four rules in containers.rules.yaml that depend on cAdvisor still
    have data
  • docs/security.md and SECURITY.md updated, since both currently list
    the read-only socket as the mitigation

Prerequisite for getting real value out of #186 and #187.

Found while doing #71 / #184.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions