/hermitd:docker-securityfrom hermitd
Applies opt-in Docker security hardening as a reversible compose overlay: LAN containment via DNS policy, resource bounds with kernel-hygiene sysctls, boot-time plugin audit log, and a credential proxy that keeps API keys outside the container.
Ships in hermitd. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Advanced hardening for already-deployed agent containers. Each toggle is opt-in, presented with honest cost/benefit framing, and applied as a docker-compose.security.yml overlay that the hermitd-docker wrapper auto-detects. Reversal: re-run and answer No to every prompt, or turn the toggles off under docker.security in config and run hermitd restart.
Tone: Honest about tradeoffs. Tell operators what each toggle does AND does not protect. Do not oversell.
Each step's commands depend on the previous step's answer, so run them in order.
Templates live in ${CLAUDE_SKILL_DIR}/../../state-templates/docker/security/.
Installing a plugin runs that plugin's hooks and skills with the same authority as hermit. The container hardening here reduces what a compromised plugin can do to the host kernel and your local network — it does not vet the plugin's intent, sandbox its file access within the project, or prevent it from acting on your behalf via the agent. A malicious or careless plugin still runs as you.
Honest limitation: DNS policy below blocks domain-based exfil/C2. In log-only mode it cannot stop direct-IP egress to a hardcoded public address; enforce mode drops connections to addresses no allowed name returned, except carve-outs.
This skill is host-only — it writes a docker-compose.security.yml overlay on the host and recreates the container with stronger isolation.
Run: [ -f /.dockerenv ] || [ -f /run/.containerenv ] && echo container || echo host
If the output is container, stop immediately — do not proceed to step 1. Print:
Run
hermitd setup docker-securityfrom a host terminal at the project root. To inspect live security inside the container, run/hermitd:hermit-doctor.
For every direct Compose command, rebuild COMPOSE_FILES immediately before use in the same Bash call:
COMPOSE_FILES=(-f docker-compose.hermit.yml)
[ ! -f docker-compose.security.yml ] || COMPOSE_FILES+=(-f docker-compose.security.yml)
[ ! -f docker-compose.override.yml ] || COMPOSE_FILES+=(-f docker-compose.override.yml)
Use docker compose "${COMPOSE_FILES[@]}": base, security overlay, then operator override. Re-evaluate after writing either overlay.
Read .hermit/config.json. If missing: "Run /hermitd:hatch first." Stop.
Verify docker-compose.hermit.yml exists at the project root. If missing: "Run /hermitd:docker-setup first." Stop.
Docker daemon check: run timeout 10s docker info >/dev/null 2>&1. If it fails or times out: tell the operator "Docker daemon is not reachable or timed out. Start Docker before re-running /docker-security." Stop.
Read docker.network_mode from config (default: "bridge"). If "host", set HOST_NETWORK_MODE=true and surface to operator: "Detected network_mode: host in your config. The LAN containment toggle (Prompt 1) will be skipped — it would replace host mode and break your HA / host-bound service access. Resource bounds (Prompt 2) will not apply network sysctls in host mode either; Docker rejects them and the container would fail to start."
Detect hermit ports: run timeout 10s docker compose "${COMPOSE_FILES[@]}" config --format json 2>/dev/null and parse .services.hermit.ports. Store as in-memory detected_hermit_ports (array of long-form Compose port objects: {target, published, host_ip, protocol, mode}). If the command fails or returns no JSON, scan the selected Compose files for ports: keys and set detected_hermit_ports_unparsed=true if found. Either way, a non-empty result means ports are present.
Check whether the container is currently running: docker compose "${COMPOSE_FILES[@]}" ps --status running --format '{{.Service}}' 2>/dev/null | grep -x hermit. If absent, tell the operator "The wizard will write the overlay. Start the container with hermitd start --build before live verification."
Read current docker.security.* from config.json. Also read sandbox.enabled from the target settings file (same hatch_target routing as hatch/docker-setup: hatch_target == "local" → .claude/settings.local.json; else → .claude/settings.json) — display only, hermit does not configure this key. Print a "current posture" summary. Example:
Current security posture:
LAN containment: off
Resource bounds: off
Audit log: off
Credential proxy: off
Baseline (always on):
cap_drop: ALL, no-new-privileges, pids_limit: 2048
Sandbox (bash tool isolation, operator-managed via /sandbox):
enabled: true (or: false / not configured)
Print the trust-model paragraph from the top of this file (the blockquote). Then continue.
If HOST_NETWORK_MODE is true, do not present this prompt. Tell the operator: "Skipping LAN containment — incompatible with network_mode: host. Run /hermitd:docker-setup to switch to bridge mode if you want this hardening." Continue to step 4.
Otherwise, ask with AskUserQuestion (header: "LAN containment"):
question: "Add LAN containment with DNS policy? (firewall sidecar + DNS allowlist)"
options:
- label: "Yes — recommended (LAN block + DNS log-only)"
description: "Blocks RFC1918 + cloud metadata. DNS in log-only mode: allows everything, logs blocked queries for tuning."
- label: "Yes — strict (LAN block + DNS enforce)"
description: "Same LAN block. DNS returns NXDOMAIN for any domain not on the allowlist, and connections go only to addresses those domains resolved or to carve-outs."
- label: "No"
description: "Skip this toggle."
Map: "Yes — recommended" → dns_mode: "log-only". "Yes — strict" → dns_mode: "enforce". "No" → skip to step 4.
If the operator selected a "Yes" option AND detected_hermit_ports is non-empty (or detected_hermit_ports_unparsed=true), surface a follow-up AskUserQuestion (header: "Port publishing") immediately:
Your merged Compose stack publishes ports on the hermit service:
- "3000:3000" ← list each port if parsed, or "(port block detected)" if unparsed
...
LAN containment requires hermit to share hermit-netguard's network namespace.
Docker forbids `ports:` on a container that joins another container's netns —
only netguard (the netns owner) can publish ports.
Options:
"Move ports to netguard (recommended)" — render the same ports: block on hermit-netguard in the overlay. Persist to docker.security.network.publish_ports. After overlay is written (step 6), show a diff and use the Step 7 override auto-fix to clear services.hermit.ports; never edit the generated base file."Skip LAN containment (keep ports on hermit)" — clear the LAN containment selection (treat as if operator answered No above). Set lan_containment_skipped_due_to_ports=true. Continue to step 4."Cancel" — print "Re-run /docker-security after deciding how to handle your port publishing. See docs/docker-security.md for guidance." Exit. Write nothing.If operator chose "Skip LAN containment": proceed to step 4 without any LAN containment config. Step 9 final-report notes: "LAN containment skipped — docker-compose.hermit.yml has a ports: block on hermit that is incompatible with network_mode: service:hermit-netguard."
Scan installed fleet plugins. From the host:
bun ${CLAUDE_PLUGIN_ROOT}/scripts/resolve-siblings.ts "$(pwd)" --role siblings
It emits a JSON array of the project-or-local + enabled hermit siblings (each carrying plugin, installPath), already excluding user-scope, disabled, cross-project, and hermitd itself.
For each entry:
installPath field from the JSON.<plugin>/skills/hatch/SKILL.md and look for a ## Docker network requirements heading. Also check <plugin>/DOCKER.md. Stop at the next ## heading.### Domains (DNS allowlist) — bullet entries are domain names. Validate against ^[a-z0-9][a-z0-9.-]+$. Reject failing entries with a warning.### LAN allowlist suggestions — bullet entries are either IPv4 CIDRs (validate with regex) OR the special token ASK_OPERATOR_FOR_HA_IP (or other ASK_OPERATOR_FOR_*_IP patterns). Reject failing CIDRs.If the deduped fleet list is non-empty, present plain text first:
Fleet plugins request these network exceptions:
api.strava.com — hermitd-fitness (DNS)
www.strava.com — hermitd-fitness (DNS)
ASK_OPERATOR_FOR_HA_IP — hermitd-homeassistant (LAN, will prompt for IP)
Then ask once with AskUserQuestion (header: "Fleet network entries"):
"Include all" (Recommended)"Pick each""Skip all"On "Pick each": loop through each entry with a 2-option AskUserQuestion ("Include" / "Skip").
For every confirmed ASK_OPERATOR_FOR_HA_IP (or similar): immediately follow up with AskUserQuestion (header: "<plugin> IP") — Other field accepting an IPv4 address or CIDR. Validate. Re-prompt on invalid. Replace the token with the typed value.
Confirmed entries are added to in-memory fleet_lan_allowlist and fleet_domains for step 6.
If the fleet list is empty: skip silently.
In enforce mode a carve-out is also how a literal public IP, or the IP behind a pinned hostname, is allowed.
AskUserQuestion (header: "Extra LAN carve-outs"):
"None""Add IPs/ranges" (Other field, comma-separated, IPv4 CIDR validated; re-prompt on invalid)Persist to lan_allowlist (combined with fleet_lan_allowlist).
First offer the project's remote MCP servers:
bun ${CLAUDE_PLUGIN_ROOT}/scripts/render-security-overlay.ts mcp-hosts <PROJECT_ROOT>
It prints { "hosts": [{ "host", "server" }] }. When the list is non-empty, show each host with its server name and ask once (header: "MCP hosts") with the same "Include all" (Recommended) / "Pick each" / "Skip all" flow as 3a. Confirmed hosts join additional_domains.
In enforce mode, also offer the hosts mapped for the credential proxy: run hermitd credproxy status (a host terminal command; skip silently if it fails) and offer each host from its bindings with the same flow. Mapping a host never adds it to the allowlist by itself.
Channel and voice-note hosts are not asked here: the render adds them from config.json for enabled channels and while transcription is enabled.
AskUserQuestion (header: "Extra domains"):
"None (use defaults + fleet)""Add domains" (Other field, comma-separated, domain regex validated; re-prompt on invalid)Persist to additional_domains (combined with fleet_domains).
docker.security.network = {
"enabled": true,
"dns_mode": "log-only" | "enforce",
"lan_allowlist": ["192.168.1.50", ...],
"additional_domains": ["api.strava.com", ...]
}
AskUserQuestion (header: "Resource bounds"):
question: "Set memory and CPU caps + network kernel hardening sysctls?"
options:
- label: "Yes — defaults (mem 4g, cpus 2.0, sysctl bundle)"
description: "Caps a runaway agent's resource cost; sysctls disable ICMP redirect / source-routing tricks."
- label: "Yes — custom mem/cpu"
description: "Pick your own memory and CPU limits."
- label: "No"
description: "Skip this toggle."
On "Yes — custom mem/cpu": follow up with AskUserQuestion (header: "Custom limits") — Other field accepting two values, comma-separated. Validate mem against ^[0-9]+(g|m)?$, cpus against ^[0-9.]+$. Re-prompt on invalid.
Sysctl placement note:
HOST_NETWORK_MODE is true: silently set sysctls_enabled = false regardless of choice and tell the operator: "Network sysctls cannot be applied with network_mode: host — Docker rejects them. Resource bounds (mem/cpus) will still apply if you said Yes."sysctls_enabled = true.Persist:
docker.security.resources = {
"enabled": true,
"mem_limit": "4g",
"memswap_limit": "4g",
"cpus": 2.0,
"sysctls_enabled": true|false
}
AskUserQuestion (header: "Audit log"):
question: "Record every boot-time plugin install to a JSONL audit log?"
options:
- label: "Yes — recommended"
description: "Appends one JSONL line per `claude plugin install` performed by the entrypoint to .hermit/state/plugin-installs.jsonl. Honest scope: post-boot installs run via tmux are not captured. The log is empty until something actually installs — on subsequent boots when the marketplace + plugin set is unchanged, no install fires and no entry is written. That's normal, not a failure."
- label: "No"
description: "Skip this toggle."
Persist docker.security.audit.plugin_installs accordingly.
If HOST_NETWORK_MODE is true, do not present this prompt. Tell the operator: "Skipping the credential proxy: not available with network_mode: host." Continue to step 6.
Otherwise, ask with AskUserQuestion (header: "Credential proxy"):
question: "Keep API credentials for chosen hosts outside the agent's container?"
options:
- label: "Yes"
description: "A sidecar adds the real header to the agent's shell HTTPS requests to hosts you map from a host terminal. The agent can still use a mapped credential on its host; it cannot read it."
- label: "No"
description: "Skip this toggle."
Persist docker.security.credential_proxy.enabled. On Yes, run hermitd credproxy status and show its bindings. Never ask for, read or print a secret value; the operator sets values in a host terminal (step 9).
Browser viewer publishing: When browser.port is set and LAN containment is on, keep exactly one {target: 6080, published: "<port>", host_ip: "127.0.0.1", protocol: "tcp"} in publish_ports on netguard. After persisting config, run bun "${CLAUDE_PLUGIN_ROOT}/scripts/render-docker-templates.ts" <project-root> and check its verdict before recreating. Enabled LAN containment makes the renderer omit the base browser mapping. On a skipped or error verdict, stop and follow the renderer reason before proceeding. Never publish the same viewer in both services. With containment off, base rendering owns it. Host networking uses the loopback bind environment.
Before rendering — preserve publish_ports across reruns:
Read docker.security.network.publish_ports from the existing config.json (if present). Keep this as persisted_publish_ports. In the current wizard run:
persisted_publish_ports with the newly detected ports from step 5 (prerequisites).persisted_publish_ports unchanged (the override already clears hermit ports; do not lose the netguard mapping).persisted_publish_ports = [] (LAN containment is off; ports stay on hermit in the merged stack).All-off branch — warn before deletion if publish_ports was set:
Otherwise (all toggles off, the credential proxy included): before deleting the overlay, check if persisted_publish_ports is non-empty. If so, surface:
Heads up: turning all toggles off will remove the overlay, including these
ports that hermit-netguard currently publishes:
- "3000:3000"
...
Restore the hermit ports in docker-compose.override.yml before bringing
the container back up; remove a hermit ports reset if needed.
The security overlay will no longer publish them.
Then AskUserQuestion (header: "Confirm all-off"):
"Yes — proceed (I'll restore override ports if needed)""No — cancel"On Yes: clear docker.security.* except managed_ceiling, run the 6b render (its disabled verdict removes the overlay and netguard files), tell the operator "All toggles off: overlay removed and config cleared." Skip to step 9.
On No: exit wizard, write nothing.
If persisted_publish_ports is empty: proceed directly to deletion without the prompt.
Subnet auto-detection (only if LAN containment is enabled):
Run pick-subnet — it enumerates occupied Docker subnets, excludes this project's own hermit-net, integer-range-checks overlap, walks the 8 fixed /24 candidates, and always exits 0 (probe pattern):
bun ${CLAUDE_PLUGIN_ROOT}/scripts/render-security-overlay.ts pick-subnet <PROJECT_ROOT>
It prints { "chosen": { "subnet", "gateway", "netguard_ip" } | null, "all_candidates_collide": bool }.
chosen is non-null, use it.all_candidates_collide is true, AskUserQuestion (header: "Custom subnet") with an Other field for an IPv4 /24 CIDR. Validate each answer with one cheap re-run:
bun ${CLAUDE_PLUGIN_ROOT}/scripts/render-security-overlay.ts pick-subnet <PROJECT_ROOT> --candidate <cidr>
chosen: null means still colliding or not a /24 — re-prompt. chosen set means accepted.Persist the chosen values to docker.security.network (subnet, gateway, netguard_ip from chosen), alongside enabled, dns_mode, lan_allowlist, additional_domains, publish_ports. If LAN containment is not enabled, omit subnet, gateway, netguard_ip.
If at least one toggle is enabled, render the overlay. Otherwise (all-off): handled in the all-off branch above.
Render 100 directly into nftables.conf as the dnsmasq UID — no probe step. Rationale and recovery path if Alpine ever changes it: see docs/docker-security.md#design-rationale.
The host lifecycle renders these files from config and builds hermit-netguard before every start, so a plain hermitd restart applies them.
With config persisted, render once:
bun ${CLAUDE_PLUGIN_ROOT}/scripts/render-security-overlay.ts render <PROJECT_ROOT>
It reads docker.security from .hermit/config.json, validates every value, and writes docker-compose.security.yml plus .hermit/docker/{Dockerfile.hermit-netguard, netguard-entrypoint.sh, nftables.conf, dnsmasq.allowlist} (domain lines include enabled channels' and voice-note hosts; the operator's .hermit/docker/dnsmasq.hermit-local.conf lines go above the catchall). Verdicts:
{ "status": "rendered", "written": [...] }: continue.{ "status": "disabled", "removed": [...] }: no toggle is on; the files are gone.{ "status": "skipped", "reason": "incomplete_config" }: LAN containment is on without a subnet; return to subnet detection.{ "error": "invalid_value:<path>" }: fix that config value and re-render.The script places sysctls on netguard when LAN is on, on hermit when LAN is off (Prompt 2 only). If base ports were detected via the grep fallback (detected_hermit_ports_unparsed=true) with no parsed shape, persist publish_ports: [] and tell the operator: "Could not parse port shapes from the compose config. Configure docker.security.network.publish_ports, run hermitd restart, then clear services.hermit.ports in docker-compose.override.yml using the Step 7 procedure."
Print a one-screen summary of files written (paths + line counts). Ask AskUserQuestion (header: "Apply") — "Yes — restart container now" / "No — I'll restart manually later".
On "No — I'll restart manually later", skip to step 9. Tell the operator the overlay is written and to run hermitd restart --build in their terminal when ready to review and apply it. They can open the wizard again with hermitd setup docker-security.
Hard gate — re-check merged ports before starting:
Before asking for terminal approval, re-run the step 5 port detection with timeout 10s docker compose "${COMPOSE_FILES[@]}" config --format json 2>/dev/null | bun -e 'const d=JSON.parse(require("fs").readFileSync(0,"utf8")); console.log((((d.services ?? {}).hermit ?? {}).ports ?? []).length)'. If the result is non-zero (or the command output from the grep fallback is non-empty) AND docker.security.network.enabled === true (LAN containment is on):
Ask with AskUserQuestion (header: "Ports conflict"):
"Auto-fix — I'll clear hermit ports in the override (backup first)" (Recommended)"I'll edit it myself — pause here"On "Auto-fix": Back up an existing docker-compose.override.yml to a timestamped .bak under .hermit/state/. Preserve its operator content and set services.hermit.ports: !reset [] in that override (replace its existing ports key rather than duplicating it). Never write docker-compose.hermit.yml. Rebuild COMPOSE_FILES, then run docker compose "${COMPOSE_FILES[@]}" config -q and confirm the merged hermit service has no ports. On failure, restore the override backup (or remove only the newly created override) and stop with the error. Print: "Hermit ports cleared through docker-compose.override.yml; netguard publishes them through the security overlay." Continue to the restart sequence below.
On "I'll edit it myself": Print:
Cannot start container: the merged hermit service still publishes ports.
Set services.hermit.ports: !reset [] in docker-compose.override.yml,
then validate the merged stack and run hermitd start.
Stop here. Tell the operator the overlay and config have been written and the override must clear the conflicting hermit ports.
If the operator chose to restart now and the port check passed, tell them "Run hermitd approve in your terminal, review the changes, then tell me whether you approved them." Wait for their reply. If they decline, stop and report that the overlay is still pending.
hermitd restart --build if the container was running. If it was stopped, run hermitd start --build. Wait for the build and surface any failure before proceeding.bun "${CLAUDE_PLUGIN_ROOT}/scripts/lib/compose-files.ts" "$(pwd -P)" "" ps --status running --format '{{.Service}}' every 2s for up to 30s. Expect hermit, hermit-netguard if Prompt 1 was enabled, and hermit-credproxy if Prompt 4 was enabled. If a service is missing, run hermitd docker logs --tail=30 <missing-service>, surface the output, and suggest:
ports: conflict was fully resolved (re-run the hard gate port check above)docker info to confirm daemon is healthy
Then stop.Stream the static verification script into the live container. It is placeholder-free (hardcoded probe values) and uses only tools the hermit base image ships — bun, jq, curl, glibc getent (no python3, nc, or nslookup):
bun "${CLAUDE_PLUGIN_ROOT}/scripts/lib/compose-files.ts" "$(pwd -P)" "" \
exec -T hermit sh -s < "${CLAUDE_PLUGIN_ROOT}/state-templates/docker/security/verify-security.sh"
Surface the output to the operator. Suggest: "Run /hermitd:hermit-doctor to also verify the docker-security check shows green."
Print a brief summary:
docker-security applied — current posture:
LAN containment: on (DNS log-only) | LAN carve-outs: 192.168.1.50
Resource bounds: on (mem 4g, cpus 2.0)
Audit log: on
Credential proxy: on (2 mapped hosts)
Reverse: re-run /docker-security and answer No to every prompt, OR
turn the toggles off under docker.security in config, then `hermitd restart`.
Tune DNS allowlist: add domains to docker.security.network.additional_domains
or lines to .hermit/docker/dnsmasq.hermit-local.conf, then `hermitd restart`.
When the credential proxy is on, also print the host terminal commands, run from the project folder, with the operator's own host, header and secret names:
hermitd credproxy map <host> --header <Header-Name> --secret <name> [--prefix "Bearer "] [--basic-user <user>]
hermitd credproxy set <name> (typed, not shown)
hermitd credproxy status
hermitd restart
Add one line: "After mapping a credential, remove it from the project .env; the agent's shell then sends a placeholder and the proxy adds the real value."
Reversal, limitations, DNS allowlist tuning, and design rationale: see docs/docker-security.md.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub gtapps/hermitd --plugin hermitd41 skills in this plugin
/briefReturns a 5-line executive summary of recent work. Checks open records first, then recent task outcomes. Activates on messages like "brief", "what happened", "morning update", "overnight summary", "progress", "what are you working on", "how's it going"./browserDrives the agent's own browser, or the operator's Chrome for their accounts. Use before giving steps that send someone to a web console to create or change something on an account (an API key, a bot, an app registration), even when the person will do them by hand or no browser is available. Also use when WebSearch fails, or when WebFetch cannot read a page: it is refused (such as 402 or 403), stays rate-limited after a retry, times out, or returns an empty page, a JavaScript-only shell, or a block notice in place of the content asked for. Use it before answering from other sites or searches, above all when the person named or linked the page, even if the browser may be off. Also use when a page needs clicks, forms, scrolling or sign-in; or when a screenshot or exact rendered text is needed. Public read-only lookups start with WebSearch or WebFetch./capability-brainstormMonthly routine plus on-demand hermit-voice brainstorm — synthesizes memory, capabilities, recent artifacts, and codebase shape into at most 2 capability ideas, each gated by proposal-triage before becoming a proposal task. Runs on the capability-brainstorm routine and when the operator asks to brainstorm capabilities or ideate, e.g. "brainstorm capabilities", "any capability ideas?"./channel-accessManage chat access. Let someone talk in a chat, remove them, see who can talk here, open a chat to everyone, turn a chat off, or remove someone who is no longer an approver./channel-responderHandles inbound messages tagged <channel source=...> from Claude Code Channels, routing replies, task work, approvals, and operator controls with session context./channel-setupGuided channel activation for local/tmux users; adds a channel entry when none is configured, installs the plugin, configures the bot token in the project-local state dir, and walks through pairing. Run after hatch, or any time to add or re-enable a channel.Other plugins' skills for the same job