Containerized defense-in-depth runtime for OpenClaw with policy-based egress control, prompt scanning, and command gatekeeping.
- Core stack is functional and starts with
make start. - OpenClaw gateway is exposed on
http://localhost:18789. - Firewall scope is intentionally limited to
openclaw-agentcontainer traffic. - Prompt scanner endpoint is active at
POST /scan. - Exec gatekeeper endpoint is active at
POST /scan_exec. - Domain approval monitor parses HAProxy 403 request lines and can whitelist blocked domains interactively.
- Containerized test suite and pre-commit enforcement are configured.
Services:
openclaw-agent: OpenClaw runtime, channels, model routing.inspector-api: FastAPI policy service (/health,/scan,/scan_exec,/approve_domain).ai-gateway: HAProxy egress gateway and runtime host ACL check.security-brain: local Ollama backend for risk classification.
Primary trust boundaries:
openclaw-agentegress is routed viaai-gateway.- Host-native apps (Cursor/extensions/browser/shell) are not routed through
ai-gateway. - Policy decisions are centralized in
inspector-api.
- Docker Desktop or Docker Engine + Compose plugin
make- provider keys in
.env(for exampleGEMINI_API_KEY)
make startThis will:
- prepare local runtime files
- build and start containers
- initialize OpenClaw state permissions
- apply optional model + Telegram runtime configuration
- open interactive approval monitor
make stop
make clean
make wipeCopy .env.example to .env and set required values.
Key variables:
OPENCLAW_DEFAULT_MODELGEMINI_API_KEYOPENCLAW_GATEWAY_TOKENorOPENCLAW_GATEWAY_PASSWORDTELEGRAM_BOT_TOKENandTELEGRAM_ALLOWED_IDS(optional)EXEC_GUARD_MODE(observeorenforce)EXEC_GUARD_FAIL_MODE(approvalorclosed)EXEC_GUARD_TIMEOUT_MS
- HAProxy ACLs in
haproxy.cfgenforce outbound host restrictions. - Runtime approvals are written to
runtime_whitelist.lstthroughPOST /approve_domain. - Approval monitor runs via
make approveand reacts to blocked403requests.
POST /scanperforms normalization + scanner checks + local intent check.- Scanner init can be skipped in tests via
SKIP_LLM_GUARD_INIT=1.
POST /scan_execcombines deterministic policy and LLM-based risk scoring.- Deterministic rules live in
config/exec_policy.yaml. - Decision output:
allowdenyrequire_approval
- LLM is not the sole authority; deterministic deny rules always win.
- If deterministic policy blocks execution, LLM check is skipped and
llm_labelisnull. - Fail behavior when LLM check errors/timeouts:
approval:require_approvalclosed:deny
Containerized tests (recommended):
make test
make test-e2eCoverage includes:
- health endpoint
- domain approval write path
- exec gatekeeper deny/approval behavior
- fail-mode behavior for LLM uncertainty/timeouts
Host-side test option:
make test-local-setup
python3 -m unittest discover -s tests -p "test_*.py"Pre-commit gate:
make install-hooksThis installs .pre-commit-config.yaml hook that runs make test and blocks commits on failure.
.specstory/is git-ignored.- OpenClaw state persists in Docker volume
openclaw_config. docker-compose.ymlcurrently declaresversion: "3.8"; Compose warns this key is obsolete but still runs.
docker-compose.ymlMakefileshield_api.pyconfig/exec_policy.yamlapprove.shhaproxy.cfg.pre-commit-config.yamlrequirements.txtandrequirements-dev.txt
This is a hardening layer, not a perfect boundary. Keep least privilege defaults, strict allowlists, and human approval for risky actions.