Introduction
OpenClaw is a flexible framework designed for building AI agents,
orchestrating workflows, and managing complex automations. As with any
platform that exposes APIs, executes code, and handles sensitive data,
securing the configuration is paramount. The Security Hardener skill,
located at skills/skills/mariusfit/oc-security-hardener/SKILL.md in the
OpenClaw skills repository, provides a systematic way to audit, report, and
remediate security issues in an OpenClaw deployment. This article explains
what the skill does, why it matters, and how you can use it to harden your
setup.
What Is the Security Hardener Skill?
The Security Hardener skill is a collection of Python scripts and
documentation that together perform a comprehensive security audit of an
OpenClaw instance. Its primary purpose is to scan the openclaw.json
configuration file (and related files) for common misconfigurations, exposed
secrets, overly permissive rules, and missing security best practices. The
skill can operate in read‑only mode to produce a report, or it can
automatically apply fixes while preserving a backup of the original
configuration.
Key capabilities include:
- Auditing gateway binding, authentication settings, exec sandbox mode, file permissions, agent‑to‑agent policies, heartbeat configuration, session reset, and context pruning.
- Detecting exposed API keys or tokens stored directly in the configuration instead of environment variables or a
.envfile. - Generating a numeric security score (0‑100) that reflects the overall security posture.
- Providing multiple output formats (plain text, JSON, Markdown) for integration with CI/CD pipelines or ticketing systems.
- Offering targeted remediation commands that allow you to fix only specific categories of issues.
How the Audit Works
When you invoke the audit command, the skill reads the openclaw.json file
(or a path you specify with --config) and evaluates it against a predefined
list of security checks. Each check has an associated severity level—CRITICAL,
HIGH, MEDIUM, or LOW—based on the potential impact of the misconfiguration.
The script then prints a human‑readable summary, a detailed table of findings,
and an overall score.
The checks performed by the skill are:
| Check ID | Severity | Description |
|---|---|---|
| gateway-bind | CRITICAL | Gateway not bound to loopback (i.e., listening on 0.0.0.0 or a public interface). |
| exposed-keys | CRITICAL | API keys, tokens, or passwords found directly in the JSON config. |
| insecure-auth | HIGH | Flags like allowInsecureAuth or dangerouslyDisableDeviceAuth enabled. |
| exec-sandbox | HIGH | Exec sandbox mode not set to restricted (allowing arbitrary command execution). |
| file-perms | HIGH | Configuration files readable by users other than the owner (permissions looser than 600). |
| agent-allow-all | MEDIUM |
agentToAgent.allow set to ["*"], permitting any agent to communicate with any other. |
| no-heartbeat | MEDIUM | No heartbeat interval configured, making outage detection impossible. |
| no-session-reset | MEDIUM | Missing session reset policy, risking memory leaks over long runs. |
| no-pruning | LOW | No context pruning configured, which can increase memory usage and latency. |
| no-memory-flush | LOW | Memory flush disabled, potentially causing stale context after pruning. |
Each finding is displayed with an emoji indicator: a white check mark (✅)
for passed items, a warning triangle (⚠️) for issues that need attention,
and a red cross (❌) for failed items that should be fixed immediately.
Running a Security Audit
The simplest way to get a security overview is to run the audit in read‑only
mode:
python scripts/hardener.py audit
This command scans the default openclaw.json in the project root and outputs
a formatted report to the terminal. If your configuration lives elsewhere,
point the script at it:
python scripts/hardener.py audit --config /etc/openclaw/production.json
For machine‑readable output (useful in pipelines), request JSON format:
python scripts/hardener.py audit -f json
The JSON output includes each check’s ID, severity, status, and a short
message, enabling automated gating decisions.
Automatically Fixing Issues
After reviewing the audit report, you can let the skill apply fixes
automatically. The fix command first creates a timestamped backup of the
original configuration (e.g., openclaw.json.bak.20240101_120000) before
making changes:
python scripts/hardener.py fix
If you prefer to address only certain categories, you can limit the scope with
the --only flag. For example, to fix gateway binding and file permissions
only:
python scripts/hardener.py fix --only gateway-bind,file-perms
This selective approach helps avoid unintended side effects while still
improving the most critical aspects of security.
Scanning for Exposed Secrets
Hardcoded credentials are a common source of breaches. The skill includes a
dedicated command to search for API keys, tokens, or passwords inside the
configuration:
python scripts/hardener.py scan-secrets
The scanner looks for patterns typical of secrets (e.g., strings resembling
AWS keys, GitHub tokens, generic base64 blobs) and reports their location.
Because the check is CRITICAL, any finding should be moved to environment
variables or a secure secret store, and the configuration should be updated to
reference them via ${VAR_NAME} or similar placeholders.
Generating a Detailed Report
For documentation, compliance, or sharing with stakeholders, you can generate
a Markdown report:
python scripts/hardener.py report -o security-report.md
The report contains:
- An executive summary with the overall score and risk level.
- A table of all checks, their severity, status, and remediation advice.
- Guidance on how to interpret the score (Excellent, Good, Fair, Poor).
- Appendices showing the exact diff of changes made when the fix command is run.
Markdown output integrates nicely with wikis, GitHub repositories, or internal
knowledge bases.
Checking File Permissions
Even if the JSON content is secure, lax file permissions can undermine
security. The check-perms command verifies that the configuration file (and
optionally an entire directory) is not readable by unauthorized users:
python scripts/hardener.py check-perms
If the directory is supplied via --config-dir, the script recurses and
reports any file with permissions looser than 600.
Understanding the Security Score
The skill aggregates the results of all checks into a score from 0 to 100. The
scoring rubric is:
- 90‑100 : Excellent — production‑ready, only minor tweaks suggested.
- 70‑89 : Good — a few issues to address, but overall safe.
- 50‑69 : Fair — several problems that need remediation before production use.
- 0‑49 : Poor — critical flaws present; immediate action required.
Each check contributes a weighted penalty based on its severity. For example,
a CRITICAL failing check might subtract 25 points, while a LOW issue might
subtract only 2. This design ensures that a single critical misconfiguration
can drive the score into the “Poor” range, prompting urgent attention.
Integrating Security Hardener into Your Workflow
Because the skill is command‑line driven and produces machine‑parsable output,
it fits naturally into automated pipelines. Consider the following patterns:
-
Pre‑deployment gate : Run
audit -f jsonin a CI step; fail the build if the score is below a threshold (e.g., 80) or if any CRITICAL checks fail. -
Nightly compliance scan : Schedule a cron job that runs
report -o reports/$(date +%F).mdand archives the output for audit trails. -
Remediation pull request : Automatically create a PR that runs
fixand commits the backed‑up, corrected configuration, allowing team review before merge. -
Secret detection : Add
scan-secretsas a pre‑commit hook to catch accidental commits of API keys.
These integrations help shift security left, catching misconfigurations before
they reach production.
Best Practices When Using the Skill
To get the most out of the Security Hardener skill, follow these
recommendations:
- Always review the backup : Before applying fixes, inspect the generated backup file to ensure you understand what changed.
- Address CRITICAL and HIGH findings first : These have the highest potential impact; lowering your risk dramatically often requires only a handful of fixes.
-
Use environment variables for secrets : Replace any hardcoded keys with references to
${VAR_NAME}or a secret management system (Vault, AWS Secrets Manager, etc.). -
Restrict the gateway to loopback : Unless you have a specific need to expose the OpenClaw API externally, bind it to
127.0.0.1and place a reverse proxy (NGINX, Traefik) in front for TLS termination and access control. -
Enable exec sandbox : Set the exec mode to
restrictedto limit the commands agents can run, reducing the blast radius of a compromised agent. -
Tighten agent‑to‑agent policies : Instead of
["*"], define explicit lists of allowed agent IDs or use role‑based tags. - Configure heartbeat and session reset : A short heartbeat interval (e.g., 30 seconds) enables fast failure detection; a session reset policy (e.g., reset after 1 hour of inactivity) prevents memory leaks.
- Enable context pruning and memory flush : These settings help control resource consumption in long‑running agents.
Limitations and Considerations
While the Security Hardener skill is powerful, it is not a substitute for a
full security program. Keep the following in mind:
- The skill only examines the
openclaw.jsonfile (and related files). It does not scan running processes, network traffic, or host‑level configurations. - Secret detection relies on pattern matching; novel or obfuscated keys may evade detection.
- Automatic fixes may not be appropriate for highly customized environments; always review changes in staging before applying to production.
- The skill assumes a standard OpenClaw layout; non‑standard directory structures may require explicit
--configor--config-dirarguments.
Treat the output as a starting point for deeper manual review and penetration
testing.
Conclusion
The OpenClaw Security Hardener skill provides a practical, repeatable way to
assess and improve the security posture of your OpenClaw deployments. By
auditing gateway binding, credential exposure, authentication flags, exec
sandbox mode, file permissions, agent policies, heartbeat, session reset, and
context pruning, it surfaces the most common configuration pitfalls that could
lead to data breaches, unauthorized code execution, or service disruption. Its
flexible command‑line interface—offering read‑only audits, automatic fixes,
scoped remediation, secret scanning, and report generation—makes it easy to
embed into development workflows, CI/CD pipelines, and ongoing compliance
efforts.
If you are responsible for operating OpenClaw in any capacity—whether as a
developer, DevOps engineer, or platform administrator—incorporating the
Security Hardener skill into your routine will help you catch
misconfigurations early, reduce risk, and maintain a trustworthy environment
for your AI agents and automation workloads. Start by running a basic audit
today, review the findings, apply the most critical fixes, and then establish
a regular cadence of scanning and reporting to keep your deployment secure
over time.
Skill can be found at:
hardener/SKILL.md>
Top comments (0)