Repository navigation
feat: isolate agent runtime and restrict egress - #3
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b862d5d78c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Maintainer review hold: the current appliance runs OpenClaw under the same principal that can mutate the nftables policy (root or passwordless sudo), so a compromised agent can remove or rewrite the proposed egress boundary. The I prepared and tested narrower idempotency, persistence, rollback, and reconvergence fixes locally, but did not push them because they would still imply a security boundary the appliance does not provide. The PR needs an architectural revision: run the agent as a separate unprivileged user, keep network policy ownership outside that principal, and gate boot/readiness on the live enforced ruleset. The two existing review threads remain unresolved until that redesign lands. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32e6a1f935
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /bin/bash "$agent_work/bundle/guest-install.sh" | ||
| "\${egress_privileged[@]}" /bin/rm -rf "$agent_work" |
There was a problem hiding this comment.
Clean the agent workdir on failed installs
If guest-install.sh exits nonzero in this production path, set -e aborts before this cleanup runs, leaving $agent_work/credentials.env and the managed spec under /var/lib/crabhelm-agent/bootstrap-$$. That file contains the model/provider credential plus the short-lived runtime token; add a trap or cleanup before invoking the agent install so failed package/policy installs do not persist copied credentials in the agent home.
Useful? React with 👍 / 👎.
| CRABHELM_CREDENTIAL_FILE="$agent_work/credentials.env" \ | ||
| CRABHELM_MANAGED_SPEC_FILE="$agent_work/managed-spec.json" \ | ||
| CRABHELM_POLICY_HASH="$CRABHELM_POLICY_HASH" \ |
There was a problem hiding this comment.
Preserve the credential refresh env for agent install
In the root appliance path this run_as_agent invocation is the only environment passed to guest-install.sh, but it omits CRABHELM_CREDENTIAL_REFRESH_URL and CRABHELM_BOOTSTRAP_TOKEN; checked /usr/sbin/runuser --help, and inherited environment is reset unless --preserve-environment is used. As a result the refresh block in guest-install.sh is skipped, so a slow offline npm/plugin install can write the originally fetched 10-minute runtime token after it has expired and the runtime bridge will fail to authenticate.
Useful? React with 👍 / 👎.
What
Crabhelm now installs the OpenClaw runtime under a dedicated, unprivileged
crabhelm-agentsystem account and applies a root-owned nftables policy before any credentials are delivered.The policy is scoped to the agent UID, so bootstrap, SSH, and other host services remain reachable. Agent egress is limited to loopback, DNS, NTP, DHCP, IPv6 neighbor discovery, and TCP 443; IPv4 and IPv6 instance-metadata endpoints are denied explicitly, followed by a final agent-UID drop.
Security model
requiredis the default and unknown values fail closed;offis the explicit escape hatch.MainPIDbelongs to the isolated account.Testing
pnpm check: 144 Node tests and 16 workerd/Vitest tests green, plus TypeScript, Worker bundle, and Wrangler dry-run checks.MainPIDowned by the isolated UID; no agent sudo; live nft rules verified; IMDS and plain HTTP denied for the agent; HTTPS allowed; host plain HTTP and the SSH control path remained reachable.This supersedes the original host-global, fail-open proposal. It now provides an actual privilege boundary without risking loss of appliance management access.