Back to skill

Security audit

OpenClaw Session Cleanup

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent OpenClaw cleanup runbook, but its install and automation scripts create real review-worthy risk through unpinned remote shell execution, persistent jobs, privileged service setup, and unsafe file handling.

Review this skill carefully before installing. Prefer ClawHub or a pinned, reviewed release over the README curl-to-bash command, do not run the installer as root, inspect environment overrides before use, and only enable cron/watchdog/swap/session-clear steps when you accept persistent host changes and possible service interruption.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (4)

T03 · Remote Payload Retrieval and Execution

Error
Location
README.md:47
Finding

Unpinned Remote Script Retrieval and Immediate Shell Execution

Content
View full analysis
/dev/null 2>&1; then git clone --depth=1 "$REPO_URL" "$TMP_DIR/repo" >/dev/null 2>&1 SOURCE_DIR="$TMP_DIR/repo" else echo "git is required for installation." >&2 exit 1 fi fi ``` ### Technical Analysis The installation instructions download a script from the mutable `main` branch of a personal GitHub repository and pipe it directly to `bash`. There is no commit pinning, release-version pinning, checksum verification, signature validation, or opportunity for inspection before execution. The fetched script then performs a shallow clone using the repository's default branch, creating a second mutable supply-chain boundary. Although the copy of the installer included in the audited artifact does not contain an overt malicious payload, the command documented for users executes whatever content is hosted remotely at execution time. That content can differ from the version reviewed in this audit. ### Attack Path 1. An attacker compromises the repository, its maintainer account, a deployment credential, or another mechanism capable of modifying the remote branch. 2. The attacker replaces the installer on `main` with a malicious shell payload. 3. A user follows the documented one-command installation procedure. 4. `curl` downloads the modified script and s ...[truncated 876 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/install-cron-prune.sh:4
Finding

Predictable Temporary File Allows Symlink and Race Attacks During Cron Installation

Content
View full analysis
/dev/null 2>&1' if crontab -l >/tmp/openclaw-current-crontab 2>/dev/null; then : else : >/tmp/openclaw-current-crontab fi if grep -Fqx "$JOB" /tmp/openclaw-current-crontab; then echo "Cron prune job already present." exit 0 fi printf '%s\n' "$JOB" >> /tmp/openclaw-current-crontab crontab /tmp/openclaw-current-crontab rm -f /tmp/openclaw-current-crontab ``` ### Technical Analysis The installer stores the current crontab in the fixed path `/tmp/openclaw-current-crontab`. Because `/tmp` is normally writable by all local users, another user can pre-create this path as a symbolic link or replace its contents between the script's separate read, validation, append, and installation operations. Shell redirection follows symbolic links. Consequently, the initial truncation or redirection can overwrite another file writable by the invoking account. The subsequent `grep`, append, and `crontab` operations also operate on a pathname that can be exchanged after validation, creating a time-of-check-to-time-of-use race. The script additionally lacks a cleanup trap, so failures can leave the temporary crontab behind for later disclosure or manipulation. ### Attack Path 1. A local attacker predicts the fixed `/tmp/openclaw-current-crontab` pathname. 2. The attacker creates it as a symbolic link to a file writable by the intended victim, or repeatedly replaces the path during execution. 3. The victim runs `install-cron-prune.sh`. 4. Redirection truncates or overwrites the symlink target, or the attacker swaps in malicious cron content after the duplicate check. 5. The script invokes `crontab` on the attacker-influenced file. 6. Attacker-supplied cron commands are installed under the victim's account and execute persistently ...[truncated 502 chars]
Remediation
View remediation
/dev/null; printf '%s\n' "$JOB") | crontab - ``` Duplicate detection must still be preserved. 7. Provide an uninstall command and clearly disclose that the script creates a persistent scheduled task. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
scripts/install-to-openclaw.sh:4
Finding

Environment-Controlled Installation Path Is Recursively Deleted Without Validation

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/render-openclaw-config.sh:4
Finding

Unvalidated Environment Values Permit JSON Configuration Injection

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • 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
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
Findings (21)

Chaining Abuse

High
Category
Tool Misuse
Confidence
98% confidence
Finding

The use of '| bash' is a high-risk execution chain because it removes any opportunity for review and turns a content fetch into immediate command execution. In the context of an ops skill that users may install on production OpenClaw hosts, exploitation could yield full user-level compromise of the host and potentially exposure of runtime configs, tokens, or service state.

Content

Scanner excerpt · README.md (reported line 47)May include surrounding context.

Install directly from GitHub into shared OpenClaw skills:

bash
curl -fsSL https://raw.githubusercontent.com/NeoCh3n/openclaw-session-cleanup-skill/main/scripts/install-to-openclaw.sh | bash

This installs the skill to:

Chaining Abuse

High
Category
Tool Misuse
Confidence
97% confidence
Finding

Using | bash turns remote content delivery into immediate shell execution, eliminating any review barrier and enabling arbitrary command execution with the user's privileges. In an ops-focused skill that may be installed on servers or VPS hosts, this is especially dangerous because it likely targets systems with meaningful access, persistent services, and potentially elevated privileges.

Content

Scanner excerpt · README.zh-CN.md (reported line 49)May include surrounding context.

直接运行:

bash
curl -fsSL https://raw.githubusercontent.com/NeoCh3n/openclaw-session-cleanup-skill/main/scripts/install-to-openclaw.sh | bash

默认会把这个 skill 安装到:

YARA rule 'backdoor_persistence': Backdoor persistence with malicious payloads (shell commands, SSH key injection, hidden root users) [malware]

High
Category
YARA Match
Confidence
75% confidence
Finding

YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Content

Scanner excerpt · scripts/install-cron-prune.sh (reported line 6)May include surrounding context.

sh
#!/usr/bin/env bash
set -euo pipefail

JOB='*/30 * * * * openclaw sessions prune >/dev/null 2>&1'

if crontab -l >/tmp/openclaw-current-crontab 2>/dev/null; then
  :
else
  : >/tmp/openclaw-current-crontab
fi

if grep -Fqx "$JOB" /tmp/openclaw-current-crontab; then
  echo "Cron prune job already present."
  exit 0
fi

printf '%s\n' "$JOB" >> /tmp/openclaw-current-crontab
crontab /tmp/openclaw-current-crontab
rm -f /tmp/openclaw-current-crontab

echo "Installed cron prune job:"
echo "$JOB"

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
95% confidence
Finding

Using a fixed pathname in /tmp and then deleting it with rm -f is unsafe because /tmp is world-writable and susceptible to symlink or race-condition attacks. A local attacker could pre-create or swap /tmp/openclaw-current-crontab to interfere with the script, potentially causing deletion of an unintended file or manipulation of the crontab contents loaded by crontab.

Content

Scanner excerpt · scripts/install-cron-prune.sh (reported line 19)May include surrounding context.

sh
printf '%s\n' "$JOB" >> /tmp/openclaw-current-crontab
crontab /tmp/openclaw-current-crontab
rm -f /tmp/openclaw-current-crontab

echo "Installed cron prune job:"
echo "$JOB"

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The README explicitly promotes a one-command installation flow that downloads a remote script and executes it immediately in the user's shell, without any verification, pinning, or warning. This is dangerous because compromise of the GitHub account, repository, branch, CDN path, or network trust chain could result in arbitrary code execution on the user's machine.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The README recommends a one-line installation method that pipes a remotely fetched script directly into bash without any integrity verification, review step, pinning, or warning. If the upstream repository, network path, or hosting account is compromised, users could execute arbitrary code immediately on their systems.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The README advertises operations such as session clear/prune, cron-based cleanup, watchdog installation, and runtime configuration changes without clearly warning about service interruption, deletion of active state, persistence changes, or system-level side effects. Users may run destructive maintenance steps on production deployments without understanding the operational impact.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill recommends openclaw sessions clear as an escalation step without explicitly warning that it will terminate active sessions and may disrupt in-flight work or state. In an operational runbook, destructive commands are not inherently malicious, but presenting them without confirmation guidance increases the risk of accidental service disruption.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The swapfile setup commands modify host-level memory and filesystem configuration, but the skill does not warn that this changes persistent system state and may have operational side effects. On small VPS hosts, this may be appropriate tuning, yet omitting cautions can lead to unintended changes on managed or production systems.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The document recommends openclaw sessions clear as an escalation step without any warning that it is a destructive operation that can terminate active sessions and disrupt users. In an operational runbook, omission of impact, confirmation, or rollback guidance increases the chance of accidental service disruption during routine troubleshooting.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

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

bash
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
free -h

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · docs/openclaw.session_cleanup_v1.md (reported line 97)May include surrounding context.

bash
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
free -h

Session Persistence

Medium
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/install-cron-prune.sh (reported line 6)May include surrounding context.

sh
JOB='*/30 * * * * openclaw sessions prune >/dev/null 2>&1'

if crontab -l >/tmp/openclaw-current-crontab 2>/dev/null; then
  :
else
  : >/tmp/openclaw-current-crontab

Session Persistence

Medium
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/install-cron-prune.sh (reported line 6)May include surrounding context.

sh
JOB='*/30 * * * * openclaw sessions prune >/dev/null 2>&1'

if crontab -l >/tmp/openclaw-current-crontab 2>/dev/null; then
  :
else
  : >/tmp/openclaw-current-crontab

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This shell script performs a destructive file operation by recursively removing the existing installation directory before recreating it. Although it prints a success message afterward, there is no user-facing warning beforehand, no confirmation prompt, and no inline comment or docstring disclosing that an existing installation will be deleted.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/install-watchdog.sh (reported line 18)May include surrounding context.

sh
$TARGET_DIR/openclaw-watchdog.timer

Next steps:
  sudo systemctl daemon-reload
  sudo systemctl enable --now openclaw-watchdog.timer
EOF

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/install-watchdog.sh (reported line 19)May include surrounding context.

sh
$TARGET_DIR/openclaw-watchdog.timer

Next steps:
  sudo systemctl daemon-reload
  sudo systemctl enable --now openclaw-watchdog.timer
EOF

Session Persistence

Medium
Category
Rogue Agent
Confidence
80% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/install-watchdog.sh (reported line 19)May include surrounding context.

sh
Next steps:
  sudo systemctl daemon-reload
  sudo systemctl enable --now openclaw-watchdog.timer
EOF

External Script Fetching

Low
Category
Supply Chain
Confidence
94% confidence
Finding

This line fetches an external shell script from GitHub and immediately runs it locally. Even if intended as a convenience install method, it creates a direct trust boundary violation where any change to the remote content becomes code execution on the user's system.

Content

Scanner excerpt · README.md (reported line 47)May include surrounding context.

Install directly from GitHub into shared OpenClaw skills:

bash
curl -fsSL https://raw.githubusercontent.com/NeoCh3n/openclaw-session-cleanup-skill/main/scripts/install-to-openclaw.sh | bash

This installs the skill to:

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

该文件整体以中文撰写,面向技能使用与安装说明,但文中未说明这是可选本地化版本,也未提示用户可参考其他语言文档。按语言/区域策略要求,若技能说明强制特定语言且没有用户选择或明确适用范围,可能构成自然语言政策问题。

Content

No source excerpt is available for this finding.

External Script Fetching

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The file instructs users to fetch and execute an external script from GitHub in a single command. This creates a trust-on-first-use remote code execution path with no integrity verification, local inspection, or version pinning, making compromise of the source or delivery channel highly impactful.

Content

Scanner excerpt · README.zh-CN.md (reported line 49)May include surrounding context.

直接运行:

bash
curl -fsSL https://raw.githubusercontent.com/NeoCh3n/openclaw-session-cleanup-skill/main/scripts/install-to-openclaw.sh | bash

默认会把这个 skill 安装到:

Static analysis

No suspicious patterns detected.