Back to skill

Security audit

Workspace Guard

Security checks for vulnerabilities and agentic risk

Overview

The skill tries to protect workspace file access, but its own boundary-check examples include unsafe path handling that could undermine that protection.

Install only if you are comfortable treating it as advisory guidance rather than a reliable enforcement layer. Before using its snippets, replace the eval path expansion, make path canonicalization fail closed, define one canonical workspace root, and move audit logging inside that root with structured escaping and retention limits.

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 (3)

T09 · Insecure Skill Coding Practices

Error
Location
references/boundaries.md:168
Finding
Arbitrary Command Execution Through Unsafe Path Expansion<![CDATA[ ## Vulnerability Details **File Location**: `references/boundaries.md`, lines 168-170 **Vulnerability Type**: Shell command injection **Risk Level**: High ### Vulnerable Code ```bash # Expand $VAR in paths eval "echo \"$path\"" | realpath ``` ### Technical Analysis The documented path-resolution pattern passes the value of `path` to `eval`. Unlike ordinary variable expansion, `eval` interprets the resulting value as shell source code. If an untrusted path contains command substitution, shell metacharacters, or crafted quotation characters, the shell can execute those elements before `realpath` performs validation. Path validation must treat input as data. It must not evaluate path strings as shell expressions merely to expand environment variables. ### Attack Path 1. An attacker supplies a path containing shell syntax, such as a command substitution. 2. The Agent follows the documented environment-variable expansion pattern. 3. The path is interpolated into the argument passed to `eval`. 4. `eval` parses the interpolated text as a new shell command. 5. The injected command executes before its output is passed to `realpath`. 6. The attacker-controlled command runs with the privileges and filesystem access of the Agent process. ### Impact Assessment Successful exploitation permits arbitrary command execution under the Agent's operating-system identity. Depending on that identity's permissions, an attacker could read or alter accessible files, expose credentials, execute additional local programs, or compromise workspace integrity. The effect is not limited to path resolution because injected shell commands can perform unrelated operations. ]]>
Remediation
<![CDATA[ ## Remediation Suggestions Remove `eval` entirely and treat all supplied path values as literal data. - Resolve literal paths with a safely quoted command such as `realpath -- "$path"`. - If leading-tilde expansion is required, implement only that specific transformation without invoking a shell evaluator. - Do not support arbitrary shell expressions or command substitutions in paths. - If environment-variable expansion is required, use a strict allowlist of recognized variables and replace them through non-evaluating string operations. - Reject control characters, command-substitution syntax, and unexpected shell metacharacters where appropriate. - Fail closed if canonical path resolution cannot be completed. Example safer handling: ```bash case "$path" in "~") path="$HOME" ;; "~/"*) path="$HOME/${path#\~/}" ;; esac abs_path=$(realpath -- "$path") || { echo "Unable to resolve path" >&2 return 1 } ``` ]]>

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:72
Finding
Workspace Boundary Bypass Through Fail-Open Canonicalization<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 72-78 **Vulnerability Type**: Improper path canonicalization and fail-open validation **Risk Level**: High ### Vulnerable Code ```bash guard_path() { local path="$1" local workspace="/home/iamlegend/.openclaw/workspace" local abs_path=$(realpath "$path" 2>/dev/null || echo "$path") case "$abs_path" in "$workspace"/*) return 0 ;; *) return 1 ;; esac } ``` ### Technical Analysis The guard attempts to canonicalize a path with `realpath`, but falls back to the original, uncanonicalized input when resolution fails: ```bash realpath "$path" 2>/dev/null || echo "$path" ``` The subsequent security decision is a string-prefix comparison. If canonicalization fails, traversal components, unresolved symlinks, or other non-canonical path elements can remain in the value being checked. A raw string can begin with the expected workspace prefix while ultimately identifying a location outside that workspace when used by a later filesystem operation. This is a fail-open design: failure of the security normalization step causes validation to continue with less trustworthy data instead of rejecting the request. ### Attack Path 1. An attacker supplies a non-canonical path that begins with `/home/iamlegend/.openclaw/workspace/`. 2. The path includes traversal components or refers to a target that cannot be resolved during the initial check. 3. `realpath` fails. 4. The fallback returns the original path unchanged. 5. The `case` statement approves it because the raw string begins with the workspace prefix. 6. A subsequent filesystem operation resolves the path according to actual filesystem semantics. 7. The resulting operation can reach a target outside the intended workspace boundary. The precise exploitability depends on the filesystem state and the behavior of the later operation, but the documented guard does not safely enforce the claimed boundary when canonicalization fails. # ...[truncated 346 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Use fail-closed, component-aware canonicalization. - Reject the operation if an existing target cannot be canonicalized. - For a new target, canonicalize its nearest existing parent directory rather than accepting the raw target string. - Verify that the canonical parent is either the workspace root or a descendant separated by a path component. - Permit only a validated final basename to be appended to the approved parent. - Revalidate symlink targets and the effective destination immediately before the operation. - Where possible, use directory-descriptor-relative filesystem APIs that prevent path traversal and symlink races. - Quote every path and use `--` before path arguments. A safer shell pattern for existing targets is: ```bash guard_path() { local path="$1" local workspace="/home/iamlegend/.openclaw/workspace" local abs_path abs_path=$(realpath -- "$path") || return 1 case "$abs_path" in "$workspace"|"$workspace"/*) return 0 ;; *) return 1 ;; esac } ``` New targets require separate handling: canonicalize and validate the existing parent, validate the basename, and avoid following a newly introduced symlink between validation and use. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
references/boundaries.md:122
Finding
Audit Log Injection and Boundary-Inconsistent Persistent Logging<![CDATA[ ## Vulnerability Details **File Location**: `references/boundaries.md`, lines 122-129 **Vulnerability Type**: Improper neutralization of untrusted log data **Risk Level**: Medium ### Vulnerable Code ```bash log_violation() { local path="$1" local operation="$2" local timestamp=$(date -Iseconds) echo "$timestamp | BLOCKED | $operation | $path" >> /workspace/memory/audit.log } ``` Related instructions also require blocked attempts to be logged and recommend tracking all violations. The selected log path, `/workspace/memory/audit.log`, is inconsistent with the declared workspace root of `/home/iamlegend/.openclaw/workspace`. ### Technical Analysis The function writes attacker-influenced `operation` and `path` values directly into a delimiter-based persistent log. It does not encode newline characters, carriage returns, delimiters, terminal control sequences, or other untrusted content. An attacker can therefore construct a path or operation containing line breaks and text that resembles legitimate audit entries. When appended, that input can create forged records or alter how later tools and reviewers interpret the log. Sensitive path names may also be retained indefinitely because no minimization or retention policy is defined. In addition, the hard-coded destination does not reside under the Skill's declared workspace root. Following this example may therefore cause the logging mechanism itself to violate the boundary that the Skill is intended to enforce. ### Attack Path 1. An attacker requests access to a path containing embedded newline characters and a forged audit-record payload. 2. Workspace Guard blocks the operation and invokes `log_violation`. 3. The function interpolates the path into an `echo` command without structured encoding. 4. The embedded newline causes one attacker-controlled value to appear as multiple log records. 5. A reviewer or automated parser later treats the injected record as genuine. 6. If the process can ...[truncated 752 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Use structured, safely encoded logging within the configured workspace. - Place the log beneath `/home/iamlegend/.openclaw/workspace` or derive its location from the validated workspace configuration. - Encode records as JSON or another structured format using a serializer rather than manual string concatenation. - Escape or reject newline characters, carriage returns, terminal escapes, and other control characters. - Do not rely on `echo` for serialization. - Minimize sensitive path data, for example by recording a redacted or cryptographic representation where full paths are unnecessary. - Restrict log permissions to the intended owner. - Define retention, rotation, and maximum-size policies. - Prevent the log itself from being targeted through the guarded file-operation interface. - Document whether logging is permitted to cross workspace boundaries; otherwise, fail closed if the configured destination is external. A safe implementation should pass each field to a JSON serializer as data and append exactly one encoded object per event. ]]>
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
Findings (15)

Tool Parameter Abuse

High
Category
Tool Misuse
Content
fi
  
  # Check for destructive commands
  if echo "$cmd" | grep -qiE 'rm -rf|dd|:(){:|>|chmod 777'; then
    echo "UNSAFE: Destructive operation"
    return 1
  fi
Confidence
80% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
fi
  
  # Check for destructive commands
  if echo "$cmd" | grep -qiE 'rm -rf|dd|:(){:|>|chmod 777'; then
    echo "UNSAFE: Destructive operation"
    return 1
  fi
Confidence
80% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
```

### Common Dangerous Patterns
- `rm -rf /` - Catastrophic delete
- `:(){ :|:& };:` - Fork bomb
- `chmod 777 /` - Open all permissions
- `dd if=/dev/zero of=/dev/sda` - Disk wipe
Confidence
90% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
```

### Common Dangerous Patterns
- `rm -rf /` - Catastrophic delete
- `:(){ :|:& };:` - Fork bomb
- `chmod 777 /` - Open all permissions
- `dd if=/dev/zero of=/dev/sda` - Disk wipe
Confidence
85% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Credential Access

High
Category
Privilege Escalation
Content
- `:(){ :|:& };:` - Fork bomb
- `chmod 777 /` - Open all permissions
- `dd if=/dev/zero of=/dev/sda` - Disk wipe
- `> /etc/passwd` - Overwrite system files

## Audit Logging
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Intent-Code Divergence

High
Confidence
99% confidence
Finding
The example `eval "echo \"$path\"" | realpath` performs shell evaluation on untrusted path input, which can trigger command substitution or other shell metacharacter expansion before boundary checks occur. In a workspace-guard skill whose purpose is to enforce path safety, documenting `eval` as a path-normalization technique is especially dangerous because consumers may copy it directly into enforcement logic.

Vague Triggers

Medium
Confidence
86% confidence
Finding
The description says to use the skill before "ANY file operation" including common actions like read, write, and edit. For a markdown skill description, this activation language is very broad and does not provide clear exclusion conditions or narrower trigger phrases, which could cause unintended invocation during ordinary conversation about files.

Intent-Code Divergence

Medium
Confidence
95% confidence
Finding
The skill documents multiple workspace roots and aliases, but its enforcement examples and guard logic rely on a single hardcoded path. In a boundary-enforcement skill, contradictory rules can cause operators or downstream agents to believe a path is permitted when the implemented check would reject it, or vice versa if callers normalize differently, weakening a security control through ambiguity.

Intent-Code Divergence

Medium
Confidence
96% confidence
Finding
The stated allowed paths include aliases such as ~/openclaw/workspace and relative paths, but the sample case statement and guard_path function only allow one hardcoded absolute prefix. Because this skill is supposed to prevent unauthorized filesystem access, mismatched examples can lead integrators to deploy incomplete checks that fail open in wrappers or encourage unsafe manual exceptions when legitimate paths are blocked.

Intent-Code Divergence

Medium
Confidence
88% confidence
Finding
The document defines the workspace root as `/home/iamlegend/.openclaw/workspace`, but the logging example writes blocked-attempt records to `/workspace/memory/audit.log`. For a skill whose purpose is strict workspace-boundary enforcement, documenting writes to a different absolute root contradicts the declared boundary model and could place audit data outside the allowed workspace.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
## Operation Classification

### Safe (Auto-Approve Within Workspace)
- `read` - File reads
- `cat`, `less`, `head`, `tail` - View operations
- `ls`, `find`, `tree` - Listing
Confidence
85% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
fi
  
  # Check for destructive commands
  if echo "$cmd" | grep -qiE 'rm -rf|dd|:(){:|>|chmod 777'; then
    echo "UNSAFE: Destructive operation"
    return 1
  fi
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
fi
  
  # Check for destructive commands
  if echo "$cmd" | grep -qiE 'rm -rf|dd|:(){:|>|chmod 777'; then
    echo "UNSAFE: Destructive operation"
    return 1
  fi
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
- `:(){ :|:& };:` - Fork bomb
- `chmod 777 /` - Open all permissions
- `dd if=/dev/zero of=/dev/sda` - Disk wipe
- `> /etc/passwd` - Overwrite system files

## Audit Logging
Confidence
60% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Missing User Warnings

Medium
Confidence
98% confidence
Finding
The documentation recommends environment-variable path expansion using `eval` without any warning, which normalizes an unsafe practice and can lead downstream implementations to execute attacker-controlled shell content. Even as an example, this undermines the skill's security model because boundary enforcement code is often reused verbatim.

Static analysis

No suspicious patterns detected.