Skip to main content

A CLI tool to analyze, audit, and fix OpenClaw security configuration issues.

Project description

OpenClaw Security Configuration Checker & Fixer

A powerful CLI tool to audit, analyze, and fix OpenClaw security configuration issues.

Python Security PyPI version

โœจ Features

  • ๐Ÿ” Comprehensive Security Audit - Checks 15+ security configurations
  • ๐ŸŽจ Beautiful CLI Interface - Rich terminal output with colors and tables
  • ๐Ÿ”ง Interactive Fixes - Apply fixes one-by-one with confirmation
  • โšก Auto-Fix Support - One-command fixes for common issues
  • ๐Ÿ“Š Detailed Reports - Export audit results to file
  • ๐Ÿš€ Native Integration - Uses openclaw config set and openclaw security audit

๐Ÿ“ฆ Installation

From PyPI

pip install openclaw-security

With rich terminal UI (recommended):

pip install openclaw-security[rich]

Prerequisites

  • Python 3.8+
  • OpenClaw CLI installed (auto-detected on Windows, macOS, and Linux)
  • OpenClaw config file at ~/.openclaw/openclaw.json

Platform Support

โœ… Windows - Full support with:

  • Automatic openclaw CLI detection (checks npm global, Program Files, and NVM paths)
  • Windows-specific file permission guidance (ACLs instead of chmod)
  • Correct handling of .cmd batch files

โœ… macOS - Full support with:

  • Auto-detection of openclaw CLI (Homebrew, NVM, npm global)
  • Standard Unix permission checks (chmod)

โœ… Linux - Full support with:

  • Auto-detection of openclaw CLI (NVM, npm global, /usr/local/bin)
  • Standard Unix permission checks (chmod)

๐Ÿ” Platform-Specific Behavior

Windows

  • File Permissions: Uses Windows ACLs (Access Control Lists) instead of Unix chmod
    • The script skips permission checks on Windows
    • Manual icacls commands are provided if you want to lock down files
  • CLI Detection: Automatically finds openclaw in:
    • C:\Program Files\nodejs\openclaw.cmd
    • %APPDATA%\npm\openclaw.cmd
    • NVM installation paths

macOS

  • File Permissions: Standard Unix chmod checks (700 for directories, 600 for files)
  • CLI Detection: Automatically finds openclaw in:
    • ~/.nvm/versions/node/v*/bin/openclaw
    • /usr/local/bin/openclaw
    • /opt/homebrew/bin/openclaw (Apple Silicon)

Linux

  • File Permissions: Standard Unix chmod checks (700 for directories, 600 for files)
  • CLI Detection: Automatically finds openclaw in:
    • ~/.nvm/versions/node/v*/bin/openclaw
    • ~/.local/bin/openclaw
    • /usr/local/bin/openclaw
    • ~/.npm-global/bin/openclaw

๐Ÿš€ Usage

After installing, use the osc command:

Basic Audit

Run security checks only (no fixes):

osc --check

Interactive Fix Mode

Audit + interactive fix session:

osc --fix

Auto-Fix All Issues

Apply all auto-fixable issues without prompting:

osc --fix-all

Run Official Audit

Run the native openclaw security audit command:

osc --audit

# With deep scan
osc --audit --deep

Export Report

Export audit results to file:

osc --export security-report.txt

Use Custom Config

Audit a specific config file:

osc --config /path/to/openclaw.json

Combined Options

Audit, fix all, and export report:

osc --fix-all --export report.txt

๐Ÿ” Security Checks

The tool checks the following areas:

Gateway Security

  • โœ… Gateway authentication configured
  • โœ… Gateway token strength
  • โœ… Bind mode (loopback vs LAN/tailnet)
  • โœ… Trusted proxies configured

Channel Security

  • โœ… Group policies (avoid "open")
  • โœ… Group allowlists configured
  • โœ… DM policies configured

Sandbox Security

  • โœ… Sandbox mode enabled
  • โœ… Workspace access (none/ro/rw)
  • โœ… Sandbox scope (session/agent/shared)
  • โœ… Docker capabilities dropped

Tool Security

  • โœ… Tool allow/deny lists
  • โœ… Elevated tools restricted
  • โœ… Dangerous tools not globally allowed

Session Security

  • โœ… DM session isolation (per-channel-peer)

File Security

  • โœ… File permissions (~/.openclaw = 700)
  • โœ… Config file permissions (600)
  • โœ… Credentials directory permissions (700)

Command Security

  • โœ… Bash commands disabled
  • โœ… Config commands restricted
  • โœ… Access groups enforced

Browser Security

  • โœ… Browser tool restrictions
  • โœ… Browser proxy mode

Docker Security

  • โœ… Container network settings
  • โœ… Container user (non-root)

Runtime Security

  • โœ… Node.js version (22.12.0+ required)

Other

  • โœ… Logging redaction enabled
  • โœ… mDNS mode (minimal/off)

๐Ÿ”ง Auto-Fixable Issues

The following issues can be automatically fixed:

Issue Fix Applied
Gateway authentication Generates new token via openclaw doctor --generate-gateway-token
Sandbox disabled Sets agents.defaults.sandbox.mode = "non-main"
mDNS full mode Sets discovery.mdns.mode = "minimal"
DM isolation Sets session.dmScope = "per-channel-peer"
Logging redaction Sets logging.redactSensitive = "tools"
File permissions Runs chmod 700/600 on directories/files (Unix/Linux/macOS only)
Access groups Sets commands.useAccessGroups = true
Docker capDrop Sets agents.defaults.sandbox.docker.capDrop = ["ALL"]

โœ… Verifying Settings After Fix

After running fixes, verify your configuration:

Re-Run Security Check

osc --check

Use OpenClaw CLI Commands

openclaw config get agents.defaults.sandbox.mode
openclaw config get session.dmScope
openclaw config get discovery.mdns.mode
openclaw config get agents.defaults.sandbox.docker.capDrop

Restart Gateway (Required!)

Configuration changes require a gateway restart:

openclaw gateway restart
openclaw gateway status

โš ๏ธ Manual Fixes Required

Some issues require manual intervention:

  • Group policies: Need to manually configure allowlists in config
  • Tool restrictions: Need to review and adjust tool allow/deny lists per agent
  • Node.js version: Must upgrade Node.js manually
  • Network exposure: Need to configure firewall rules
  • Elevated tools: Need to review tools.elevated.allowFrom settings

๐Ÿ“‹ Command Reference

usage: osc [-h] [--check] [--fix] [--fix-all]
           [--audit] [--deep] [--export FILE]
           [--config FILE] [-v]

Audit and fix OpenClaw security configuration

options:
  -h, --help            Show help message and exit
  --check               Run security checks only (no fixes)
  --fix                 Run interactive fix session after checks
  --fix-all             Apply all auto-fixable issues without prompting
  --audit               Run official openclaw security audit command
  --deep                Run deep audit (with --audit flag)
  --export FILE         Export report to file
  --config FILE         Use custom config file path
  -v, --verbose         Verbose output

๐Ÿ” Security Best Practices

  1. Always run openclaw security audit --deep first
  2. Never bind Gateway to LAN - Use loopback or Tailscale Serve
  3. Enable sandboxing for non-main sessions
  4. Use strong, random gateway tokens (16+ characters)
  5. Restrict elevated tools to owner only
  6. Set file permissions: 700 for dirs, 600 for config files
  7. Enable mention gating in groups - Require @-mentions
  8. Isolate DM sessions - Use per-channel-peer scope
  9. Keep logging redaction on - Unless actively debugging
  10. Run this tool regularly - Especially after config changes

๐Ÿ› Troubleshooting

"openclaw command not found"

Ensure OpenClaw CLI is installed and in your PATH:

npm install -g openclaw

"Config file not found"

Check that ~/.openclaw/openclaw.json exists:

ls -la ~/.openclaw/

Rich library not found

Install with the rich extra:

pip install openclaw-security[rich]

๐Ÿค Contributing

This tool is designed to be extensible. To add new checks:

  1. Add a new check method to OpenClawSecurityChecker class
  2. Call it in run_all_checks() method
  3. Add corresponding fix method if applicable
  4. Update this README

๐Ÿ“„ License

MIT License - see LICENSE for details.

๐Ÿ™ Credits

Built with โค๏ธ using:

  • Rich - Beautiful terminal output
  • OpenClaw - The awesome AI assistant framework

Made By Umer Farooq

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openclaw_security-0.1.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openclaw_security-0.1.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file openclaw_security-0.1.0.tar.gz.

File metadata

  • Download URL: openclaw_security-0.1.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for openclaw_security-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fdafc0039da755e5ea2490d8ed6c1ba659e4a1e59e0f2f348d4a815a54611d7d
MD5 b16f2fd7c982f8707ca4a14b81a6aba1
BLAKE2b-256 5d139cb4ed302007a39e4c962b41ce6daf8156599c487ad5533e6a991cf88807

See more details on using hashes here.

File details

Details for the file openclaw_security-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openclaw_security-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79b4c8defff598fcf177697e198388d7fd0fb9ccfd7dae1e3600e5165a09dff8
MD5 25043517a8c3d38e5f87ebb41e3f6d1c
BLAKE2b-256 a002fb0062f502e21dd5ad136034200c49d020b44ca83eac06b188386ebd532d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page