Back to skill

Security audit

openclaw security auditor

Security checks for vulnerabilities and agentic risk

Overview

This security-auditor skill has a coherent purpose, but it relies on unreviewed external Python code and includes persistent configuration-changing behavior that is under-disclosed.

Review this before installing. The audit/reporting goal is legitimate, but do not rely on the scanner unless the external `osa` dependency is pinned and verified. Avoid the aggressive profile except in disposable isolated tests, and treat the fixer as a persistent config editor despite the read-only safety claim.

Vulnerability Patterns
  • Tool Hijacking and SpoofingModifies or replaces tools so legitimate-looking calls execute attacker logic
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T07 · Tool Hijacking and Spoofing

Error
Location
scripts/security_scanner.py:12
Finding
Unverified External Python Modules Can Be Loaded and Executed<![CDATA[ ## Vulnerability Details **File Location**: `scripts/security_scanner.py:12-15` **Vulnerability Type**: Python import-path manipulation and unverified external dependency loading **Risk Level**: High ### Vulnerable Code ```python # Add the OSA tool directory to path sys.path.insert(0, str(Path(__file__).parent.parent.parent / "openclaw-security-auditor")) from osa.scanner_fixed import SecurityScanner from osa.reporter import ReportGenerator ``` ### Technical Analysis The scanner prepends a predictable directory outside the audited project to `sys.path` and then imports the `osa.scanner_fixed` and `osa.reporter` modules. Those modules are not included in this project, pinned to a verified package version, or checked against trusted cryptographic hashes. Python executes module-level code when a module is imported. Consequently, a party that can create or modify the expected external `openclaw-security-auditor/osa` package can cause arbitrary Python code to execute when `security_scanner.py` is imported or run. Prepending the external path gives modules found there priority during import resolution. This crosses the audited package's trust boundary and prevents the effective scanner implementation from being verified as part of this audit. It also creates an opportunity to spoof legitimate-looking scanner and report-generator classes. The import is indirectly triggered by `test_skill.py:10-12`, which adds the local scripts directory to `sys.path` and imports `security_scanner`: ```python # Add skill scripts to path sys.path.insert(0, str(Path(__file__).parent / "scripts")) from security_scanner import scan_openclaw_config ``` ### Attack Path 1. An attacker obtains write access to the predictable external `openclaw-security-auditor` directory or causes an untrusted package to be installed there. 2. The attacker creates or modifies `osa/scanner_fixed.py`, `osa/reporter.py`, or package initialization files. 3. A user or Agent imports `scripts/sec ...[truncated 1166 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove the runtime `sys.path.insert` modification. 2. Bundle the required `osa` implementation inside the audited project and use package-relative imports, for example: ```python from .osa.scanner_fixed import SecurityScanner from .osa.reporter import ReportGenerator ``` 3. If `osa` must remain a third-party dependency: - Declare it through a standard dependency manifest. - Pin an exact trusted version. - Verify package hashes during installation. - Install it only from an authenticated, approved package repository. - Use a locked virtual environment rather than a writable sibling directory. 4. Validate that the imported module originates from the expected installed path before using it. 5. Fail closed with a clear error if the verified dependency is unavailable; do not search predictable external directories as a fallback. 6. Include the effective scanner and reporter implementations in future security-review scope. 7. Add a regression test that places a fake `osa` module in nearby directories and confirms that it cannot override the trusted implementation. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/report_generator.py:242
Finding
Unescaped Scan Results Permit Stored HTML Injection<![CDATA[ ## Vulnerability Details **File Location**: `scripts/report_generator.py:242-269` **Vulnerability Type**: Stored HTML injection caused by unescaped report fields **Risk Level**: Medium ### Vulnerable Code ```python html = f"""<!DOCTYPE html> <html> <head> <title>OpenClaw Security Audit Report</title> <meta charset="utf-8"> <style> body {{ font-family: Arial, sans-serif; margin: 40px; }} .header {{ background: #f5f5f5; padding: 20px; border-radius: 5px; }} .score-excellent {{ color: #22c55e; font-weight: bold; }} .score-good {{ color: #84cc16; font-weight: bold; }} .score-fair {{ color: #f59e0b; font-weight: bold; }} .score-risk {{ color: #ef4444; font-weight: bold; }} .score-critical {{ color: #7f1d1d; font-weight: bold; }} .issue {{ margin: 20px 0; padding: 15px; border-left: 4px solid #ccc; }} .critical {{ border-left-color: #ef4444; }} .high {{ border-left-color: #f97316; }} .medium {{ border-left-color: #eab308; }} .low {{ border-left-color: #22c55e; }} .info {{ border-left-color: #64748b; }} </style> </head> <body> <div class="header"> <h1>OpenClaw Security Audit Report</h1> <p><strong>Security Score:</strong> <span class="score-{results.get('security_level', 'critical')}">{results['score']}/100</span></p> <p><strong>Configuration File:</strong> {results['config_path']}</p> <p><strong>Security Mode:</strong> {results['mode']}</p> </div> <h2>Summary</h2> <p>Total Checks: {results['total_checks']}</p> <p>Passed: {results['passed_checks']}</p> <p>Issues Found: {len(results['issues'])}</p> """ # Add issues for issue in results['issues']: severity = issue.get('severity', 'info') html += f""" <div class="issue {severity}"> <h3>{issue.get('title', 'Unknown issue')}</h3> <p><strong>Description:</strong> {issue.get('description' ...[truncated 2857 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Escape every dynamic value before inserting it into HTML: ```python from html import escape def html_text(value: object) -> str: return escape(str(value), quote=True) ``` 2. Apply escaping in both text and attribute contexts: ```python config_path = html_text(results["config_path"]) mode = html_text(results["mode"]) title = html_text(issue.get("title", "Unknown issue")) description = html_text(issue.get("description", "No description")) fix_command = html_text(issue.get("fix_command", "N/A")) ``` 3. Prefer a mature template engine with automatic HTML escaping enabled rather than constructing HTML through f-strings. 4. Validate input against a strict schema before report generation: - Require numeric score and check-count fields. - Restrict `security_level` and `severity` to fixed allowlists. - Require expected collection and string types. - Reject unknown or structurally invalid fields where appropriate. 5. Do not insert raw input into CSS class attributes. Map validated enum values to internally defined class names. 6. Add a restrictive Content Security Policy when reports are served over HTTP, such as disallowing inline scripts and unapproved external resources. This should be defense in depth, not a substitute for escaping. 7. Add regression tests covering HTML-sensitive characters and payloads in every dynamic field, including closing tags, quoted attribute values, event-handler attributes, and script-capable markup. ]]>
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (12)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
If the skill claims to perform security diagnosis, scoring, validation, and remediation generation but in reality only renders provided values, users can be misled into relying on nonexistent security analysis. In a security context, false assurance is itself harmful because serious misconfigurations may go undetected while the output appears authoritative.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the skill claims to perform security diagnosis, scoring, validation, and remediation generation but in reality only renders provided values, users can be misled into relying on nonexistent security analysis. In a security context, false assurance is itself harmful because serious misconfigurations may go undetected while the output appears authoritative.

Intent-Code Divergence

High
Confidence
98% confidence
Finding
Claiming the skill is 'safe and non-destructive' and 'only reads configuration files' directly contradicts earlier documented write and fix capabilities. In a security tool, deceptive or inaccurate safety claims are especially dangerous because they can lower user caution and enable unintended file modification under a veneer of safety.

Intent-Code Divergence

High
Confidence
97% confidence
Finding
The module header claims to provide 'safe configuration fixing capabilities,' but one of its built-in profiles applies overtly unsafe settings. This mismatch is dangerous because it creates trust in a security tool that can silently reduce protections, increasing the likelihood of operator error and insecure deployment.

Description-Behavior Mismatch

High
Confidence
99% confidence
Finding
The 'aggressive' profile materially weakens security by binding to LAN, disabling authentication, disabling workspace-only filesystem restrictions, and widening session scope. In a tool presented as a security auditor/fixer, offering this as a normal selectable mode can directly lead users to deploy an insecure configuration under the mistaken belief that it is a stronger hardening option.

Missing User Warnings

High
Confidence
98% confidence
Finding
The aggressive mode disables authentication and increases network exposure, yet the command-line interface presents it as a standard mode choice without a strong warning or extra friction at the point of use. In the context of a security auditor skill, this is especially dangerous because users may interpret 'aggressive' as stronger security rather than aggressively permissive behavior.

Lp3

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding
The skill documents code paths that read from a user configuration and write a report to disk, but it does not declare any explicit tool scope such as permissions or allowed-tools. That mismatch weakens the trust boundary for the skill and can lead to broader-than-expected file access when the agent executes the documented workflow.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The documentation says the skill only reads configuration files, but elsewhere it explicitly writes reports and offers scripts that apply fixes. This inconsistency can cause unsafe operator assumptions about non-destructiveness and may lead users to authorize execution they would have declined if the write behavior were disclosed clearly.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
### Issue: No system firewall
- **Risk**: Network-level attacks
- **Fix**: Enable UFW with `sudo ufw enable`

## Configuration Validation
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
This code performs a file write that modifies the user's configuration in place. Although the script logs backup creation and success, it does not require user confirmation before applying changes, which is a safety-relevant operation for a config-fixing tool.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
This code sets the default report format to "bilingual", and the CLI also defaults to that format, which forces a specific language/locale combination unless the user explicitly overrides it. Under the policy, language or locale constraints should be optional or clearly justified rather than imposed by default.

Natural-Language Policy Violations

Medium
Confidence
88% confidence
Finding
The report template hardcodes paired English and Chinese headings and text throughout the generated output, reflecting a fixed locale policy in the natural-language content. The file does not present this as an optional language preference or explain a justified compliance need for this locale combination.

Static analysis

No suspicious patterns detected.