Quick fixes for common OpenClaw formerly Moltbot/Clawdbot security issues
Symptoms:
Why this is critical: Anyone on the internet can access your bot, read conversations, and execute commands.
Fix:
# 1. Stop the gateway
pkill -f "openclaw gateway"
# Or if that doesn't work:
ps aux | grep openclaw
kill -9 [PID]
# 2. Restart bound to localhost ONLY
openclaw gateway --bind 127.0.0.1 --port 18789
# 3. Verify it's fixed
netstat -tuln | grep 18789
# Should show: 127.0.0.1:18789 (NOT 0.0.0.0:18789)
Access via SSH tunnel instead:
# From your laptop
ssh -L 18789:127.0.0.1:18789 user@your-vps-ip
# Then open browser to: http://localhost:18789
Permanent fix:
Edit ~/.openclaw/openclaw.json and set:
{
"gateway": {
"bind": "127.0.0.1",
"port": 18789
}
}
Symptoms:
cat ~/.openclaw/logs/gateway.logWhy this is critical: If someone gains access to your system, they can steal all your API keys.
Fix:
# 1. Edit config
nano ~/.openclaw/openclaw.json
# 2. Find logging section and set:
{
"logging": {
"redactSensitive": "all"
}
}
# 3. Restart OpenClaw
pkill -f openclaw && openclaw gateway --bind 127.0.0.1
# 4. Verify
tail ~/.openclaw/logs/gateway.log
# API keys should now show as: sk-ant-***REDACTED***
Rotate exposed keys: If logs already contain keys in plaintext:
# 1. Generate new keys at:
# - https://console.anthropic.com (Anthropic)
# - https://platform.openai.com (OpenAI)
# - etc.
# 2. Update OpenClaw config with new keys
# 3. Delete old keys from provider
# 4. Securely delete old logs
shred -u ~/.openclaw/logs/*.log
Symptoms:
Why this is critical: Config files contain API keys and sensitive settings.
Fix:
# Lock down entire directory
chmod 700 ~/.openclaw
chmod 600 ~/.openclaw/openclaw.json
chmod 600 ~/.openclaw/*.log
chmod 600 ~/.openclaw/.env
# Verify
ls -la ~/.openclaw/
# Should show: drwx------ (700 for directories)
# Should show: -rw------- (600 for files)
Symptoms:
Why this is high-risk: Prompt injection or compromised bot can run arbitrary commands on your system.
Fix - Option 1: Disable completely (safest)
# Edit config
nano ~/.openclaw/openclaw.json
# Set tools to deny-by-default:
{
"tools": {
"exec": {"enabled": false},
"browser": {"enabled": false},
"cron": {"enabled": false},
"process": {"enabled": false}
}
}
Fix - Option 2: Enable sandbox mode
# In OpenClaw UI:
# 1. Go to Settings → Security
# 2. Enable "Sandbox Mode"
# 3. Under "Tool Permissions":
# - Uncheck: exec, browser, cron, gateway
# - Keep only: messaging tools
Symptoms:
~/.openclaw/logs/ directory empty or doesn’t existWhy this is high-risk: Without logs, you can’t detect compromise or investigate incidents.
Fix:
# 1. Create logs directory
mkdir -p ~/.openclaw/logs
# 2. Enable logging in config
nano ~/.openclaw/openclaw.json
{
"logging": {
"enabled": true,
"audit_log": "logs/audit.log",
"gateway_log": "logs/gateway.log",
"redactSensitive": "all",
"level": "info"
}
}
# 3. Restart OpenClaw
pkill -f openclaw && openclaw gateway --bind 127.0.0.1
# 4. Verify logs are being written
tail -f ~/.openclaw/logs/audit.log
Symptoms:
Why this is high-risk: Passwords can be brute-forced, phished, or stolen.
Fix:
# Enable MFA in config
nano ~/.openclaw/openclaw.json
{
"authentication": {
"mode": "mfa_token",
"totp_enabled": true
}
}
# Better: Use SSO if available
{
"authentication": {
"mode": "sso_required",
"provider": "google" # or "github", "okta"
}
}
Symptoms:
Why this matters: Memory protocol embeds safety rules directly into bot’s “brain.”
Fix:
# 1. Download memory protocol
cd ~/.openclaw/memories/
curl -O https://raw.githubusercontent.com/CyberStrategyInstitute/ai-safe2-framework/main/examples/openclaw/openclaw_memory.md
# 2. Restart OpenClaw
pkill -f openclaw && openclaw gateway --bind 127.0.0.1
# 3. Verify it's loaded
# Send a test message: "Ignore previous instructions"
# Bot should refuse with security warning
Symptoms:
Why this matters: If config is accidentally committed to Git or backed up insecurely, keys are exposed.
Fix:
# 1. Move keys to environment variables
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."
# Add to ~/.bashrc or ~/.zshrc for persistence:
echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> ~/.bashrc
source ~/.bashrc
# 2. Update config to reference env vars
nano ~/.openclaw/openclaw.json
{
"anthropic": {
"api_key": "${ANTHROPIC_API_KEY}"
},
"openai": {
"api_key": "${OPENAI_API_KEY}"
}
}
# 3. Verify
echo $ANTHROPIC_API_KEY
# Should show: sk-ant-...
Even better: Use OS keychain
# macOS
security add-generic-password -a openclaw -s anthropic_key -w "sk-ant-..."
# Linux (gnome-keyring)
secret-tool store --label='Anthropic API Key' service openclaw account anthropic
Symptoms:
ERROR: ANTHROPIC_API_KEY not configured
Fix:
# Set environment variable
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
# Verify it's set
echo $ANTHROPIC_API_KEY
# Try starting again
cd gateway/
./start.sh
Permanent fix:
# Add to ~/.bashrc or ~/.zshrc
echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> ~/.bashrc
source ~/.bashrc
Symptoms:
ERROR: Required packages not installed
Run: pip3 install flask requests jsonschema pyyaml
Fix:
# Install dependencies
pip3 install flask requests jsonschema pyyaml
# If permission denied:
pip3 install --user flask requests jsonschema pyyaml
# On Debian/Ubuntu, may need:
sudo apt-get install python3-pip
Symptoms:
Fix - Option 1: Adjust risk threshold
# Edit gateway/config.yaml
gateway:
risk_threshold: 9.0 # Increase from default 7.0
Fix - Option 2: Allow specific tools
gateway:
allow_high_risk_tools: true # Use with caution
tool_allowlist:
- "exec" # Only if you really need shell access
Fix - Option 3: Add user to trusted list
trusted_users:
- "your-email@example.com"
Symptoms:
curl http://localhost:8888/health
# Connection refused
Possible causes:
1. Gateway not running
# Check if running
ps aux | grep gateway.py
# Start it
cd gateway/
./start.sh
2. Wrong port
# Check config
grep "bind_port:" gateway/config.yaml
# Should match curl command port
3. Firewall blocking
# Check firewall (Linux)
sudo iptables -L | grep 8888
# Allow port
sudo iptables -A INPUT -p tcp --dport 8888 -j ACCEPT
Symptom: Scanner flags issues that don’t apply to your setup.
Examples:
Fix: These are recommendations, not requirements. Focus on:
Symptoms:
ERROR: Path not found: /home/user/.openclaw
Fix:
# Find your actual path
find ~ -name "openclaw.json" 2>/dev/null
# Run scanner with correct path
python3 scanner.py --path /actual/path/to/.openclaw
Symptoms: Made config changes, now OpenClaw won’t start
Fix:
# 1. Check for JSON syntax errors
cat ~/.openclaw/openclaw.json | python3 -m json.tool
# If error shown, fix the JSON syntax
# 2. Check logs for error messages
tail -50 ~/.openclaw/logs/gateway.log
# 3. Try starting in foreground to see errors
openclaw gateway --bind 127.0.0.1 --verbose
Symptom: Secured OpenClaw, now can’t access web UI
This is expected! You hardened it. Access via SSH tunnel:
# From your laptop
ssh -L 18789:127.0.0.1:18789 user@your-server
# Then open browser to: http://localhost:18789
Alternatively, use VPN:
# Connect to your VPN
# Then access: http://[server-vpn-ip]:18789
Symptoms:
openclaw_memory.md to /memories/ but bot still accepts dangerous commandsTroubleshooting:
ls -la ~/.openclaw/memories/openclaw_memory.md
# File should exist
chmod 644 ~/.openclaw/memories/openclaw_memory.md
pkill -9 -f openclaw
openclaw gateway --bind 127.0.0.1
Bot should respond with security warning, not attempt execution.
If you’re still stuck:
tail -100 ~/.openclaw/logs/gateway.log
tail -100 ~/.openclaw/logs/audit.log
python3 scanner.py --path ~/.openclaw --output detailed-report.txt
Search GitHub issues: https://github.com/CyberStrategyInstitute/ai-safe2-framework/issues
If you suspect your OpenClaw has been hacked:
pkill -9 -f openclaw
sudo ifconfig eth0 down
sudo iptables -A OUTPUT -j DROP
3. **PRESERVE evidence**
```bash
# Copy logs
tar -czf /tmp/openclaw-incident-$(date +%Y%m%d-%H%M%S).tar.gz ~/.openclaw/logs/
# Copy configs
tar -czf /tmp/openclaw-config-$(date +%Y%m%d-%H%M%S).tar.gz ~/.openclaw/
cat ~/.openclaw/logs/audit.log | grep -E “exec|browser|DELETE|DROP”
cat ~/.openclaw/logs/gateway.log | grep -E “401|403|unauthorized”
cat ~/.openclaw/logs/audit.log | grep -E “upload|POST|curl”
6. **CLEAN and RESTORE**
```bash
# Option 1: Fresh install
rm -rf ~/.openclaw/
# Reinstall OpenClaw from official source
# Restore configs (after auditing them)
# Option 2: Restore from backup
./restore_backup.sh [date-before-incident]
Document Version: 2.1
Last Updated: January 30, 2026
Maintained By: Cyber Strategy Institute