Skip to content

Security

The Idea

A systematic, phased approach to testing Docker sandbox configurations without risking the host machine - especially important for personal automation bots with access to real data.

Context

User setting up moltbot on Mac Mini with Docker sandbox. Concerned about:

  • Signal-cli (can brick phone identity)
  • Volume mounts to personal Obsidian vault
  • Email credentials
  • Resource limits not actually working

The Pattern

Phase 1: Isolated Container Test

# Use DUMMY mounts, not real data
mkdir -p /tmp/test-sandbox/{downloads,obsidian}
docker run --rm -it \
  --read-only \
  --cpus="2.0" \
  --memory="2g" \
  -v /tmp/test-sandbox/downloads:/mnt/downloads:rw \
  moltbot-sandbox:custom /bin/sh

Phase 2: Resource Limit Validation

# Stress test that stays inside container limits
docker run --rm -it --cpus="2" --memory="2g" container sh -c "
  stress-ng --cpu 8 --timeout 10s 2>/dev/null || echo 'expected'
"

Phase 3: Credential Testing (Read-Only First)

# Email: read-only commands only
himalaya list --folder INBOX -s 3  # Safe
# himalaya send ...  # NEVER in testing

Phase 4: High-Risk Components

  • Signal-cli: Use burner number or skip entirely
  • Backup identity before any testing: cp -r ~/.signal-cli ~/.signal-cli.backup

Raw Exchange

User: “this machine is mac mini. and sandbox is running in docker. tell me plan to test this config but not blowing up my device”

Read more

The Idea

Use a shell wrapper script that fetches API keys from macOS Keychain only when the command actually runs - never exposing secrets in shell environment globally.

Context

Setting up OpenClaw/moltbot automation. User correctly pushed back on storing API keys in ~/.zshrc because:

  • Keys visible to ALL processes
  • Persists in shell history
  • Often committed to dotfiles repos

Raw Quote

“putting api in shell config seems not good”

The Pattern

#!/bin/bash
# ~/bin/openclaw - wrapper that fetches from Keychain on-demand

fetch_key() {
    local keychain_name="$1"
    security find-generic-password -a "$USER" -s "$keychain_name" -w 2>/dev/null || {
        echo "Error: $keychain_name not found in Keychain" >&2
        return 1
    }
}

export GEMINI_API_KEY=$(fetch_key "gemini-api-key") || exit 1
export OPENCLAW_GATEWAY_TOKEN=$(fetch_key "openclaw-gateway-token") || exit 1

exec /path/to/actual/command "$@"

Why This Is Better

ApproachKey Exposure
~/.zshrc exportEvery shell, every process
Wrapper scriptOnly during command execution

Expansion Potential

  • Blog post: “The Right Way to Handle API Keys on macOS”
  • Could apply to any CLI tool needing secrets
  • Universal pattern for security-conscious developers