Back to skill

Security audit

asclaude-grep

Security checks for vulnerabilities and agentic risk

Overview

This skill is a local workspace search helper with a real but limited command-argument hardening issue, and I found no hidden network, persistence, credential, or destructive behavior.

Install only if you are comfortable with a local helper that can search filenames and contents under your OpenClaw workspace. Avoid using untrusted search patterns that start with command-style options, and prefer a patched version that adds a grep -- delimiter or fixed-string mode.

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

Warning
Location
scripts/workspace_search.py:11
Finding

User-Controlled GNU grep Option Injection

Content
View full analysis

Vulnerability Details

File Location: scripts/workspace_search.py, lines 11–21
Vulnerability Type: Command argument injection through missing end-of-options delimiter
Risk Level: Medium

Vulnerable Code

python
def grep_content(pattern, max_results=20):
    """Search file content using grep."""
    cmd = [
        "grep", "-rn", 
        "--include=*.py", "--include=*.md", "--include=*.ts", 
        "--include=*.js", "--include=*.json", "-i",
        pattern, WORKSPACE_PATH
    ]
    try:
        result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)

Technical Analysis

The user-controlled pattern is inserted into the grep argument list before the workspace path without a -- end-of-options delimiter. Consequently, a pattern beginning with - can be interpreted by GNU grep as one or more command-line options rather than as the intended search expression.

Although the use of an argument list with subprocess.run() prevents shell metacharacter injection, it does not prevent argument or option injection. For example, a compact argument such as -f/path/to/file instructs GNU grep to read search patterns from the specified local file. Other injected options can modify matching, recursion, output, and resource-consumption behavior.

Attack Path

  1. An attacker or untrusted caller supplies an option-like search pattern:
    bash
    python scripts/workspace_search.py grep -f/path/to/readable/file
    
  2. The script constructs the following effective invocation:
    bash
    grep -rn --include=*.py --include=*.md --include=*.ts \
      --include=*.js --include=*.json -i \
      -f/path/to/readable/file ~/.openclaw/workspace
    
  3. GNU grep interprets -f/path/to/readable/file as an option and reads that file as a source of regular-expression patterns.
  4. Those patterns are applied to files in the OpenClaw workspace.
  5. Matching out ...[truncated 879 chars]
Remediation
View remediation

Remediation Suggestions

Insert GNU's -- end-of-options delimiter immediately before the user-controlled pattern so that values beginning with - are handled as search expressions:

python
cmd = [
    "grep", "-rn",
    "--include=*.py", "--include=*.md", "--include=*.ts",
    "--include=*.js", "--include=*.json", "-i",
    "--", pattern, WORKSPACE_PATH
]

Additional hardening measures:

  1. Validate the pattern's length to reduce denial-of-service risk from excessively large or computationally expensive regular expressions.
  2. If regular-expression support is unnecessary, add -F to perform fixed-string matching.
  3. If both literal and regular-expression searches are required, expose them as explicit modes rather than inferring behavior from user input.
  4. Check result.returncode and distinguish no-match status from operational errors.
  5. Avoid returning raw exception details to untrusted callers where those details could expose local paths or runtime information.
  6. Add regression tests using patterns such as -f/etc/passwd, --help, and --version to verify that they are treated solely as search text.
Vulnerability Patterns
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (3)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The natural-language content of the skill forces a specific language for all users, and there is no indication that Chinese is optional or that the skill is intended only for a Chinese-speaking audience. This can violate language/locale policy when users are not given an opt-in or alternative.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/workspace_search.py (reported line 21)May include surrounding context.

python
pattern, WORKSPACE_PATH
    ]
    try:
        result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
        lines = result.stdout.strip().split('\n')
        if not lines or lines == ['']:
            return f"No content matches found for: {pattern}"

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/workspace_search.py (reported line 33)May include surrounding context.

python
pattern, WORKSPACE_PATH
    ]
    try:
        result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
        lines = result.stdout.strip().split('\n')
        if not lines or lines == ['']:
            return f"No content matches found for: {pattern}"