Back to skill

Security audit

OpenClaw Self-Improve

Security checks for vulnerabilities and agentic risk

Overview

This skill is mostly a disclosed workflow helper, but its rollback command can revert more repository files than users are told to expect.

Install only if you are comfortable with a repo-mutating workflow. Review proposal.md before rollback, avoid broad rollback targets such as . or directories, keep a separate commit/stash/backup for uncommitted work, and add privacy/consent handling before using the UX feedback examples with real users.

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/init-improvement-run.sh:151
Finding

Artifact-Controlled Git Pathspec Can Broaden Rollback Scope

Content
View full analysis

Vulnerability Details

File Location: scripts/init-improvement-run.sh, lines 151-175
Vulnerability Type: Unvalidated Git pathspec in destructive rollback operation
Risk Level: Medium

Vulnerable Code

bash
if [[ -n "$SCOPE" ]]; then
  TARGETS+=("$SCOPE")
elif [[ -f "$RUN_DIR/proposal.md" ]]; then
  while IFS= read -r line; do
    # accept "- path" or "* path" bullets
    file="${line#- }"
    file="${file#\* }"
    file="$(trim "$file")"
    [[ -n "$file" ]] && TARGETS+=("$file")
  done < <(awk '
    /^## Files To Edit/ { in_section=1; next }
    /^## / && in_section { exit }
    in_section && /^[-*] / { print }
  ' "$RUN_DIR/proposal.md")
fi

if [[ ${#TARGETS[@]} -eq 0 ]]; then
  echo "Refusing rollback: no scope provided and proposal.md has no '## Files To Edit' bullets." >&2
  echo "Pass --scope <path> or fill proposal.md before rolling back." >&2
  exit 1
fi

echo "Rollback targets:"
for t in "${TARGETS[@]}"; do echo "  - $t"; done

if [[ "$IS_GIT_REPO" == "true" ]]; then
  (cd "$REPO_ABS" && git checkout -- "${TARGETS[@]}")

Technical Analysis

Rollback targets are read from the mutable ## Files To Edit section of proposal.md and passed directly to git checkout. Shell quoting and the -- separator prevent shell injection and Git option injection, but they do not make the arguments literal paths.

Git continues to interpret each argument as a pathspec. Consequently, broad targets such as . or Git pathspec magic can match substantially more tracked content than a normal file entry. The implementation does not:

  • Reject Git pathspec magic.
  • Require targets to identify regular files.
  • Reject broad directory targets such as ..
  • Normalize and verify repository-relative paths.
  • Compare rollback targets against a previously approved immutable manifest.
  • Force Git to use literal pathspec semantics.

This violates the documented strict-roll ...[truncated 1556 chars]

Remediation
View remediation

Remediation Suggestions

  1. Force literal Git path handling. Invoke Git with literal pathspec behavior:

    bash
    GIT_LITERAL_PATHSPECS=1 git checkout -- "${TARGETS[@]}"
    
  2. Normalize each target. Require a clean repository-relative path and reject:

    • Absolute paths.
    • Empty paths.
    • . and ...
    • Paths containing traversal components.
    • Git pathspec magic, including values beginning with :(.
    • Directory-only or wildcard targets.
  3. Resolve and enforce repository containment. Canonicalize the parent path and verify that it remains beneath REPO_ABS.

  4. Require file-level targets. Check each target against tracked files before rollback, for example with literal-path Git queries. Reject entries that expand to zero or multiple files.

  5. Use an immutable approved manifest. At approval time, store the exact normalized file list in a dedicated machine-readable artifact and bind it to the approved proposal with a digest. Rollback should consume that manifest rather than reparsing mutable Markdown.

  6. Add a destructive-operation confirmation. Display the fully resolved file list and require explicit confirmation before checkout, with a separate noninteractive flag for controlled CI use.

  7. Preserve recoverability. Before rollback, create a patch or stash of affected worktree changes so unintended data loss can be recovered.

  8. Add security tests. Verify that ., .., absolute paths, directories, wildcard expressions, and Git pathspec magic are rejected while valid repository-relative literal filenames are accepted.

Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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 (8)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The code chunk’s primary purpose is repository backup creation, which is not mentioned in the declared description. The declared skill describes a self-improvement workflow focused on run scaffolding, run comparison, status management, completeness validation, and JSON export for CI. None of those behaviors appear in this script. Instead, it accesses repository contents and writes a backup archive to disk for rollback/safety purposes, which is a materially different capability rather than a minor implementation detail. Therefore this is a clear description-behavior mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description presents a comprehensive approval-gated self-improvement workflow with multiple helpers for managing experiment/run artifacts and evidence. The supplied code chunk instead implements a single utility: detecting likely validation gates in a repository by inspecting files such as package.json, pyproject.toml, go.mod, Cargo.toml, Makefile, etc. While validation-gate detection could be a supporting component of a larger improvement workflow, this code does not realize the main declared functionality and instead has a materially narrower, different purpose. Therefore the description does not accurately represent what this code chunk actually does.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 29)May include surrounding context.

md
- `list-runs.sh` — enumerate every self-improvement run under `<repo>/.openclaw-self-improve/`, newest first, with mode/baseline/validation/outcome status and a

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 110)May include surrounding context.

md
- `list-runs.sh` — enumerate every self-improvement run under `<repo>/.openclaw-self-improve/`, newest first, with mode/baseline/validation/outcome status and a

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 164)May include surrounding context.

md
- `list-runs.sh` — enumerate every self-improvement run under `<repo>/.openclaw-self-improve/`, newest first, with mode/baseline/validation/outcome status and a

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The UX playbook includes commands to collect user feedback and run usability tests on human participants, but it provides no guidance on obtaining informed consent, minimizing collected data, or handling the resulting data safely. In a self-improvement workflow, this omission can lead operators to gather personal or behavioral data in ways that violate privacy expectations, internal policy, or legal requirements.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script uses eval to populate associative arrays from values extracted out of markdown files in the supplied run directories. Because those files are attacker-controlled input relative to this script, shell metacharacters or command substitutions embedded in fields can be evaluated by the shell, causing arbitrary command execution when comparing runs. In this skill context, run artifacts are exactly the kind of semi-structured data that may come from prior automated runs or untrusted branches, which makes this more dangerous rather than less.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.