swarmexec

swarmexec › Docs › TUI: the security-risks overlay

TUI: the security-risks overlay_

Eight checks over every service spec, and what they flag.

Security risks (!)

Every time the service list is fetched, swarmexec runs a set of small static analyzers over each service's spec — the same spec the manager already returned, so there is no extra API call, no agent involvement and nothing is executed inside your containers. A service with a finding worth acting on is marked with a leading 🛡 in the service tree, in a fixed-width slot ahead of the name, so the shields line up as a vertical scan column. Press ! to open the security-risks overlay, and w inside it to write a cluster-wide Markdown report — which covers more than the overlay does, since it adds the checks that belong to the cluster rather than to a service.

The checks

The eight checks that ship today. The ones that can mark a service come first; the purely informational ones are grouped at the end:

CheckSeverityWhat it flags
docker-socket — “Docker socket mounted in”highthe most serious finding here. A bind mount whose source is the Docker daemon socket — /var/run/docker.sock, /run/docker.sock or any source path ending in /docker.sock. Anything in that container can talk to the socket, and anything that can talk to the socket can start a privileged container on that node — so it is effectively root on the host, whatever the container itself runs as. Read-only does not mitigate it: the socket is an API, not a file whose contents matter — the finding says so itself when the mount is read-only. It names the target path the socket is mounted at
added-capability — “capability NAME added”high / mediuma Linux capability the service adds to its container. Swarm has no --privileged, so capabilities are how a service asks for extra host power — which makes the added set worth reading. Eight are high, each reported with the reason it carries: ALL (grants every capability), SYS_ADMIN (near-root: mount, namespace and cgroup control), SYS_MODULE (can load kernel modules), SYS_PTRACE (can inspect and control other processes), SYS_RAWIO (raw I/O access to devices), DAC_READ_SEARCH (bypasses file read permission checks), NET_ADMIN (full control of the node's networking), NET_RAW (can forge and sniff raw packets). Any other added capability is medium — a privilege beyond the default set. One finding per added capability; both spellings are recognised, in any case (CAP_SYS_ADMIN and SYS_ADMIN)
host-network — “runs on the host network”highthe service is attached to the network named host — or, on a deployed service, to the network id of a host-driver network, which is how the manager may store it: the container shares the node's network stack, so there is no network isolation and swarm's published-port mapping no longer applies. It can reach anything the node can — including services bound to localhost, which are usually assumed to be out of a container's reach
unconfined — “seccomp disabled” / “AppArmor disabled”highthe container's kernel-level sandbox has been switched off: seccomp set to unconfined — the container may make any syscall, which removes the main barrier to kernel exploits — or AppArmor confinement disabled. The two are reported separately, so a service that turns off both gets two findings
root-user — “runs as root”highthe spec pins the container to root explicitly — User=root or uid 0 (numeric forms like 00 or +0 are caught too; only the user part of user:group is looked at)
secret-in-env — “secret in environment variable”higha credential-looking env key holds a literal value in the service spec, readable by anyone who can read the spec. Use a Docker secret or the *_FILE convention instead
root-user — “no user set”lowno user is set at all, so the container runs as the image's own default user, which is often root. Informational only, and it does not mark the service: an unset user is the Swarm default on nearly every service, and whether it really is root depends on the image's USER, which the manager spec doesn't reveal
no-resource-limits — “no resource limits”lowthe task sets neither a CPU nor a memory limit, so a runaway container can consume the whole node and starve everything else on it. Informational only — see below
unpinned-image — “image not pinned”lowthe image is pinned to :latest, or carries no tag at all (which resolves to :latest) — the running version can change without a spec change, so a deploy is not reproducible. A digest-pinned image (…@sha256:…) is exactly reproducible and is never flagged, and a colon that belongs to a registry host's port (registry:5000/img) is not mistaken for a tag. Informational only — see below

Why the informational checks never mark a service. Only a finding above low — high or medium — makes a service actionable and puts the 🛡 on its tree row. The low ones (no-resource-limits, unpinned-image and root-user's “no user set”) are true of almost every service in a real cluster: badging them would put a shield on nearly every row and destroy the at-a-glance signal the marker exists for. They are not swept under the rug, though — once a service is flagged for something else, its low findings are listed with the rest in the overlay, so you see them where they are actually worth reading.

No secret value is ever displayed. Of the eight checks only secret-in-env looks at environment variables at all, and its finding names only the env var's key; the value is never read into the finding, never rendered and never copied. The check is also written to stay quiet: it matches whole _-delimited tokens (PASSWORD, PASSWD, PASS, PASSPHRASE, SECRET, TOKEN, APIKEY, CREDENTIAL(S), PRIVATEKEY, and the pairs API_KEY, ACCESS_KEY, PRIVATE_KEY, SECRET_KEY, CLIENT_SECRET, AUTH_TOKEN), so COMPASS, PASSENGER_PORT or BYPASS_AUTH are not reported. Keys that merely reference a credential are exempt (_FILE, _PATH, _URL, _URI, _NAME, _ID, _TYPE, _ENABLED, _REQUIRED, _LENGTH, _TIMEOUT, _TTL, _EXPIRY, _ALGORITHM), and so are values that plainly aren't a credential — an absolute path, a boolean, a number.

The overlay

The overlay lists every flagged service (“N of M service(s) flagged · 8 checks”), grouped by service, each finding on its own line with a severity dot — ● high, ● medium, ● low — a short title and a one-line explanation. Findings are ordered worst-first. Once a service is flagged for something actionable, its informational low findings are listed too. If the service under the cursor is among them it is pre-highlighted and scrolled into view. When nothing is flagged the overlay says so explicitly and names every check that ran (“Checked: Docker socket mounted in, added Linux capabilities, host network, seccomp / AppArmor disabled, container user, secrets in environment variables, missing resource limits, unpinned image.”), so an all-clear tells you what it actually covers; when the service list hasn't loaded yet it says nothing has been scanned rather than giving a false all-clear. j/k scroll, Esc (or q, or ! again) closes.

The scan is an extensible registry of analyzers, not a fixed list: a new check surfaces in both the tree marker and the overlay automatically. The overlay's own wording comes from that registry too — the check count in its header and the “Checked:” list are generated from the analyzers themselves, so they cannot drift from what actually ran the way a hardcoded list does. The key is remappable as security_risks in keys.yaml.