Comprehensive Security Hardening — Defense-in-Depth Implementation#1
Merged
Conversation
Implements defense-in-depth security measures informed by the Bitdefender Technical Advisory on OpenClaw exploitation (Feb 2026). This positions the project as a reference implementation for secure OpenClaw IaC. Critical fixes: - Fix secrets leaking to persistent disk (tmpfs symlink, no shell vars) - Fix installer checksum verification hard-fail (with macOS support) - Fix Terraform variable injection via validation blocks Container hardening: - Migrate from host network to isolated bridge network - Read-only root filesystem with explicit tmpfs mounts - Drop all Linux capabilities (cap_drop: ALL) - Pin Docker images by version + SHA256 digest - Chrome gets only SYS_ADMIN capability Infrastructure hardening: - Egress firewall restricts outbound to ports 80/443/53 only - OS Login for IAM-authenticated SSH access - Automatic security updates (unattended-upgrades) - Data Access audit logging on backup bucket - Narrowed OAuth scopes Backup security: - Client-side encryption with age before GCS upload - Backward-compatible restore (handles both encrypted and unencrypted) - Cleanup traps for sensitive temp files CI/CD hardening: - Replace grep with gitleaks for secret detection - SHA-pin all GitHub Actions - Restrict workflow permissions to contents:read - Add Trivy container image vulnerability scanning Supply chain: - Pre-commit hooks (gitleaks + shellcheck + terraform-fmt) - All Docker images pinned by digest Documentation: - New docs/security.md with full threat model and defense mapping - Updated README, AGENTS.md with security architecture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements comprehensive defense-in-depth security hardening across all layers of the infrastructure, informed by the Bitdefender Technical Advisory on OpenClaw Exploitation in Enterprise Networks (Feb 2026).
This PR positions
create-openclaw-agentas a reference implementation for secure OpenClaw IaC deployment.Changes by Category
Critical Fixes
.envbeing written to persistent disk instead of tmpfs. Now writes entire.envto tmpfs and creates a symlink. Secrets are never captured in shell variables (writes directly fromgcloudto tmpfs files).shasumfallback.templatefile().Container Hardening (docker-compose)
network_mode: hostto isolated bridge network (openclaw-net). Gateway ports bound to127.0.0.1only. Qdrant and Chrome accessible only within the bridge.read_only: trueon all containers with explicit tmpfs mounts for writable paths (/tmp,/home/node/.cache,/dev/shm).cap_drop: [ALL]on all containers. Chrome gets onlySYS_ADMIN(required for headless operation).v1.13.2, Chrome145.0.7632.46).Infrastructure Hardening (Terraform)
enable-oslogin = TRUEties SSH access to IAM identity.unattended-upgradesinstalled on VM (no auto-reboot).google_project_iam_audit_config.cloud-platformwith specific API scopes.Backup Security
agebefore upload to GCS. Private key stored in Secret Manager..age) and unencrypted (.tar.gz) backups.trap.CI/CD Hardening
gitleaks/gitleaks-action.permissions: contents: read.Supply Chain
.pre-commit-config.yamlwith gitleaks, shellcheck, terraform-fmt/validate.tag@sha256:digest..gitleaks.toml— Project-specific allowlist for documentation files.Documentation
docs/security.md— Comprehensive security architecture document with threat model, 7 defense layers, attack vector mapping, and verification commands.Attack Vector Mapping (Bitdefender Advisory)
cap_drop: ALL; bridge networkread_onlyfilesystem;no-new-privileges.envsymlink to tmpfs; secrets never on persistent disk; restrictive umaskCode Review
Three sequential review rounds were performed:
E2E Testing
Usability Impact
Zero impact on agent functionality. All agent operations (crons, configs, plugins, memory, workspace) continue working because they use mounted volumes which are exempt from
read_only. Bridge network changes are transparent via automatic service name configuration.Test Plan
tofu validatepassestofu fmt -checkpasses