Back to skill

Security audit

smart-restart-protection

Security checks for vulnerabilities and agentic risk

Overview

This skill is a coherent OpenClaw Gateway restart helper, but it restarts services and persists configuration backups in ways users should review before installing.

Install only if you intend to give this skill authority to stop/start OpenClaw Gateway and create persistent local backups of OpenClaw configuration. Review backup contents and permissions, avoid running it as a privileged user, and prefer fixing the /tmp lock-file handling before production use.

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
smart-restart.sh:14
Finding
Predictable Symlink-Unsafe Lock File Allows Local File Corruption## Vulnerability Details **File Location**: `smart-restart.sh`, lines 14 and 42–52 **Vulnerability Type**: Unsafe temporary lock file handling **Risk Level**: Medium ### Vulnerable Code ```bash LOCK_FILE="/tmp/openclaw-restart.lock" ``` ```bash check_concurrent() { if [ -f "$LOCK_FILE" ]; then LOCK_PID=$(cat "$LOCK_FILE" 2>/dev/null) if ps -p "$LOCK_PID" > /dev/null 2>&1; then error "另一个重启进程正在运行 (PID: $LOCK_PID)" error "如果确定没有其他进程,请删除锁文件: $LOCK_FILE" exit 1 else warning "发现陈旧的锁文件,正在清理..." rm -f "$LOCK_FILE" fi fi echo $$ > "$LOCK_FILE" } ``` ### Technical Analysis The script uses the fixed, predictable path `/tmp/openclaw-restart.lock` in a shared temporary directory. It creates or truncates this file using shell redirection without securely opening it, atomically claiming it, checking ownership, or rejecting symbolic links. An unprivileged local attacker can place a symbolic link at this predictable path. The test `[ -f "$LOCK_FILE" ]` follows symbolic links. If the target does not appear to contain the PID of a running process, the script removes the link; however, there is a race between that check/removal and the subsequent redirection. The attacker can recreate or replace the path with a symbolic link before: ```bash echo $$ > "$LOCK_FILE" ``` Shell redirection follows the symbolic link and truncates the linked target before writing the process ID. This is a time-of-check-to-time-of-use race combined with unsafe temporary-file handling. The lock is also not acquired atomically. Two concurrent processes can both observe that no valid lock exists and then overwrite the same file, undermining the concurrency protection that the lock is intended to provide. ### Attack Path 1. A local attacker identifies that the victim uses this Skill and monitors `/tmp/openclaw-restart.lock`. 2. T ...[truncated 1469 chars]
Remediation
## Remediation Suggestions 1. Replace the predictable PID-file protocol with an advisory lock opened on a file descriptor: ```bash RUNTIME_DIR="${XDG_RUNTIME_DIR:-$HOME/.openclaw/run}" mkdir -p -- "$RUNTIME_DIR" chmod 700 -- "$RUNTIME_DIR" LOCK_FILE="$RUNTIME_DIR/openclaw-restart.lock" exec 9>"$LOCK_FILE" chmod 600 -- "$LOCK_FILE" if ! flock -n 9; then error "Another restart process is already running" exit 1 fi printf '%s\n' "$$" >&9 ``` Keep descriptor 9 open for the entire operation so the lock is released automatically when the process exits. 2. Prefer `${XDG_RUNTIME_DIR}` when available because it is normally private to the current user. Otherwise, use a dedicated directory under the user's home directory with mode `0700`, rather than a shared `/tmp` path. 3. If a filesystem lock must be created manually, use an atomic operation such as `mkdir` for lock acquisition. Verify that the lock directory is owned by the current user and is not a symbolic link. 4. Do not rely on separate existence checks followed by writes. Such checks introduce time-of-check-to-time-of-use races. 5. Apply restrictive permissions by setting an appropriate `umask`, such as `umask 077`, before creating state or lock files. 6. Add automated tests covering symlink replacement, simultaneous invocations, stale lock recovery, malformed PID contents, and interruption by signals.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (15)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
The mismatch is more severe here because the implementation reportedly deletes backups, clears state files, releases lock files, and exposes system command execution capability without clearly disclosing those actions. Hidden destructive file operations and shell execution in a service-management skill can lead to data loss, bypass of safety controls, or abuse of the agent's execution context.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The mismatch is more severe here because the implementation reportedly deletes backups, clears state files, releases lock files, and exposes system command execution capability without clearly disclosing those actions. Hidden destructive file operations and shell execution in a service-management skill can lead to data loss, bypass of safety controls, or abuse of the agent's execution context.

Ae1

High
Category
analysis-evasion
Content
./check-status.sh
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Context-Inappropriate Capability

High
Confidence
93% confidence
Finding
The skill exposes a generic shell execution helper that can run arbitrary commands via execSync and spawn with shell:true. In a restart-protection skill, this is broader than necessary and creates a command-injection/RCE risk if any current or future code path passes user-influenced input into this helper, especially because shell parsing is enabled.

Natural-Language Policy Violations

Medium
Confidence
82% confidence
Finding
The primary skill description is presented in Chinese and the document consistently assumes Chinese-language usage, with no indication that users may choose another language or that the skill is intentionally limited to a Chinese-speaking context. Under the stated policy, locale/language constraints should be opt-in or clearly justified.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
The README documents `--force` and `--no-backup` modes that explicitly bypass safety controls and recoverability safeguards, but it does not clearly warn users about the consequences such as restart-loop amplification, failed rollback, or permanent loss of recoverable configuration state. In a restart-protection skill, normalizing these unsafe modes without prominent cautions increases the chance that operators will disable the very protections the skill is supposed to enforce.

Lp3

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding
The skill advertises shell-capable behavior via required binaries and usage examples, but it does not declare an explicit tool scope such as permissions or allowed-tools. This creates an authorization and review gap: downstream systems or users cannot clearly determine what command execution capability the skill expects, increasing the chance of unintended shell access.

Natural-Language Policy Violations

Medium
Confidence
90% confidence
Finding
The description and core instructional content are written in Chinese, while the file does not indicate that language choice is optional or that the skill is region-specific. This can violate language/locale policy when users are not given an explicit opt-in or alternative locale.

External Transmission

Medium
Category
Data Exfiltration
Content
# 5. 网络连接
echo ""
echo "🌐 网络连接:"
if curl -s --max-time 5 http://127.0.0.1:18789/ > /dev/null; then
    echo "   ✅ Gateway Web接口可访问"
else
    echo "   ❌ Gateway Web接口不可达"
Confidence
70% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The file consistently emits user-facing recommendations, confirmations, errors, and report content in Chinese, such as restart guidance, reset-confirmation errors, and generated markdown headings. This forces a specific language/locale on users without any visible opt-in or documented region-specific justification, which matches the language-policy violation criterion.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
The manifest description is written only in Chinese, which can indicate a language-specific constraint for the skill without any user opt-in or documented locale justification. Under the policy, natural-language content that forces a specific language without choice should be flagged.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
All user-facing warnings, prompts, and operational messages in the script are written in Chinese, including required confirmations at L025 and L086. This imposes a specific language on users without any opt-in or alternative, which matches the language/locale policy violation category.

Session Persistence

Medium
Category
Rogue Agent
Content
# 步骤1: 备份当前配置
    log "备份当前配置..."
    BACKUP_DIR="$HOME/.openclaw/backups"
    mkdir -p "$BACKUP_DIR"
    BACKUP_FILE="$BACKUP_DIR/openclaw-$(date +%Y%m%d-%H%M%S).json.bak"
    cp ~/.openclaw/openclaw.json "$BACKUP_FILE"
    success "配置已备份到: $BACKUP_FILE"
Confidence
80% confidence
Finding
The script copies ~/.openclaw/openclaw.json into a persistent backup directory under the user's home directory, which can retain sensitive configuration data such as tokens, API keys, or service endpoints longer than necessary. In the context of an agent/gateway restart skill, this increases exposure if the host is multi-user, backups are weakly permissioned, or old backups accumulate and are later exfiltrated.

Natural-Language Policy Violations

Low
Confidence
91% confidence
Finding
The file's natural-language comments and user-facing text are written in Chinese throughout, starting with lines L002-L003, with no indication that language selection is optional or that the skill is intended only for a Chinese-speaking or region-specific context. Under the policy rule, forcing a specific language without user opt-in is a locale/language policy concern.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
The script description and all user-facing messages are written in Chinese, including status, warnings, and operational guidance. This imposes a specific language on users with no opt-in or alternative locale path, which matches the language/locale policy violation criteria.

Static analysis

No suspicious patterns detected.